From 26ea61e8dd834c59f5158e893342686de6142ade Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 11 Aug 2022 08:06:50 +0000 Subject: [PATCH] CodeGen from PR 20188 in Azure/azure-rest-api-specs Merge 943cb59bed16e3fa124272914f66a7b5408f736c into 80065490402157d0df0dd37ab347c651b22eb576 --- sdk/cosmos/azure-mgmt-cosmosdb/_meta.json | 10 +- .../azure/mgmt/cosmosdb/__init__.py | 3 +- .../azure/mgmt/cosmosdb/_configuration.py | 42 +- .../cosmosdb/_cosmos_db_management_client.py | 101 +- .../azure/mgmt/cosmosdb/_patch.py | 2 +- .../azure/mgmt/cosmosdb/_serialization.py | 1970 ++++ .../azure/mgmt/cosmosdb/_vendor.py | 6 +- .../azure/mgmt/cosmosdb/_version.py | 2 +- .../azure/mgmt/cosmosdb/aio/__init__.py | 3 +- .../azure/mgmt/cosmosdb/aio/_configuration.py | 44 +- .../aio/_cosmos_db_management_client.py | 101 +- .../azure/mgmt/cosmosdb/aio/_patch.py | 2 +- .../mgmt/cosmosdb/aio/operations/__init__.py | 81 +- .../_cassandra_clusters_operations.py | 1046 +- .../_cassandra_data_centers_operations.py | 555 +- .../_cassandra_resources_operations.py | 2342 +++-- .../aio/operations/_collection_operations.py | 220 +- .../_collection_partition_operations.py | 148 +- ..._collection_partition_region_operations.py | 85 +- .../_collection_region_operations.py | 83 +- .../_data_transfer_jobs_operations.py | 358 +- .../_database_account_region_operations.py | 84 +- .../_database_accounts_operations.py | 1621 ++-- .../aio/operations/_database_operations.py | 217 +- .../operations/_graph_resources_operations.py | 378 +- .../_gremlin_resources_operations.py | 1735 ++-- .../aio/operations/_locations_operations.py | 101 +- .../_mongo_db_resources_operations.py | 3071 +++--- .../_notebook_workspaces_operations.py | 562 +- .../cosmosdb/aio/operations/_operations.py | 65 +- .../_partition_key_range_id_operations.py | 85 +- ...artition_key_range_id_region_operations.py | 88 +- .../mgmt/cosmosdb/aio/operations/_patch.py | 1 + .../aio/operations/_percentile_operations.py | 82 +- .../_percentile_source_target_operations.py | 82 +- .../_percentile_target_operations.py | 86 +- ...private_endpoint_connections_operations.py | 386 +- .../_private_link_resources_operations.py | 115 +- ...restorable_database_accounts_operations.py | 164 +- ...restorable_gremlin_databases_operations.py | 74 +- .../_restorable_gremlin_graphs_operations.py | 74 +- ...restorable_gremlin_resources_operations.py | 73 +- ...storable_mongodb_collections_operations.py | 76 +- ...restorable_mongodb_databases_operations.py | 74 +- ...restorable_mongodb_resources_operations.py | 73 +- .../_restorable_sql_containers_operations.py | 74 +- .../_restorable_sql_databases_operations.py | 74 +- .../_restorable_sql_resources_operations.py | 73 +- .../_restorable_table_resources_operations.py | 75 +- .../_restorable_tables_operations.py | 73 +- .../aio/operations/_service_operations.py | 380 +- .../operations/_sql_resources_operations.py | 4453 +++++---- .../operations/_table_resources_operations.py | 937 +- .../azure/mgmt/cosmosdb/models/__init__.py | 788 +- .../_cosmos_db_management_client_enums.py | 164 +- .../azure/mgmt/cosmosdb/models/_models_py3.py | 8593 ++++++++--------- .../azure/mgmt/cosmosdb/models/_patch.py | 1 + .../mgmt/cosmosdb/operations/__init__.py | 81 +- .../_cassandra_clusters_operations.py | 1525 +-- .../_cassandra_data_centers_operations.py | 819 +- .../_cassandra_resources_operations.py | 3352 ++++--- .../operations/_collection_operations.py | 334 +- .../_collection_partition_operations.py | 230 +- ..._collection_partition_region_operations.py | 131 +- .../_collection_region_operations.py | 130 +- .../_data_transfer_jobs_operations.py | 595 +- .../_database_account_region_operations.py | 133 +- .../_database_accounts_operations.py | 2338 +++-- .../operations/_database_operations.py | 335 +- .../operations/_graph_resources_operations.py | 550 +- .../_gremlin_resources_operations.py | 2418 ++--- .../operations/_locations_operations.py | 164 +- .../_mongo_db_resources_operations.py | 4219 ++++---- .../_notebook_workspaces_operations.py | 820 +- .../mgmt/cosmosdb/operations/_operations.py | 90 +- .../_partition_key_range_id_operations.py | 131 +- ...artition_key_range_id_region_operations.py | 136 +- .../azure/mgmt/cosmosdb/operations/_patch.py | 1 + .../operations/_percentile_operations.py | 127 +- .../_percentile_source_target_operations.py | 126 +- .../_percentile_target_operations.py | 134 +- ...private_endpoint_connections_operations.py | 544 +- .../_private_link_resources_operations.py | 196 +- ...restorable_database_accounts_operations.py | 262 +- ...restorable_gremlin_databases_operations.py | 114 +- .../_restorable_gremlin_graphs_operations.py | 117 +- ...restorable_gremlin_resources_operations.py | 114 +- ...storable_mongodb_collections_operations.py | 119 +- ...restorable_mongodb_databases_operations.py | 114 +- ...restorable_mongodb_resources_operations.py | 114 +- .../_restorable_sql_containers_operations.py | 117 +- .../_restorable_sql_databases_operations.py | 114 +- .../_restorable_sql_resources_operations.py | 114 +- .../_restorable_table_resources_operations.py | 116 +- .../_restorable_tables_operations.py | 112 +- .../operations/_service_operations.py | 558 +- .../operations/_sql_resources_operations.py | 6223 ++++++------ .../operations/_table_resources_operations.py | 1349 +-- 98 files changed, 33956 insertions(+), 27616 deletions(-) create mode 100644 sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_serialization.py diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/_meta.json b/sdk/cosmos/azure-mgmt-cosmosdb/_meta.json index 5372c9459b6d..7fac189c61c5 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/_meta.json +++ b/sdk/cosmos/azure-mgmt-cosmosdb/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "autorest": "3.8.4", "use": [ - "@autorest/python@5.16.0", - "@autorest/modelerfour@4.19.3" + "@autorest/python@6.0.1", + "@autorest/modelerfour@4.23.5" ], - "commit": "1dd79c416cdccde274113ec03b92b75069fad464", + "commit": "7cf4740b8f4113f6d18c7129e0ec7702dab4385b", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/cosmos-db/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/cosmos-db/resource-manager/readme.md --models-mode=msrest --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.0.1 --use=@autorest/modelerfour@4.23.5 --version=3.8.4 --version-tolerant=False", "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 174f63d0a3d9..f87102f4f8d7 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/__init__.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/__init__.py @@ -17,7 +17,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['CosmosDBManagementClient'] + +__all__ = ["CosmosDBManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _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 4710e83f9166..a0652de2a010 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_configuration.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_configuration.py @@ -25,23 +25,18 @@ class CosmosDBManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-05-15-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(CosmosDBManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-05-15-preview") # type: str + api_version = kwargs.pop("api_version", "2022-05-15-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-cosmosdb/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-cosmosdb/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + 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 = ARMChallengeAuthenticationPolicy(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 cdb059ce46bf..46e83724e201 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 @@ -9,20 +9,60 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models from ._configuration import CosmosDBManagementClientConfiguration -from .operations import CassandraClustersOperations, CassandraDataCentersOperations, CassandraResourcesOperations, CollectionOperations, CollectionPartitionOperations, CollectionPartitionRegionOperations, CollectionRegionOperations, DataTransferJobsOperations, DatabaseAccountRegionOperations, DatabaseAccountsOperations, DatabaseOperations, GraphResourcesOperations, GremlinResourcesOperations, LocationsOperations, MongoDBResourcesOperations, NotebookWorkspacesOperations, Operations, PartitionKeyRangeIdOperations, PartitionKeyRangeIdRegionOperations, PercentileOperations, PercentileSourceTargetOperations, PercentileTargetOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, RestorableDatabaseAccountsOperations, RestorableGremlinDatabasesOperations, RestorableGremlinGraphsOperations, RestorableGremlinResourcesOperations, RestorableMongodbCollectionsOperations, RestorableMongodbDatabasesOperations, RestorableMongodbResourcesOperations, RestorableSqlContainersOperations, RestorableSqlDatabasesOperations, RestorableSqlResourcesOperations, RestorableTableResourcesOperations, RestorableTablesOperations, ServiceOperations, SqlResourcesOperations, TableResourcesOperations +from ._serialization import Deserializer, Serializer +from .operations import ( + CassandraClustersOperations, + CassandraDataCentersOperations, + CassandraResourcesOperations, + CollectionOperations, + CollectionPartitionOperations, + CollectionPartitionRegionOperations, + CollectionRegionOperations, + DataTransferJobsOperations, + DatabaseAccountRegionOperations, + DatabaseAccountsOperations, + DatabaseOperations, + GraphResourcesOperations, + GremlinResourcesOperations, + LocationsOperations, + MongoDBResourcesOperations, + NotebookWorkspacesOperations, + Operations, + PartitionKeyRangeIdOperations, + PartitionKeyRangeIdRegionOperations, + PercentileOperations, + PercentileSourceTargetOperations, + PercentileTargetOperations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + RestorableDatabaseAccountsOperations, + RestorableGremlinDatabasesOperations, + RestorableGremlinGraphsOperations, + RestorableGremlinResourcesOperations, + RestorableMongodbCollectionsOperations, + RestorableMongodbDatabasesOperations, + RestorableMongodbResourcesOperations, + RestorableSqlContainersOperations, + RestorableSqlDatabasesOperations, + RestorableSqlResourcesOperations, + RestorableTableResourcesOperations, + RestorableTablesOperations, + ServiceOperations, + SqlResourcesOperations, + TableResourcesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class CosmosDBManagementClient: # pylint: disable=too-many-instance-attributes + +class CosmosDBManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Cosmos DB Database Service Resource Provider REST API. :ivar database_accounts: DatabaseAccountsOperations operations @@ -119,9 +159,9 @@ class CosmosDBManagementClient: # pylint: disable=too-many-instance-attribute azure.mgmt.cosmosdb.operations.RestorableTableResourcesOperations :ivar service: ServiceOperations operations :vartype service: azure.mgmt.cosmosdb.operations.ServiceOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -139,7 +179,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = CosmosDBManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + 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)} @@ -149,15 +191,9 @@ def __init__( 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.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 ) @@ -170,9 +206,7 @@ def __init__( self.percentile_target = PercentileTargetOperations( self._client, self._config, self._serialize, self._deserialize ) - self.percentile = PercentileOperations( - 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 ) @@ -185,27 +219,19 @@ def __init__( self.partition_key_range_id_region = PartitionKeyRangeIdRegionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.graph_resources = GraphResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.sql_resources = SqlResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.graph_resources = GraphResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.sql_resources = SqlResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.mongo_db_resources = MongoDBResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.table_resources = TableResourcesOperations( - 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.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) self.data_transfer_jobs = DataTransferJobsOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -260,16 +286,9 @@ def __init__( self.restorable_table_resources = RestorableTableResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.service = ServiceOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.service = ServiceOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -278,7 +297,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_patch.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_patch.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_patch.py @@ -28,4 +28,4 @@ # 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 + pass diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_serialization.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_serialization.py new file mode 100644 index 000000000000..648f84cc4e65 --- /dev/null +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_serialization.py @@ -0,0 +1,1970 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes, headers): + # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds() / 3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + + +try: + from datetime import timezone + + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes=None): + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = unicode_str(new_attr) + serialized.append(local_node) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] + if not kwargs.get("skip_quote", False): + data = [quote(str(d), safe="") for d in data] + return str(self.serialize_iter(data, internal_data_type, **kwargs)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback(SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key.""" + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes=None): + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [k for k, v in response._validation.items() if v.get("readonly")] + const = [k for k, v in response._validation.items() if v.get("constant")] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ["true", "1"]: + return True + elif attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_vendor.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_vendor.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + 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 0d5779dc14de..a712687790e5 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 = "8.0.0b1" +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 e5fc49b735f1..f1e67febd9c7 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 @@ -14,7 +14,8 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['CosmosDBManagementClient'] + +__all__ = ["CosmosDBManagementClient"] __all__.extend([p for p in _patch_all if p not in __all__]) _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 cc90646137d3..8be34db14d7b 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 @@ -25,23 +25,18 @@ class CosmosDBManagementClientConfiguration(Configuration): # pylint: disable=t Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-05-15-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(CosmosDBManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-05-15-preview") # type: str + api_version = kwargs.pop("api_version", "2022-05-15-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-cosmosdb/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-cosmosdb/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + 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 = AsyncARMChallengeAuthenticationPolicy(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 187f54593100..651d079f7759 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 @@ -9,20 +9,60 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from .._serialization import Deserializer, Serializer from ._configuration import CosmosDBManagementClientConfiguration -from .operations import CassandraClustersOperations, CassandraDataCentersOperations, CassandraResourcesOperations, CollectionOperations, CollectionPartitionOperations, CollectionPartitionRegionOperations, CollectionRegionOperations, DataTransferJobsOperations, DatabaseAccountRegionOperations, DatabaseAccountsOperations, DatabaseOperations, GraphResourcesOperations, GremlinResourcesOperations, LocationsOperations, MongoDBResourcesOperations, NotebookWorkspacesOperations, Operations, PartitionKeyRangeIdOperations, PartitionKeyRangeIdRegionOperations, PercentileOperations, PercentileSourceTargetOperations, PercentileTargetOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, RestorableDatabaseAccountsOperations, RestorableGremlinDatabasesOperations, RestorableGremlinGraphsOperations, RestorableGremlinResourcesOperations, RestorableMongodbCollectionsOperations, RestorableMongodbDatabasesOperations, RestorableMongodbResourcesOperations, RestorableSqlContainersOperations, RestorableSqlDatabasesOperations, RestorableSqlResourcesOperations, RestorableTableResourcesOperations, RestorableTablesOperations, ServiceOperations, SqlResourcesOperations, TableResourcesOperations +from .operations import ( + CassandraClustersOperations, + CassandraDataCentersOperations, + CassandraResourcesOperations, + CollectionOperations, + CollectionPartitionOperations, + CollectionPartitionRegionOperations, + CollectionRegionOperations, + DataTransferJobsOperations, + DatabaseAccountRegionOperations, + DatabaseAccountsOperations, + DatabaseOperations, + GraphResourcesOperations, + GremlinResourcesOperations, + LocationsOperations, + MongoDBResourcesOperations, + NotebookWorkspacesOperations, + Operations, + PartitionKeyRangeIdOperations, + PartitionKeyRangeIdRegionOperations, + PercentileOperations, + PercentileSourceTargetOperations, + PercentileTargetOperations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + RestorableDatabaseAccountsOperations, + RestorableGremlinDatabasesOperations, + RestorableGremlinGraphsOperations, + RestorableGremlinResourcesOperations, + RestorableMongodbCollectionsOperations, + RestorableMongodbDatabasesOperations, + RestorableMongodbResourcesOperations, + RestorableSqlContainersOperations, + RestorableSqlDatabasesOperations, + RestorableSqlResourcesOperations, + RestorableTableResourcesOperations, + RestorableTablesOperations, + ServiceOperations, + SqlResourcesOperations, + TableResourcesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class CosmosDBManagementClient: # pylint: disable=too-many-instance-attributes + +class CosmosDBManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Cosmos DB Database Service Resource Provider REST API. :ivar database_accounts: DatabaseAccountsOperations operations @@ -122,9 +162,9 @@ class CosmosDBManagementClient: # pylint: disable=too-many-instance-attribute azure.mgmt.cosmosdb.aio.operations.RestorableTableResourcesOperations :ivar service: ServiceOperations operations :vartype service: azure.mgmt.cosmosdb.aio.operations.ServiceOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -142,7 +182,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = CosmosDBManagementClientConfiguration(credential=credential, subscription_id=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)} @@ -152,15 +194,9 @@ def __init__( 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.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 ) @@ -173,9 +209,7 @@ def __init__( self.percentile_target = PercentileTargetOperations( self._client, self._config, self._serialize, self._deserialize ) - self.percentile = PercentileOperations( - 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 ) @@ -188,27 +222,19 @@ def __init__( self.partition_key_range_id_region = PartitionKeyRangeIdRegionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.graph_resources = GraphResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.sql_resources = SqlResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.graph_resources = GraphResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.sql_resources = SqlResourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.mongo_db_resources = MongoDBResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.table_resources = TableResourcesOperations( - 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.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) self.data_transfer_jobs = DataTransferJobsOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -263,16 +289,9 @@ def __init__( self.restorable_table_resources = RestorableTableResourcesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.service = ServiceOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.service = ServiceOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -281,7 +300,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest 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 index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/_patch.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/_patch.py @@ -28,4 +28,4 @@ # 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 + pass diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/__init__.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/__init__.py index f93c597154b4..b9aee75bbc64 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/__init__.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/__init__.py @@ -49,46 +49,47 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DatabaseAccountsOperations', - 'Operations', - 'DatabaseOperations', - 'CollectionOperations', - 'CollectionRegionOperations', - 'DatabaseAccountRegionOperations', - 'PercentileSourceTargetOperations', - 'PercentileTargetOperations', - 'PercentileOperations', - 'CollectionPartitionRegionOperations', - 'CollectionPartitionOperations', - 'PartitionKeyRangeIdOperations', - 'PartitionKeyRangeIdRegionOperations', - 'GraphResourcesOperations', - 'SqlResourcesOperations', - 'MongoDBResourcesOperations', - 'TableResourcesOperations', - 'CassandraResourcesOperations', - 'GremlinResourcesOperations', - 'LocationsOperations', - 'DataTransferJobsOperations', - 'CassandraClustersOperations', - 'CassandraDataCentersOperations', - 'NotebookWorkspacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'RestorableDatabaseAccountsOperations', - 'RestorableSqlDatabasesOperations', - 'RestorableSqlContainersOperations', - 'RestorableSqlResourcesOperations', - 'RestorableMongodbDatabasesOperations', - 'RestorableMongodbCollectionsOperations', - 'RestorableMongodbResourcesOperations', - 'RestorableGremlinDatabasesOperations', - 'RestorableGremlinGraphsOperations', - 'RestorableGremlinResourcesOperations', - 'RestorableTablesOperations', - 'RestorableTableResourcesOperations', - 'ServiceOperations', + "DatabaseAccountsOperations", + "Operations", + "DatabaseOperations", + "CollectionOperations", + "CollectionRegionOperations", + "DatabaseAccountRegionOperations", + "PercentileSourceTargetOperations", + "PercentileTargetOperations", + "PercentileOperations", + "CollectionPartitionRegionOperations", + "CollectionPartitionOperations", + "PartitionKeyRangeIdOperations", + "PartitionKeyRangeIdRegionOperations", + "GraphResourcesOperations", + "SqlResourcesOperations", + "MongoDBResourcesOperations", + "TableResourcesOperations", + "CassandraResourcesOperations", + "GremlinResourcesOperations", + "LocationsOperations", + "DataTransferJobsOperations", + "CassandraClustersOperations", + "CassandraDataCentersOperations", + "NotebookWorkspacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "RestorableDatabaseAccountsOperations", + "RestorableSqlDatabasesOperations", + "RestorableSqlContainersOperations", + "RestorableSqlResourcesOperations", + "RestorableMongodbDatabasesOperations", + "RestorableMongodbCollectionsOperations", + "RestorableMongodbResourcesOperations", + "RestorableGremlinDatabasesOperations", + "RestorableGremlinGraphsOperations", + "RestorableGremlinResourcesOperations", + "RestorableTablesOperations", + "RestorableTableResourcesOperations", + "ServiceOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() 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 af76294875d2..b01d05c46de7 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 @@ -6,10 +6,17 @@ # 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 Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,25 @@ 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_backup_request, build_get_request, build_invoke_command_request_initial, build_list_backups_request, 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') +from ...operations._cassandra_clusters_operations import ( + build_create_update_request, + build_deallocate_request, + build_delete_request, + build_get_backup_request, + build_get_request, + build_invoke_command_request, + build_list_backups_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_start_request, + build_status_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class CassandraClustersOperations: """ .. warning:: @@ -45,36 +67,31 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable[_models.ListClusters]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ClusterResource"]: """List all managed Cassandra clusters in this subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListClusters or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.ListClusters] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ClusterResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.ClusterResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListClusters] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListClusters] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -82,14 +99,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -105,10 +119,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -118,45 +130,41 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/cassandraClusters"} # type: ignore + 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, - **kwargs: Any - ) -> AsyncIterable[_models.ListClusters]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ClusterResource"]: """List all managed Cassandra clusters in this resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :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 ListClusters or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.ListClusters] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ClusterResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.ClusterResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListClusters] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListClusters] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -164,15 +172,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -188,10 +192,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -201,48 +203,39 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters"} # type: ignore + 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, - cluster_name: str, - **kwargs: Any - ) -> _models.ClusterResource: + async def get(self, 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. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ClusterResource, or the result of cls(response) + :return: ClusterResource or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ClusterResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ClusterResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -250,50 +243,42 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ClusterResource', pipeline_response) + deserialized = self._deserialize("ClusterResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, cluster_name=cluster_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -301,10 +286,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -314,21 +298,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a managed Cassandra cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :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. @@ -340,85 +319,79 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore async def _create_update_initial( - self, - resource_group_name: str, - cluster_name: str, - body: _models.ClusterResource, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, body: Union[_models.ClusterResource, IO], **kwargs: Any ) -> _models.ClusterResource: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ClusterResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterResource] - _json = self._serialize.body(body, 'ClusterResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = self._serialize.body(body, "ClusterResource") - request = build_create_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_initial.metadata['url'], + content=_content, + template_url=self._create_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -426,10 +399,9 @@ async def _create_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -437,36 +409,80 @@ async def _create_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ClusterResource', pipeline_response) + deserialized = self._deserialize("ClusterResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ClusterResource', pipeline_response) + deserialized = self._deserialize("ClusterResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore + _create_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_update( self, resource_group_name: str, cluster_name: str, body: _models.ClusterResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ClusterResource]: """Create or update a managed Cassandra cluster. When updating, you must specify all writable properties. To update only some properties, use PATCH. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str :param body: The properties specifying the desired state of the managed Cassandra cluster. + Required. :type body: ~azure.mgmt.cosmosdb.models.ClusterResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ClusterResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_update( + self, + resource_group_name: str, + cluster_name: str, + body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ClusterResource]: + """Create or update a managed Cassandra cluster. When updating, you must specify all writable + properties. To update only some properties, use PATCH. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: The properties specifying the desired state of the managed Cassandra cluster. + Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -478,20 +494,49 @@ async def begin_create_update( :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: + """ + + @distributed_trace_async + async def begin_create_update( + self, resource_group_name: str, cluster_name: str, body: Union[_models.ClusterResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.ClusterResource]: + """Create or update a managed Cassandra cluster. When updating, you must specify all writable + properties. To update only some properties, use PATCH. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: The properties specifying the desired state of the managed Cassandra cluster. Is + either a model type or a IO type. Required. + :type body: ~azure.mgmt.cosmosdb.models.ClusterResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ClusterResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ClusterResource] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -499,69 +544,66 @@ async def begin_create_update( body=body, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ClusterResource', pipeline_response) + deserialized = self._deserialize("ClusterResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_create_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore async def _update_initial( - self, - resource_group_name: str, - cluster_name: str, - body: _models.ClusterResource, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, body: Union[_models.ClusterResource, IO], **kwargs: Any ) -> _models.ClusterResource: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ClusterResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterResource] - _json = self._serialize.body(body, 'ClusterResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = self._serialize.body(body, "ClusterResource") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -569,10 +611,9 @@ async def _update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -580,35 +621,107 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ClusterResource', pipeline_response) + deserialized = self._deserialize("ClusterResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ClusterResource', pipeline_response) + deserialized = self._deserialize("ClusterResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, cluster_name: str, body: _models.ClusterResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_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. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :param body: Parameters to provide for specifying the managed Cassandra cluster. + :param body: Parameters to provide for specifying the managed Cassandra cluster. Required. :type body: ~azure.mgmt.cosmosdb.models.ClusterResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ClusterResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_name: str, + body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: Parameters to provide for specifying the managed Cassandra cluster. Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ClusterResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, resource_group_name: str, cluster_name: str, body: Union[_models.ClusterResource, IO], **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: Parameters to provide for specifying the managed Cassandra cluster. Is either a + model type or a IO type. Required. + :type body: ~azure.mgmt.cosmosdb.models.ClusterResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -620,20 +733,17 @@ async def begin_update( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ClusterResource] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, @@ -641,69 +751,66 @@ async def begin_update( body=body, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ClusterResource', pipeline_response) + deserialized = self._deserialize("ClusterResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore async def _invoke_command_initial( - self, - resource_group_name: str, - cluster_name: str, - body: _models.CommandPostBody, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, body: Union[_models.CommandPostBody, IO], **kwargs: Any ) -> _models.CommandOutput: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CommandOutput] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CommandOutput] - _json = self._serialize.body(body, 'CommandPostBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = self._serialize.body(body, "CommandPostBody") - request = build_invoke_command_request_initial( - subscription_id=self._config.subscription_id, + request = build_invoke_command_request( resource_group_name=resource_group_name, cluster_name=cluster_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._invoke_command_initial.metadata['url'], + content=_content, + template_url=self._invoke_command_initial.metadata["url"], headers=_headers, params=_params, ) @@ -711,42 +818,113 @@ async def _invoke_command_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CommandOutput', pipeline_response) + deserialized = self._deserialize("CommandOutput", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _invoke_command_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/invokeCommand"} # type: ignore - + _invoke_command_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/invokeCommand"} # type: ignore - @distributed_trace_async + @overload async def begin_invoke_command( self, resource_group_name: str, cluster_name: str, body: _models.CommandPostBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.CommandOutput]: """Invoke a command like nodetool for cassandra maintenance. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :param body: Specification which command to run where. + :param body: Specification which command to run where. Required. :type body: ~azure.mgmt.cosmosdb.models.CommandPostBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CommandOutput] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_invoke_command( + self, + resource_group_name: str, + cluster_name: str, + body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CommandOutput]: + """Invoke a command like nodetool for cassandra maintenance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: Specification which command to run where. Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CommandOutput] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_invoke_command( + self, resource_group_name: str, cluster_name: str, body: Union[_models.CommandPostBody, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.CommandOutput]: + """Invoke a command like nodetool for cassandra maintenance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: Specification which command to run where. Is either a model type or a IO type. + Required. + :type body: ~azure.mgmt.cosmosdb.models.CommandPostBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -758,20 +936,17 @@ async def begin_invoke_command( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CommandOutput] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CommandOutput] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._invoke_command_initial( # type: ignore resource_group_name=resource_group_name, @@ -779,77 +954,70 @@ async def begin_invoke_command( body=body, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('CommandOutput', pipeline_response) + deserialized = self._deserialize("CommandOutput", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_invoke_command.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/invokeCommand"} # type: ignore @distributed_trace def list_backups( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ListBackups]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BackupResource"]: """List the backups of this cluster that are available to restore. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListBackups or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.ListBackups] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BackupResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.BackupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBackups] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBackups] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_backups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_backups.metadata['url'], + template_url=self.list_backups.metadata["url"], headers=_headers, params=_params, ) @@ -857,16 +1025,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_backups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -882,10 +1045,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -895,52 +1056,44 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_backups.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/backups"} # type: ignore + list_backups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/backups"} # type: ignore @distributed_trace_async async def get_backup( - self, - resource_group_name: str, - cluster_name: str, - backup_id: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, backup_id: str, **kwargs: Any ) -> _models.BackupResource: """Get the properties of an individual backup of this cluster that is available to restore. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :param backup_id: Id of a restorable backup of a Cassandra cluster. + :param backup_id: Id of a restorable backup of a Cassandra cluster. Required. :type backup_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BackupResource, or the result of cls(response) + :return: BackupResource or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.BackupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BackupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupResource] - request = build_get_backup_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, backup_id=backup_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_backup.metadata['url'], + template_url=self.get_backup.metadata["url"], headers=_headers, params=_params, ) @@ -948,50 +1101,42 @@ async def get_backup( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BackupResource', pipeline_response) + deserialized = self._deserialize("BackupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_backup.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/backups/{backupId}"} # type: ignore - + get_backup.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/backups/{backupId}"} # type: ignore async def _deallocate_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deallocate_request_initial( - subscription_id=self._config.subscription_id, + request = build_deallocate_request( resource_group_name=resource_group_name, cluster_name=cluster_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._deallocate_initial.metadata['url'], + template_url=self._deallocate_initial.metadata["url"], headers=_headers, params=_params, ) @@ -999,10 +1144,9 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202]: @@ -1012,23 +1156,20 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _deallocate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/deallocate"} # type: ignore - + _deallocate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/deallocate"} # type: ignore @distributed_trace_async - async def begin_deallocate( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + async def begin_deallocate( + self, resource_group_name: str, cluster_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deallocate the Managed Cassandra Cluster and Associated Data Centers. Deallocation will deallocate the host virtual machine of this cluster, and reserved the data disk. This won't do anything on an already deallocated cluster. Use Start to restart the cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :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. @@ -1040,80 +1181,67 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_deallocate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/deallocate"} # type: ignore async def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + request = build_start_request( resource_group_name=resource_group_name, cluster_name=cluster_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1121,10 +1249,9 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202]: @@ -1134,23 +1261,18 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/start"} # type: ignore @distributed_trace_async - async def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_start(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncLROPoller[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. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :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. @@ -1162,92 +1284,80 @@ async def begin_start( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - cluster_name: str, - **kwargs: Any + self, 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. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CassandraClusterPublicStatus, or the result of cls(response) + :return: CassandraClusterPublicStatus or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.CassandraClusterPublicStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.CassandraClusterPublicStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CassandraClusterPublicStatus] - request = build_status_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.status.metadata['url'], + template_url=self.status.metadata["url"], headers=_headers, params=_params, ) @@ -1255,22 +1365,20 @@ async def status( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CassandraClusterPublicStatus', pipeline_response) + deserialized = self._deserialize("CassandraClusterPublicStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - status.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/status"} # type: ignore - + 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 350e96670c37..31672e312480 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 @@ -6,10 +6,17 @@ # 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 Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,18 @@ 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') +from ...operations._cassandra_data_centers_operations import ( + build_create_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class CassandraDataCentersOperations: """ .. warning:: @@ -45,44 +60,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ListDataCenters]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DataCenterResource"]: """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. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListDataCenters or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.ListDataCenters] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataCenterResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.DataCenterResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListDataCenters] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListDataCenters] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -90,16 +101,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -115,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -128,52 +132,44 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters"} # type: ignore + 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, - cluster_name: str, - data_center_name: str, - **kwargs: Any + self, 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. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :param data_center_name: Data center name in a managed Cassandra cluster. + :param data_center_name: Data center name in a managed Cassandra cluster. Required. :type data_center_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCenterResource, or the result of cls(response) + :return: DataCenterResource or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DataCenterResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCenterResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCenterResource] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -181,52 +177,43 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCenterResource', pipeline_response) + deserialized = self._deserialize("DataCenterResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - cluster_name: str, - data_center_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, data_center_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, cluster_name=cluster_name, data_center_name=data_center_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -234,10 +221,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -247,24 +233,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - cluster_name: str, - data_center_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, cluster_name: str, data_center_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a managed Cassandra data center. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :param data_center_name: Data center name in a managed Cassandra cluster. + :param data_center_name: Data center name in a managed Cassandra cluster. Required. :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. @@ -276,88 +258,86 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, data_center_name=data_center_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}"} # type: ignore async def _create_update_initial( self, resource_group_name: str, cluster_name: str, data_center_name: str, - body: _models.DataCenterResource, + body: Union[_models.DataCenterResource, IO], **kwargs: Any ) -> _models.DataCenterResource: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCenterResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCenterResource] - _json = self._serialize.body(body, 'DataCenterResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = self._serialize.body(body, "DataCenterResource") - request = build_create_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, data_center_name=data_center_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_initial.metadata['url'], + content=_content, + template_url=self._create_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -365,10 +345,9 @@ async def _create_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -376,39 +355,44 @@ async def _create_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataCenterResource', pipeline_response) + deserialized = self._deserialize("DataCenterResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataCenterResource', pipeline_response) + deserialized = self._deserialize("DataCenterResource", pipeline_response) if cls: 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 - + _create_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_update( self, resource_group_name: str, cluster_name: str, data_center_name: str, body: _models.DataCenterResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DataCenterResource]: """Create or update a managed Cassandra data center. When updating, overwrite all properties. To update only some properties, use PATCH. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :param data_center_name: Data center name in a managed Cassandra cluster. + :param data_center_name: Data center name in a managed Cassandra cluster. Required. :type data_center_name: str - :param body: Parameters specifying the managed Cassandra data center. + :param body: Parameters specifying the managed Cassandra data center. Required. :type body: ~azure.mgmt.cosmosdb.models.DataCenterResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 @@ -420,20 +404,96 @@ async def begin_create_update( :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: + """ + + @overload + async def begin_create_update( + self, + resource_group_name: str, + cluster_name: str, + data_center_name: str, + body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataCenterResource]: + """Create or update a managed Cassandra data center. When updating, overwrite all properties. To + update only some properties, use PATCH. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param data_center_name: Data center name in a managed Cassandra cluster. Required. + :type data_center_name: str + :param body: Parameters specifying the managed Cassandra data center. Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.DataCenterResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_update( + self, + resource_group_name: str, + cluster_name: str, + data_center_name: str, + body: Union[_models.DataCenterResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DataCenterResource]: + """Create or update a managed Cassandra data center. When updating, overwrite all properties. To + update only some properties, use PATCH. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param data_center_name: Data center name in a managed Cassandra cluster. Required. + :type data_center_name: str + :param body: Parameters specifying the managed Cassandra data center. Is either a model type or + a IO type. Required. + :type body: ~azure.mgmt.cosmosdb.models.DataCenterResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.DataCenterResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCenterResource] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCenterResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -442,71 +502,72 @@ async def begin_create_update( body=body, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataCenterResource', pipeline_response) + deserialized = self._deserialize("DataCenterResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_create_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}"} # type: ignore async def _update_initial( self, resource_group_name: str, cluster_name: str, data_center_name: str, - body: _models.DataCenterResource, + body: Union[_models.DataCenterResource, IO], **kwargs: Any ) -> _models.DataCenterResource: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCenterResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCenterResource] - _json = self._serialize.body(body, 'DataCenterResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = self._serialize.body(body, "DataCenterResource") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, data_center_name=data_center_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -514,10 +575,9 @@ async def _update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -525,38 +585,82 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataCenterResource', pipeline_response) + deserialized = self._deserialize("DataCenterResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DataCenterResource', pipeline_response) + deserialized = self._deserialize("DataCenterResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, cluster_name: str, data_center_name: str, body: _models.DataCenterResource, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_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. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :param data_center_name: Data center name in a managed Cassandra cluster. + :param data_center_name: Data center name in a managed Cassandra cluster. Required. :type data_center_name: str - :param body: Parameters to provide for specifying the managed Cassandra data center. + :param body: Parameters to provide for specifying the managed Cassandra data center. Required. :type body: ~azure.mgmt.cosmosdb.models.DataCenterResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.DataCenterResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_name: str, + data_center_name: str, + body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param data_center_name: Data center name in a managed Cassandra cluster. Required. + :type data_center_name: str + :param body: Parameters to provide for specifying the managed Cassandra data center. Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -568,20 +672,55 @@ async def begin_update( :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: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + cluster_name: str, + data_center_name: str, + body: Union[_models.DataCenterResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param data_center_name: Data center name in a managed Cassandra cluster. Required. + :type data_center_name: str + :param body: Parameters to provide for specifying the managed Cassandra data center. Is either + a model type or a IO type. Required. + :type body: ~azure.mgmt.cosmosdb.models.DataCenterResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.DataCenterResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCenterResource] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCenterResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, @@ -590,36 +729,32 @@ async def begin_update( body=body, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataCenterResource', pipeline_response) + deserialized = self._deserialize("DataCenterResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 6cacc546d289..ff3787226eb5 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 @@ -6,10 +6,17 @@ # 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 Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,37 @@ 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_create_update_cassandra_view_request_initial, build_delete_cassandra_keyspace_request_initial, build_delete_cassandra_table_request_initial, build_delete_cassandra_view_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_get_cassandra_view_request, build_get_cassandra_view_throughput_request, build_list_cassandra_keyspaces_request, build_list_cassandra_tables_request, build_list_cassandra_views_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_migrate_cassandra_view_to_autoscale_request_initial, build_migrate_cassandra_view_to_manual_throughput_request_initial, build_update_cassandra_keyspace_throughput_request_initial, build_update_cassandra_table_throughput_request_initial, build_update_cassandra_view_throughput_request_initial -T = TypeVar('T') +from ...operations._cassandra_resources_operations import ( + build_create_update_cassandra_keyspace_request, + build_create_update_cassandra_table_request, + build_create_update_cassandra_view_request, + build_delete_cassandra_keyspace_request, + build_delete_cassandra_table_request, + build_delete_cassandra_view_request, + build_get_cassandra_keyspace_request, + build_get_cassandra_keyspace_throughput_request, + build_get_cassandra_table_request, + build_get_cassandra_table_throughput_request, + build_get_cassandra_view_request, + build_get_cassandra_view_throughput_request, + build_list_cassandra_keyspaces_request, + build_list_cassandra_tables_request, + build_list_cassandra_views_request, + build_migrate_cassandra_keyspace_to_autoscale_request, + build_migrate_cassandra_keyspace_to_manual_throughput_request, + build_migrate_cassandra_table_to_autoscale_request, + build_migrate_cassandra_table_to_manual_throughput_request, + build_migrate_cassandra_view_to_autoscale_request, + build_migrate_cassandra_view_to_manual_throughput_request, + build_update_cassandra_keyspace_throughput_request, + build_update_cassandra_table_throughput_request, + build_update_cassandra_view_throughput_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class CassandraResourcesOperations: # pylint: disable=too-many-public-methods """ .. warning:: @@ -45,46 +79,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_cassandra_keyspaces( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.CassandraKeyspaceListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CassandraKeyspaceGetResults"]: """Lists the Cassandra keyspaces under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 + :return: An iterator like instance of either CassandraKeyspaceGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CassandraKeyspaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.CassandraKeyspaceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CassandraKeyspaceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_cassandra_keyspaces_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_cassandra_keyspaces.metadata['url'], + template_url=self.list_cassandra_keyspaces.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +122,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_cassandra_keyspaces_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +142,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -130,53 +153,45 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_cassandra_keyspaces.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces"} # type: ignore + 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, - account_name: str, - keyspace_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any ) -> _models.CassandraKeyspaceGetResults: """Gets the Cassandra keyspaces under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CassandraKeyspaceGetResults, or the result of cls(response) + :return: CassandraKeyspaceGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.CassandraKeyspaceGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CassandraKeyspaceGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_cassandra_keyspace.metadata['url'], + template_url=self.get_cassandra_keyspace.metadata["url"], headers=_headers, params=_params, ) @@ -184,57 +199,62 @@ async def get_cassandra_keyspace( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CassandraKeyspaceGetResults', pipeline_response) + deserialized = self._deserialize("CassandraKeyspaceGetResults", pipeline_response) if cls: 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 - + 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, account_name: str, keyspace_name: str, - create_update_cassandra_keyspace_parameters: _models.CassandraKeyspaceCreateUpdateParameters, + create_update_cassandra_keyspace_parameters: Union[_models.CassandraKeyspaceCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.CassandraKeyspaceGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.CassandraKeyspaceGetResults]] - - _json = self._serialize.body(create_update_cassandra_keyspace_parameters, 'CassandraKeyspaceCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.CassandraKeyspaceGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_cassandra_keyspace_parameters, (IO, bytes)): + _content = create_update_cassandra_keyspace_parameters + else: + _json = self._serialize.body( + create_update_cassandra_keyspace_parameters, "CassandraKeyspaceCreateUpdateParameters" + ) - request = build_create_update_cassandra_keyspace_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_cassandra_keyspace_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_cassandra_keyspace_initial.metadata['url'], + content=_content, + template_url=self._create_update_cassandra_keyspace_initial.metadata["url"], headers=_headers, params=_params, ) @@ -242,10 +262,9 @@ async def _create_update_cassandra_keyspace_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -254,37 +273,123 @@ async def _create_update_cassandra_keyspace_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('CassandraKeyspaceGetResults', pipeline_response) + deserialized = self._deserialize("CassandraKeyspaceGetResults", pipeline_response) if cls: 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 - + _create_update_cassandra_keyspace_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_update_cassandra_keyspace( self, resource_group_name: str, account_name: str, keyspace_name: str, create_update_cassandra_keyspace_parameters: _models.CassandraKeyspaceCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.CassandraKeyspaceGetResults]: """Create or update an Azure Cosmos DB Cassandra keyspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str :param create_update_cassandra_keyspace_parameters: The parameters to provide for the current - Cassandra keyspace. + Cassandra keyspace. Required. :type create_update_cassandra_keyspace_parameters: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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: + """ + + @overload + async def begin_create_update_cassandra_keyspace( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + create_update_cassandra_keyspace_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CassandraKeyspaceGetResults]: + """Create or update an Azure Cosmos DB Cassandra keyspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param create_update_cassandra_keyspace_parameters: The parameters to provide for the current + Cassandra keyspace. Required. + :type create_update_cassandra_keyspace_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_create_update_cassandra_keyspace( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + create_update_cassandra_keyspace_parameters: Union[_models.CassandraKeyspaceCreateUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.CassandraKeyspaceGetResults]: + """Create or update an Azure Cosmos DB Cassandra keyspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param create_update_cassandra_keyspace_parameters: The parameters to provide for the current + Cassandra keyspace. Is either a model type or a IO type. Required. + :type create_update_cassandra_keyspace_parameters: + ~azure.mgmt.cosmosdb.models.CassandraKeyspaceCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -297,20 +402,17 @@ async def begin_create_update_cassandra_keyspace( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CassandraKeyspaceGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CassandraKeyspaceGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_update_cassandra_keyspace_initial( # type: ignore resource_group_name=resource_group_name, @@ -319,66 +421,55 @@ async def begin_create_update_cassandra_keyspace( create_update_cassandra_keyspace_parameters=create_update_cassandra_keyspace_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('CassandraKeyspaceGetResults', pipeline_response) + deserialized = self._deserialize("CassandraKeyspaceGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_cassandra_keyspace_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_cassandra_keyspace_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_cassandra_keyspace_initial.metadata['url'], + template_url=self._delete_cassandra_keyspace_initial.metadata["url"], headers=_headers, params=_params, ) @@ -386,10 +477,9 @@ async def _delete_cassandra_keyspace_initial( # pylint: disable=inconsistent-re request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -399,24 +489,20 @@ async def _delete_cassandra_keyspace_initial( # pylint: disable=inconsistent-re if cls: return cls(pipeline_response, None, {}) - _delete_cassandra_keyspace_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - **kwargs: Any + async def begin_delete_cassandra_keyspace( + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Azure Cosmos DB Cassandra keyspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :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. @@ -428,98 +514,85 @@ async def begin_delete_cassandra_keyspace( # pylint: disable=inconsistent-retur 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_cassandra_keyspace_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - account_name: str, - keyspace_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: """Gets the RUs per second of the Cassandra Keyspace under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ThroughputSettingsGetResults, or the result of cls(response) + :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_cassandra_keyspace_throughput.metadata['url'], + template_url=self.get_cassandra_keyspace_throughput.metadata["url"], headers=_headers, params=_params, ) @@ -527,57 +600,60 @@ async def get_cassandra_keyspace_throughput( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + 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, account_name: str, keyspace_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IO, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - request = build_update_cassandra_keyspace_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_cassandra_keyspace_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_cassandra_keyspace_throughput_initial.metadata['url'], + content=_content, + template_url=self._update_cassandra_keyspace_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -585,10 +661,9 @@ async def _update_cassandra_keyspace_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -597,37 +672,123 @@ async def _update_cassandra_keyspace_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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 + @overload async def begin_update_cassandra_keyspace_throughput( self, resource_group_name: str, account_name: str, keyspace_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Update RUs per second of an Azure Cosmos DB Cassandra Keyspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Cassandra Keyspace. + current Cassandra Keyspace. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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: + """ + + @overload + async def begin_update_cassandra_keyspace_throughput( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + update_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Cassandra Keyspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Cassandra Keyspace. Required. + :type update_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_update_cassandra_keyspace_throughput( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Cassandra Keyspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Cassandra Keyspace. Is either a model type or a IO type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -640,20 +801,17 @@ async def begin_update_cassandra_keyspace_throughput( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._update_cassandra_keyspace_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -662,66 +820,55 @@ async def begin_update_cassandra_keyspace_throughput( update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_cassandra_keyspace_to_autoscale_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_cassandra_keyspace_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_cassandra_keyspace_to_autoscale_initial.metadata['url'], + template_url=self._migrate_cassandra_keyspace_to_autoscale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -729,10 +876,9 @@ async def _migrate_cassandra_keyspace_to_autoscale_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -741,31 +887,27 @@ async def _migrate_cassandra_keyspace_to_autoscale_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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, - account_name: str, - keyspace_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any ) -> AsyncLROPoller[_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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :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. @@ -779,85 +921,71 @@ async def begin_migrate_cassandra_keyspace_to_autoscale( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._migrate_cassandra_keyspace_to_autoscale_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_cassandra_keyspace_to_manual_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_cassandra_keyspace_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_cassandra_keyspace_to_manual_throughput_initial.metadata['url'], + template_url=self._migrate_cassandra_keyspace_to_manual_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -865,10 +993,9 @@ async def _migrate_cassandra_keyspace_to_manual_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -877,31 +1004,27 @@ async def _migrate_cassandra_keyspace_to_manual_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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, - account_name: str, - keyspace_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any ) -> AsyncLROPoller[_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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :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. @@ -915,102 +1038,91 @@ async def begin_migrate_cassandra_keyspace_to_manual_throughput( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._migrate_cassandra_keyspace_to_manual_throughput_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - account_name: str, - keyspace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.CassandraTableListResult]: + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CassandraTableGetResults"]: """Lists the Cassandra table under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :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 + :return: An iterator like instance of either CassandraTableGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CassandraTableListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.CassandraTableListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CassandraTableListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_cassandra_tables.metadata['url'], + template_url=self.list_cassandra_tables.metadata["url"], headers=_headers, params=_params, ) @@ -1018,17 +1130,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1044,10 +1150,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1057,56 +1161,47 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + 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, - account_name: str, - keyspace_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> _models.CassandraTableGetResults: """Gets the Cassandra table under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CassandraTableGetResults, or the result of cls(response) + :return: CassandraTableGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.CassandraTableGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.CassandraTableGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CassandraTableGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_cassandra_table.metadata['url'], + template_url=self.get_cassandra_table.metadata["url"], headers=_headers, params=_params, ) @@ -1114,25 +1209,23 @@ async def get_cassandra_table( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CassandraTableGetResults', pipeline_response) + deserialized = self._deserialize("CassandraTableGetResults", pipeline_response) if cls: 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 - + 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, @@ -1140,33 +1233,40 @@ async def _create_update_cassandra_table_initial( account_name: str, keyspace_name: str, table_name: str, - create_update_cassandra_table_parameters: _models.CassandraTableCreateUpdateParameters, + create_update_cassandra_table_parameters: Union[_models.CassandraTableCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.CassandraTableGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.CassandraTableGetResults]] - - _json = self._serialize.body(create_update_cassandra_table_parameters, 'CassandraTableCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.CassandraTableGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_cassandra_table_parameters, (IO, bytes)): + _content = create_update_cassandra_table_parameters + else: + _json = self._serialize.body( + create_update_cassandra_table_parameters, "CassandraTableCreateUpdateParameters" + ) - request = build_create_update_cassandra_table_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_cassandra_table_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_cassandra_table_initial.metadata['url'], + content=_content, + template_url=self._create_update_cassandra_table_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1174,10 +1274,9 @@ async def _create_update_cassandra_table_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1186,17 +1285,16 @@ async def _create_update_cassandra_table_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('CassandraTableGetResults', pipeline_response) + deserialized = self._deserialize("CassandraTableGetResults", pipeline_response) if cls: 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 + _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 + @overload async def begin_create_update_cassandra_table( self, resource_group_name: str, @@ -1204,22 +1302,28 @@ async def begin_create_update_cassandra_table( keyspace_name: str, table_name: str, create_update_cassandra_table_parameters: _models.CassandraTableCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.CassandraTableGetResults]: """Create or update an Azure Cosmos DB Cassandra Table. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :type table_name: str :param create_update_cassandra_table_parameters: The parameters to provide for the current - Cassandra Table. + Cassandra Table. Required. :type create_update_cassandra_table_parameters: ~azure.mgmt.cosmosdb.models.CassandraTableCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :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 @@ -1232,20 +1336,104 @@ async def begin_create_update_cassandra_table( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_update_cassandra_table( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + create_update_cassandra_table_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CassandraTableGetResults]: + """Create or update an Azure Cosmos DB Cassandra Table. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param create_update_cassandra_table_parameters: The parameters to provide for the current + Cassandra Table. Required. + :type create_update_cassandra_table_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_create_update_cassandra_table( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + create_update_cassandra_table_parameters: Union[_models.CassandraTableCreateUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.CassandraTableGetResults]: + """Create or update an Azure Cosmos DB Cassandra Table. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param create_update_cassandra_table_parameters: The parameters to provide for the current + Cassandra Table. Is either a model type or a IO type. Required. + :type create_update_cassandra_table_parameters: + ~azure.mgmt.cosmosdb.models.CassandraTableCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CassandraTableGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CassandraTableGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_update_cassandra_table_initial( # type: ignore resource_group_name=resource_group_name, @@ -1255,68 +1443,56 @@ async def begin_create_update_cassandra_table( create_update_cassandra_table_parameters=create_update_cassandra_table_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('CassandraTableGetResults', pipeline_response) + deserialized = self._deserialize("CassandraTableGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_cassandra_table_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_cassandra_table_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_cassandra_table_initial.metadata['url'], + template_url=self._delete_cassandra_table_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1324,10 +1500,9 @@ async def _delete_cassandra_table_initial( # pylint: disable=inconsistent-retur request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1337,27 +1512,22 @@ async def _delete_cassandra_table_initial( # pylint: disable=inconsistent-retur if cls: return cls(pipeline_response, None, {}) - _delete_cassandra_table_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - table_name: str, - **kwargs: Any + async def begin_delete_cassandra_table( + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Azure Cosmos DB Cassandra table. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :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. @@ -1369,19 +1539,16 @@ async def begin_delete_cassandra_table( # pylint: disable=inconsistent-return-s 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_cassandra_table_initial( # type: ignore resource_group_name=resource_group_name, @@ -1389,83 +1556,72 @@ async def begin_delete_cassandra_table( # pylint: disable=inconsistent-return-s keyspace_name=keyspace_name, table_name=table_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - account_name: str, - keyspace_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: """Gets the RUs per second of the Cassandra table under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ThroughputSettingsGetResults, or the result of cls(response) + :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_cassandra_table_throughput.metadata['url'], + template_url=self.get_cassandra_table_throughput.metadata["url"], headers=_headers, params=_params, ) @@ -1473,25 +1629,23 @@ async def get_cassandra_table_throughput( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + 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, @@ -1499,33 +1653,38 @@ async def _update_cassandra_table_throughput_initial( account_name: str, keyspace_name: str, table_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IO, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - request = build_update_cassandra_table_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_cassandra_table_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_cassandra_table_throughput_initial.metadata['url'], + content=_content, + template_url=self._update_cassandra_table_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1533,10 +1692,9 @@ async def _update_cassandra_table_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1545,17 +1703,16 @@ async def _update_cassandra_table_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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 + @overload async def begin_update_cassandra_table_throughput( self, resource_group_name: str, @@ -1563,22 +1720,28 @@ async def begin_update_cassandra_table_throughput( keyspace_name: str, table_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Update RUs per second of an Azure Cosmos DB Cassandra table. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :type table_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Cassandra table. + current Cassandra table. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :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 @@ -1591,20 +1754,104 @@ async def begin_update_cassandra_table_throughput( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_cassandra_table_throughput( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + update_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Cassandra table. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Cassandra table. Required. + :type update_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_update_cassandra_table_throughput( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Cassandra table. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Cassandra table. Is either a model type or a IO type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._update_cassandra_table_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -1614,68 +1861,56 @@ async def begin_update_cassandra_table_throughput( update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_cassandra_table_to_autoscale_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_cassandra_table_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_cassandra_table_to_autoscale_initial.metadata['url'], + template_url=self._migrate_cassandra_table_to_autoscale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1683,10 +1918,9 @@ async def _migrate_cassandra_table_to_autoscale_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1695,34 +1929,29 @@ async def _migrate_cassandra_table_to_autoscale_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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, - account_name: str, - keyspace_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB Cassandra table from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :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. @@ -1736,19 +1965,16 @@ async def begin_migrate_cassandra_table_to_autoscale( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._migrate_cassandra_table_to_autoscale_initial( # type: ignore resource_group_name=resource_group_name, @@ -1756,68 +1982,56 @@ async def begin_migrate_cassandra_table_to_autoscale( keyspace_name=keyspace_name, table_name=table_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_cassandra_table_to_manual_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_cassandra_table_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_cassandra_table_to_manual_throughput_initial.metadata['url'], + template_url=self._migrate_cassandra_table_to_manual_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1825,10 +2039,9 @@ async def _migrate_cassandra_table_to_manual_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1837,34 +2050,29 @@ async def _migrate_cassandra_table_to_manual_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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, - account_name: str, - keyspace_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB Cassandra table from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :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. @@ -1878,19 +2086,16 @@ async def begin_migrate_cassandra_table_to_manual_throughput( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._migrate_cassandra_table_to_manual_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -1898,83 +2103,75 @@ async def begin_migrate_cassandra_table_to_manual_throughput( keyspace_name=keyspace_name, table_name=table_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 @distributed_trace def list_cassandra_views( - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.CassandraViewListResult]: + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CassandraViewGetResults"]: """Lists the Cassandra materialized views under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :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 CassandraViewListResult or the result of + :return: An iterator like instance of either CassandraViewGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CassandraViewListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.CassandraViewListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CassandraViewListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_cassandra_views_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_cassandra_views.metadata['url'], + template_url=self.list_cassandra_views.metadata["url"], headers=_headers, params=_params, ) @@ -1982,17 +2179,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_cassandra_views_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - keyspace_name=keyspace_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -2008,10 +2199,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2021,56 +2210,47 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_cassandra_views.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views"} # type: ignore + list_cassandra_views.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views"} # type: ignore @distributed_trace_async async def get_cassandra_view( - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> _models.CassandraViewGetResults: """Gets the Cassandra view under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param view_name: Cosmos DB view name. + :param view_name: Cosmos DB view name. Required. :type view_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CassandraViewGetResults, or the result of cls(response) + :return: CassandraViewGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.CassandraViewGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.CassandraViewGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CassandraViewGetResults] - request = build_get_cassandra_view_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, view_name=view_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_cassandra_view.metadata['url'], + template_url=self.get_cassandra_view.metadata["url"], headers=_headers, params=_params, ) @@ -2078,25 +2258,23 @@ async def get_cassandra_view( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CassandraViewGetResults', pipeline_response) + deserialized = self._deserialize("CassandraViewGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_cassandra_view.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}"} # type: ignore - + get_cassandra_view.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}"} # type: ignore async def _create_update_cassandra_view_initial( self, @@ -2104,33 +2282,38 @@ async def _create_update_cassandra_view_initial( account_name: str, keyspace_name: str, view_name: str, - create_update_cassandra_view_parameters: _models.CassandraViewCreateUpdateParameters, + create_update_cassandra_view_parameters: Union[_models.CassandraViewCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.CassandraViewGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.CassandraViewGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.CassandraViewGetResults]] - _json = self._serialize.body(create_update_cassandra_view_parameters, 'CassandraViewCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_cassandra_view_parameters, (IO, bytes)): + _content = create_update_cassandra_view_parameters + else: + _json = self._serialize.body(create_update_cassandra_view_parameters, "CassandraViewCreateUpdateParameters") - request = build_create_update_cassandra_view_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_cassandra_view_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, view_name=view_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_cassandra_view_initial.metadata['url'], + content=_content, + template_url=self._create_update_cassandra_view_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2138,10 +2321,9 @@ async def _create_update_cassandra_view_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2150,17 +2332,16 @@ async def _create_update_cassandra_view_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('CassandraViewGetResults', pipeline_response) + deserialized = self._deserialize("CassandraViewGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_update_cassandra_view_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}"} # type: ignore - + _create_update_cassandra_view_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_update_cassandra_view( self, resource_group_name: str, @@ -2168,22 +2349,28 @@ async def begin_create_update_cassandra_view( keyspace_name: str, view_name: str, create_update_cassandra_view_parameters: _models.CassandraViewCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.CassandraViewGetResults]: """Create or update an Azure Cosmos DB Cassandra View. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param view_name: Cosmos DB view name. + :param view_name: Cosmos DB view name. Required. :type view_name: str :param create_update_cassandra_view_parameters: The parameters to provide for the current - Cassandra View. + Cassandra View. Required. :type create_update_cassandra_view_parameters: ~azure.mgmt.cosmosdb.models.CassandraViewCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :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 @@ -2195,20 +2382,102 @@ async def begin_create_update_cassandra_view( :return: An instance of AsyncLROPoller that returns either CassandraViewGetResults or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_update_cassandra_view( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + view_name: str, + create_update_cassandra_view_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CassandraViewGetResults]: + """Create or update an Azure Cosmos DB Cassandra View. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param view_name: Cosmos DB view name. Required. + :type view_name: str + :param create_update_cassandra_view_parameters: The parameters to provide for the current + Cassandra View. Required. + :type create_update_cassandra_view_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 CassandraViewGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_update_cassandra_view( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + view_name: str, + create_update_cassandra_view_parameters: Union[_models.CassandraViewCreateUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.CassandraViewGetResults]: + """Create or update an Azure Cosmos DB Cassandra View. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param view_name: Cosmos DB view name. Required. + :type view_name: str + :param create_update_cassandra_view_parameters: The parameters to provide for the current + Cassandra View. Is either a model type or a IO type. Required. + :type create_update_cassandra_view_parameters: + ~azure.mgmt.cosmosdb.models.CassandraViewCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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 CassandraViewGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CassandraViewGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CassandraViewGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_update_cassandra_view_initial( # type: ignore resource_group_name=resource_group_name, @@ -2218,68 +2487,56 @@ async def begin_create_update_cassandra_view( create_update_cassandra_view_parameters=create_update_cassandra_view_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('CassandraViewGetResults', pipeline_response) + deserialized = self._deserialize("CassandraViewGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_update_cassandra_view.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}"} # type: ignore + begin_create_update_cassandra_view.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}"} # type: ignore async def _delete_cassandra_view_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_cassandra_view_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_cassandra_view_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, view_name=view_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_cassandra_view_initial.metadata['url'], + template_url=self._delete_cassandra_view_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2287,10 +2544,9 @@ async def _delete_cassandra_view_initial( # pylint: disable=inconsistent-return request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -2300,27 +2556,22 @@ async def _delete_cassandra_view_initial( # pylint: disable=inconsistent-return if cls: return cls(pipeline_response, None, {}) - _delete_cassandra_view_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}"} # type: ignore - + _delete_cassandra_view_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}"} # type: ignore @distributed_trace_async - async def begin_delete_cassandra_view( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - **kwargs: Any + async def begin_delete_cassandra_view( + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Azure Cosmos DB Cassandra view. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param view_name: Cosmos DB view name. + :param view_name: Cosmos DB view name. Required. :type view_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. @@ -2332,19 +2583,16 @@ async def begin_delete_cassandra_view( # pylint: disable=inconsistent-return-st 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_cassandra_view_initial( # type: ignore resource_group_name=resource_group_name, @@ -2352,83 +2600,72 @@ async def begin_delete_cassandra_view( # pylint: disable=inconsistent-return-st keyspace_name=keyspace_name, view_name=view_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_cassandra_view.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}"} # type: ignore + begin_delete_cassandra_view.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}"} # type: ignore @distributed_trace_async async def get_cassandra_view_throughput( - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: """Gets the RUs per second of the Cassandra view under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param view_name: Cosmos DB view name. + :param view_name: Cosmos DB view name. Required. :type view_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ThroughputSettingsGetResults, or the result of cls(response) + :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] - request = build_get_cassandra_view_throughput_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, view_name=view_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_cassandra_view_throughput.metadata['url'], + template_url=self.get_cassandra_view_throughput.metadata["url"], headers=_headers, params=_params, ) @@ -2436,25 +2673,23 @@ async def get_cassandra_view_throughput( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_cassandra_view_throughput.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default"} # type: ignore - + get_cassandra_view_throughput.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default"} # type: ignore async def _update_cassandra_view_throughput_initial( self, @@ -2462,33 +2697,38 @@ async def _update_cassandra_view_throughput_initial( account_name: str, keyspace_name: str, view_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IO, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - request = build_update_cassandra_view_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_cassandra_view_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, view_name=view_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_cassandra_view_throughput_initial.metadata['url'], + content=_content, + template_url=self._update_cassandra_view_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2496,10 +2736,9 @@ async def _update_cassandra_view_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2508,17 +2747,16 @@ async def _update_cassandra_view_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_cassandra_view_throughput_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default"} # type: ignore + _update_cassandra_view_throughput_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default"} # type: ignore - - @distributed_trace_async + @overload async def begin_update_cassandra_view_throughput( self, resource_group_name: str, @@ -2526,22 +2764,115 @@ async def begin_update_cassandra_view_throughput( keyspace_name: str, view_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Update RUs per second of an Azure Cosmos DB Cassandra view. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param view_name: Cosmos DB view name. + :param view_name: Cosmos DB view name. Required. :type view_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Cassandra view. + current Cassandra view. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + async def begin_update_cassandra_view_throughput( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + view_name: str, + update_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Cassandra view. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param view_name: Cosmos DB view name. Required. + :type view_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Cassandra view. Required. + :type update_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_update_cassandra_view_throughput( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + view_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Cassandra view. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param view_name: Cosmos DB view name. Required. + :type view_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Cassandra view. Is either a model type or a IO type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -2554,20 +2885,17 @@ async def begin_update_cassandra_view_throughput( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._update_cassandra_view_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -2577,68 +2905,56 @@ async def begin_update_cassandra_view_throughput( update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_cassandra_view_throughput.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default"} # type: ignore + begin_update_cassandra_view_throughput.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default"} # type: ignore async def _migrate_cassandra_view_to_autoscale_initial( - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_cassandra_view_to_autoscale_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_cassandra_view_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, view_name=view_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_cassandra_view_to_autoscale_initial.metadata['url'], + template_url=self._migrate_cassandra_view_to_autoscale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2646,10 +2962,9 @@ async def _migrate_cassandra_view_to_autoscale_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2658,34 +2973,29 @@ async def _migrate_cassandra_view_to_autoscale_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _migrate_cassandra_view_to_autoscale_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToAutoscale"} # type: ignore - + _migrate_cassandra_view_to_autoscale_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToAutoscale"} # type: ignore @distributed_trace_async async def begin_migrate_cassandra_view_to_autoscale( - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB Cassandra view from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param view_name: Cosmos DB view name. + :param view_name: Cosmos DB view name. Required. :type view_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. @@ -2699,19 +3009,16 @@ async def begin_migrate_cassandra_view_to_autoscale( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._migrate_cassandra_view_to_autoscale_initial( # type: ignore resource_group_name=resource_group_name, @@ -2719,68 +3026,56 @@ async def begin_migrate_cassandra_view_to_autoscale( keyspace_name=keyspace_name, view_name=view_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_migrate_cassandra_view_to_autoscale.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToAutoscale"} # type: ignore + begin_migrate_cassandra_view_to_autoscale.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToAutoscale"} # type: ignore async def _migrate_cassandra_view_to_manual_throughput_initial( - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_cassandra_view_to_manual_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_cassandra_view_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, view_name=view_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_cassandra_view_to_manual_throughput_initial.metadata['url'], + template_url=self._migrate_cassandra_view_to_manual_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2788,10 +3083,9 @@ async def _migrate_cassandra_view_to_manual_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2800,34 +3094,29 @@ async def _migrate_cassandra_view_to_manual_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _migrate_cassandra_view_to_manual_throughput_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToManualThroughput"} # type: ignore - + _migrate_cassandra_view_to_manual_throughput_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToManualThroughput"} # type: ignore @distributed_trace_async async def begin_migrate_cassandra_view_to_manual_throughput( - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB Cassandra view from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param view_name: Cosmos DB view name. + :param view_name: Cosmos DB view name. Required. :type view_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. @@ -2841,19 +3130,16 @@ async def begin_migrate_cassandra_view_to_manual_throughput( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._migrate_cassandra_view_to_manual_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -2861,36 +3147,32 @@ async def begin_migrate_cassandra_view_to_manual_throughput( keyspace_name=keyspace_name, view_name=view_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_migrate_cassandra_view_to_manual_throughput.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToManualThroughput"} # type: ignore + begin_migrate_cassandra_view_to_manual_throughput.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/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 13d4b8c76bda..8d157738e7d3 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,10 +26,16 @@ 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') +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]] + class CollectionOperations: """ .. warning:: @@ -42,7 +55,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( self, @@ -52,49 +64,49 @@ def list_metrics( collection_rid: str, filter: str, **kwargs: Any - ) -> AsyncIterable[_models.MetricListResult]: + ) -> AsyncIterable["_models.Metric"]: """Retrieves the metrics determined by the given filter for the given database account and collection. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param collection_rid: Cosmos DB collection rid. + :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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 MetricListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MetricListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Metric or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.Metric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -102,19 +114,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -130,10 +134,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -143,11 +145,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + 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( @@ -158,48 +158,48 @@ def list_usages( collection_rid: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.UsagesResult]: + ) -> AsyncIterable["_models.Usage"]: """Retrieves the usages (most recent storage data) for the given collection. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param collection_rid: Cosmos DB collection rid. + :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str :param filter: An OData filter expression that describes a subset of usages to return. The supported parameter is name.value (name of the metric, can have an or of multiple names). Default value is None. :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 UsagesResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.UsagesResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsagesResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsagesResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_usages.metadata['url'], + api_version=api_version, + template_url=self.list_usages.metadata["url"], headers=_headers, params=_params, ) @@ -207,19 +207,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -235,10 +227,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -248,59 +238,50 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + 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, - account_name: str, - database_rid: str, - collection_rid: str, - **kwargs: Any - ) -> AsyncIterable[_models.MetricDefinitionsListResult]: + self, resource_group_name: str, account_name: str, database_rid: str, collection_rid: str, **kwargs: Any + ) -> AsyncIterable["_models.MetricDefinition"]: """Retrieves metric definitions for the given collection. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param collection_rid: Cosmos DB collection rid. + :param collection_rid: Cosmos DB collection rid. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MetricDefinition or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricDefinitionsListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_metric_definitions.metadata['url'], + template_url=self.list_metric_definitions.metadata["url"], headers=_headers, params=_params, ) @@ -308,18 +289,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -335,10 +309,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -348,8 +320,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_metric_definitions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/metricDefinitions"} # type: ignore + list_metric_definitions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/metricDefinitions"} # type: ignore 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 101d85039643..f3875bffedd1 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ 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') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class CollectionPartitionOperations: """ .. warning:: @@ -42,7 +51,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( self, @@ -52,51 +60,49 @@ def list_metrics( collection_rid: str, filter: str, **kwargs: Any - ) -> AsyncIterable[_models.PartitionMetricListResult]: + ) -> AsyncIterable["_models.PartitionMetric"]: """Retrieves the metrics determined by the given filter for the given collection, split by partition. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param collection_rid: Cosmos DB collection rid. + :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PartitionMetric or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PartitionMetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartitionMetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -104,19 +110,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -132,10 +130,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -145,11 +141,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + 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( @@ -160,50 +154,48 @@ def list_usages( collection_rid: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.PartitionUsagesResult]: + ) -> AsyncIterable["_models.PartitionUsage"]: """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param collection_rid: Cosmos DB collection rid. + :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str :param filter: An OData filter expression that describes a subset of usages to return. The supported parameter is name.value (name of the metric, can have an or of multiple names). Default value is None. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PartitionUsage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PartitionUsage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PartitionUsagesResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartitionUsagesResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_usages.metadata['url'], + api_version=api_version, + template_url=self.list_usages.metadata["url"], headers=_headers, params=_params, ) @@ -211,19 +203,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -239,10 +223,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -252,8 +234,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitions/usages"} # type: ignore + list_usages.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitions/usages"} # type: ignore 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 d0bb7529445f..dde631133852 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._collection_partition_region_operations import build_list_metrics_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class CollectionPartitionRegionOperations: """ .. warning:: @@ -42,7 +51,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( self, @@ -53,54 +61,52 @@ def list_metrics( collection_rid: str, filter: str, **kwargs: Any - ) -> AsyncIterable[_models.PartitionMetricListResult]: + ) -> AsyncIterable["_models.PartitionMetric"]: """Retrieves the metrics determined by the given filter for the given collection and region, split by partition. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param region: Cosmos DB region, with spaces between words and each word capitalized. + :param region: Cosmos DB region, with spaces between words and each word capitalized. Required. :type region: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param collection_rid: Cosmos DB collection rid. + :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PartitionMetric or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PartitionMetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartitionMetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -108,20 +114,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -137,10 +134,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -150,8 +145,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_metrics.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/partitions/metrics"} # type: ignore + list_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/partitions/metrics"} # type: ignore 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 86191fec094f..c3f848cfa3f2 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._collection_region_operations import build_list_metrics_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class CollectionRegionOperations: """ .. warning:: @@ -42,7 +51,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( self, @@ -53,52 +61,52 @@ def list_metrics( collection_rid: str, filter: str, **kwargs: Any - ) -> AsyncIterable[_models.MetricListResult]: + ) -> AsyncIterable["_models.Metric"]: """Retrieves the metrics determined by the given filter for the given database account, collection and region. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param region: Cosmos DB region, with spaces between words and each word capitalized. + :param region: Cosmos DB region, with spaces between words and each word capitalized. Required. :type region: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param collection_rid: Cosmos DB collection rid. + :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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 MetricListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MetricListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Metric or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.Metric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -106,20 +114,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -135,10 +134,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -148,8 +145,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_metrics.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/metrics"} # type: ignore + list_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/metrics"} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_data_transfer_jobs_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_data_transfer_jobs_operations.py index 64074a2e77b2..220f15d59d73 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_data_transfer_jobs_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_data_transfer_jobs_operations.py @@ -6,10 +6,17 @@ # 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 Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._data_transfer_jobs_operations import build_cancel_request, build_create_request, build_get_request, build_list_by_database_account_request, build_pause_request, build_resume_request -T = TypeVar('T') +from ...operations._data_transfer_jobs_operations import ( + build_cancel_request, + build_create_request, + build_get_request, + build_list_by_database_account_request, + build_pause_request, + build_resume_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DataTransferJobsOperations: """ .. warning:: @@ -43,54 +59,124 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, job_name: str, job_create_parameters: _models.CreateJobRequest, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataTransferJobGetResults: """Creates a Data Transfer Job. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param job_name: Name of the Data Transfer Job. + :param job_name: Name of the Data Transfer Job. Required. :type job_name: str - :param job_create_parameters: + :param job_create_parameters: Required. :type job_create_parameters: ~azure.mgmt.cosmosdb.models.CreateJobRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataTransferJobGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.DataTransferJobGetResults + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + job_name: str, + job_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataTransferJobGetResults: + """Creates a Data Transfer Job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param job_name: Name of the Data Transfer Job. Required. + :type job_name: str + :param job_create_parameters: Required. + :type job_create_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataTransferJobGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.DataTransferJobGetResults + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + job_name: str, + job_create_parameters: Union[_models.CreateJobRequest, IO], + **kwargs: Any + ) -> _models.DataTransferJobGetResults: + """Creates a Data Transfer Job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param job_name: Name of the Data Transfer Job. Required. + :type job_name: str + :param job_create_parameters: Is either a model type or a IO type. Required. + :type job_create_parameters: ~azure.mgmt.cosmosdb.models.CreateJobRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataTransferJobGetResults, or the result of cls(response) + :return: DataTransferJobGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DataTransferJobGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataTransferJobGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataTransferJobGetResults] - _json = self._serialize.body(job_create_parameters, 'CreateJobRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(job_create_parameters, (IO, bytes)): + _content = job_create_parameters + else: + _json = self._serialize.body(job_create_parameters, "CreateJobRequest") request = build_create_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -98,66 +184,58 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataTransferJobGetResults', pipeline_response) + deserialized = self._deserialize("DataTransferJobGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - job_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.DataTransferJobGetResults: """Get a Data Transfer Job. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param job_name: Name of the Data Transfer Job. + :param job_name: Name of the Data Transfer Job. Required. :type job_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataTransferJobGetResults, or the result of cls(response) + :return: DataTransferJobGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DataTransferJobGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataTransferJobGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataTransferJobGetResults] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -165,66 +243,58 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataTransferJobGetResults', pipeline_response) + deserialized = self._deserialize("DataTransferJobGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}"} # type: ignore @distributed_trace_async async def pause( - self, - resource_group_name: str, - account_name: str, - job_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.DataTransferJobGetResults: """Pause a Data Transfer Job. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param job_name: Name of the Data Transfer Job. + :param job_name: Name of the Data Transfer Job. Required. :type job_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataTransferJobGetResults, or the result of cls(response) + :return: DataTransferJobGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DataTransferJobGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataTransferJobGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataTransferJobGetResults] - request = build_pause_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.pause.metadata['url'], + template_url=self.pause.metadata["url"], headers=_headers, params=_params, ) @@ -232,66 +302,58 @@ async def pause( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataTransferJobGetResults', pipeline_response) + deserialized = self._deserialize("DataTransferJobGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - pause.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/pause"} # type: ignore - + pause.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/pause"} # type: ignore @distributed_trace_async async def resume( - self, - resource_group_name: str, - account_name: str, - job_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.DataTransferJobGetResults: """Resumes a Data Transfer Job. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param job_name: Name of the Data Transfer Job. + :param job_name: Name of the Data Transfer Job. Required. :type job_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataTransferJobGetResults, or the result of cls(response) + :return: DataTransferJobGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DataTransferJobGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataTransferJobGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataTransferJobGetResults] - request = build_resume_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.resume.metadata['url'], + template_url=self.resume.metadata["url"], headers=_headers, params=_params, ) @@ -299,66 +361,58 @@ async def resume( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataTransferJobGetResults', pipeline_response) + deserialized = self._deserialize("DataTransferJobGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - resume.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/resume"} # type: ignore - + resume.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/resume"} # type: ignore @distributed_trace_async async def cancel( - self, - resource_group_name: str, - account_name: str, - job_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.DataTransferJobGetResults: """Cancels a Data Transfer Job. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param job_name: Name of the Data Transfer Job. + :param job_name: Name of the Data Transfer Job. Required. :type job_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataTransferJobGetResults, or the result of cls(response) + :return: DataTransferJobGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DataTransferJobGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataTransferJobGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataTransferJobGetResults] - request = build_cancel_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], headers=_headers, params=_params, ) @@ -366,65 +420,60 @@ async def cancel( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataTransferJobGetResults', pipeline_response) + deserialized = self._deserialize("DataTransferJobGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/cancel"} # type: ignore - + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/cancel"} # type: ignore @distributed_trace def list_by_database_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.DataTransferJobFeedResults]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DataTransferJobGetResults"]: """Get a list of Data Transfer jobs. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 DataTransferJobFeedResults or the result of + :return: An iterator like instance of either DataTransferJobGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.DataTransferJobFeedResults] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.DataTransferJobGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataTransferJobFeedResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataTransferJobFeedResults] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_database_account_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_database_account.metadata['url'], + template_url=self.list_by_database_account.metadata["url"], headers=_headers, params=_params, ) @@ -432,16 +481,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_database_account_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -457,10 +501,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -470,8 +512,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_database_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs"} # type: ignore + list_by_database_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs"} # type: ignore 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 4e4c8733f10a..85f771923a33 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._database_account_region_operations import build_list_metrics_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DatabaseAccountRegionOperations: """ .. warning:: @@ -42,54 +51,48 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( - self, - resource_group_name: str, - account_name: str, - region: str, - filter: str, - **kwargs: Any - ) -> AsyncIterable[_models.MetricListResult]: + self, resource_group_name: str, account_name: str, region: str, filter: str, **kwargs: Any + ) -> AsyncIterable["_models.Metric"]: """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param region: Cosmos DB region, with spaces between words and each word capitalized. + :param region: Cosmos DB region, with spaces between words and each word capitalized. Required. :type region: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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 MetricListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MetricListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Metric or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.Metric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, region=region, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -97,18 +100,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - region=region, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -124,10 +120,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -137,8 +131,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_metrics.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/metrics"} # type: ignore + list_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/metrics"} # type: ignore 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 01c23dc1b3b7..e2a5a0c2a62c 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 @@ -6,10 +6,17 @@ # 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 Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,31 @@ 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') +from ...operations._database_accounts_operations import ( + build_check_name_exists_request, + build_create_or_update_request, + build_delete_request, + build_failover_priority_change_request, + 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, + build_online_region_request, + build_regenerate_key_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DatabaseAccountsOperations: # pylint: disable=too-many-public-methods """ .. warning:: @@ -45,43 +73,37 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.DatabaseAccountGetResults: """Retrieves the properties of an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DatabaseAccountGetResults, or the result of cls(response) + :return: DatabaseAccountGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountGetResults] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -89,55 +111,58 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatabaseAccountGetResults', pipeline_response) + deserialized = self._deserialize("DatabaseAccountGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore async def _update_initial( self, resource_group_name: str, account_name: str, - update_parameters: _models.DatabaseAccountUpdateParameters, + update_parameters: Union[_models.DatabaseAccountUpdateParameters, IO], **kwargs: Any ) -> _models.DatabaseAccountGetResults: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountGetResults] - _json = self._serialize.body(update_parameters, 'DatabaseAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_parameters, (IO, bytes)): + _content = update_parameters + else: + _json = self._serialize.body(update_parameters, "DatabaseAccountUpdateParameters") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -145,42 +170,119 @@ async def _update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatabaseAccountGetResults', pipeline_response) + deserialized = self._deserialize("DatabaseAccountGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, account_name: str, update_parameters: _models.DatabaseAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param update_parameters: The parameters to provide for the current database account. + :param update_parameters: The parameters to provide for the current database account. Required. :type update_parameters: ~azure.mgmt.cosmosdb.models.DatabaseAccountUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + account_name: str, + update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param update_parameters: The parameters to provide for the current database account. Required. + :type update_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + account_name: str, + update_parameters: Union[_models.DatabaseAccountUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param update_parameters: The parameters to provide for the current database account. Is either + a model type or a IO type. Required. + :type update_parameters: ~azure.mgmt.cosmosdb.models.DatabaseAccountUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -193,20 +295,17 @@ async def begin_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, @@ -214,69 +313,70 @@ async def begin_update( update_parameters=update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DatabaseAccountGetResults', pipeline_response) + deserialized = self._deserialize("DatabaseAccountGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, account_name: str, - create_update_parameters: _models.DatabaseAccountCreateUpdateParameters, + create_update_parameters: Union[_models.DatabaseAccountCreateUpdateParameters, IO], **kwargs: Any ) -> _models.DatabaseAccountGetResults: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountGetResults] - _json = self._serialize.body(create_update_parameters, 'DatabaseAccountCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_parameters, (IO, bytes)): + _content = create_update_parameters + else: + _json = self._serialize.body(create_update_parameters, "DatabaseAccountCreateUpdateParameters") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -284,44 +384,126 @@ async def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatabaseAccountGetResults', pipeline_response) + deserialized = self._deserialize("DatabaseAccountGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, account_name: str, create_update_parameters: _models.DatabaseAccountCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DatabaseAccountGetResults]: """Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when performing updates on an account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param create_update_parameters: The parameters to provide for the current database account. + Required. :type create_update_parameters: ~azure.mgmt.cosmosdb.models.DatabaseAccountCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + create_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DatabaseAccountGetResults]: + """Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when + performing updates on an account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param create_update_parameters: The parameters to provide for the current database account. + Required. + :type create_update_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + create_update_parameters: Union[_models.DatabaseAccountCreateUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DatabaseAccountGetResults]: + """Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when + performing updates on an account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param create_update_parameters: The parameters to provide for the current database account. Is + either a model type or a IO type. Required. + :type create_update_parameters: + ~azure.mgmt.cosmosdb.models.DatabaseAccountCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -334,20 +516,17 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -355,64 +534,54 @@ async def begin_create_or_update( create_update_parameters=create_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DatabaseAccountGetResults', pipeline_response) + deserialized = self._deserialize("DatabaseAccountGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -420,10 +589,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -433,21 +601,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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. @@ -459,85 +622,83 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore async def _failover_priority_change_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - failover_parameters: _models.FailoverPolicies, + failover_parameters: Union[_models.FailoverPolicies, IO], **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(failover_parameters, 'FailoverPolicies') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_parameters, (IO, bytes)): + _content = failover_parameters + else: + _json = self._serialize.body(failover_parameters, "FailoverPolicies") - request = build_failover_priority_change_request_initial( - subscription_id=self._config.subscription_id, + request = build_failover_priority_change_request( resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._failover_priority_change_initial.metadata['url'], + content=_content, + template_url=self._failover_priority_change_initial.metadata["url"], headers=_headers, params=_params, ) @@ -545,10 +706,9 @@ async def _failover_priority_change_initial( # pylint: disable=inconsistent-ret request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -558,15 +718,16 @@ async def _failover_priority_change_initial( # pylint: disable=inconsistent-ret if cls: return cls(pipeline_response, None, {}) - _failover_priority_change_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/failoverPriorityChange"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements + @overload + async def begin_failover_priority_change( self, resource_group_name: str, account_name: str, failover_parameters: _models.FailoverPolicies, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Changes the failover priority for the Azure Cosmos DB database account. A failover priority of @@ -575,11 +736,90 @@ async def begin_failover_priority_change( # pylint: disable=inconsistent-return database account exists. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param failover_parameters: The new failover policies for the database account. + :param failover_parameters: The new failover policies for the database account. Required. :type failover_parameters: ~azure.mgmt.cosmosdb.models.FailoverPolicies + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_failover_priority_change( + self, + resource_group_name: str, + account_name: str, + failover_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[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 + database account exists. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param failover_parameters: The new failover policies for the database account. Required. + :type failover_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_failover_priority_change( + self, + resource_group_name: str, + account_name: str, + failover_parameters: Union[_models.FailoverPolicies, IO], + **kwargs: Any + ) -> AsyncLROPoller[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 + database account exists. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param failover_parameters: The new failover policies for the database account. Is either a + model type or a IO type. Required. + :type failover_parameters: ~azure.mgmt.cosmosdb.models.FailoverPolicies or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -590,20 +830,17 @@ async def begin_failover_priority_change( # pylint: disable=inconsistent-return 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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._failover_priority_change_initial( # type: ignore resource_group_name=resource_group_name, @@ -611,69 +848,61 @@ async def begin_failover_priority_change( # pylint: disable=inconsistent-return failover_parameters=failover_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 - ) -> AsyncIterable[_models.DatabaseAccountsListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.DatabaseAccountGetResults"]: """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 + :return: An iterator like instance of either DatabaseAccountGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountsListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -681,14 +910,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -704,10 +930,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -717,47 +941,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/databaseAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/databaseAccounts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.DatabaseAccountsListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DatabaseAccountGetResults"]: """Lists all the Azure Cosmos DB database accounts available under the given resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :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 + :return: An iterator like instance of either DatabaseAccountGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountsListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -765,15 +985,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -789,10 +1005,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -802,48 +1016,41 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts"} # type: ignore + 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, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.DatabaseAccountListKeysResult: """Lists the access keys for the specified Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DatabaseAccountListKeysResult, or the result of cls(response) + :return: DatabaseAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DatabaseAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountListKeysResult] - request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -851,62 +1058,55 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatabaseAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("DatabaseAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listKeys"} # type: ignore - + 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, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.DatabaseAccountListConnectionStringsResult: """Lists the connection strings for the specified Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DatabaseAccountListConnectionStringsResult, or the result of cls(response) + :return: DatabaseAccountListConnectionStringsResult or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DatabaseAccountListConnectionStringsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountListConnectionStringsResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountListConnectionStringsResult] - request = build_list_connection_strings_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_connection_strings.metadata['url'], + template_url=self.list_connection_strings.metadata["url"], headers=_headers, params=_params, ) @@ -914,55 +1114,58 @@ async def list_connection_strings( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatabaseAccountListConnectionStringsResult', pipeline_response) + deserialized = self._deserialize("DatabaseAccountListConnectionStringsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_connection_strings.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listConnectionStrings"} # type: ignore - + list_connection_strings.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listConnectionStrings"} # type: ignore async def _offline_region_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - region_parameter_for_offline: _models.RegionForOnlineOffline, + region_parameter_for_offline: Union[_models.RegionForOnlineOffline, IO], **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(region_parameter_for_offline, 'RegionForOnlineOffline') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(region_parameter_for_offline, (IO, bytes)): + _content = region_parameter_for_offline + else: + _json = self._serialize.body(region_parameter_for_offline, "RegionForOnlineOffline") - request = build_offline_region_request_initial( - subscription_id=self._config.subscription_id, + request = build_offline_region_request( resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._offline_region_initial.metadata['url'], + content=_content, + template_url=self._offline_region_initial.metadata["url"], headers=_headers, params=_params, ) @@ -970,38 +1173,114 @@ async def _offline_region_initial( # pylint: disable=inconsistent-return-statem request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _offline_region_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/offlineRegion"} # type: ignore + _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( # pylint: disable=inconsistent-return-statements + @overload + async def begin_offline_region( self, resource_group_name: str, account_name: str, region_parameter_for_offline: _models.RegionForOnlineOffline, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param region_parameter_for_offline: Cosmos DB region to offline for the database account. + Required. :type region_parameter_for_offline: ~azure.mgmt.cosmosdb.models.RegionForOnlineOffline + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_offline_region( + self, + resource_group_name: str, + account_name: str, + region_parameter_for_offline: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param region_parameter_for_offline: Cosmos DB region to offline for the database account. + Required. + :type region_parameter_for_offline: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_offline_region( + self, + resource_group_name: str, + account_name: str, + region_parameter_for_offline: Union[_models.RegionForOnlineOffline, IO], + **kwargs: Any + ) -> AsyncLROPoller[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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param region_parameter_for_offline: Cosmos DB region to offline for the database account. Is + either a model type or a IO type. Required. + :type region_parameter_for_offline: ~azure.mgmt.cosmosdb.models.RegionForOnlineOffline or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -1012,20 +1291,17 @@ async def begin_offline_region( # pylint: disable=inconsistent-return-statement 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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._offline_region_initial( # type: ignore resource_group_name=resource_group_name, @@ -1033,67 +1309,68 @@ async def begin_offline_region( # pylint: disable=inconsistent-return-statement region_parameter_for_offline=region_parameter_for_offline, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_offline_region.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/offlineRegion"} # type: ignore async def _online_region_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - region_parameter_for_online: _models.RegionForOnlineOffline, + region_parameter_for_online: Union[_models.RegionForOnlineOffline, IO], **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(region_parameter_for_online, 'RegionForOnlineOffline') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(region_parameter_for_online, (IO, bytes)): + _content = region_parameter_for_online + else: + _json = self._serialize.body(region_parameter_for_online, "RegionForOnlineOffline") - request = build_online_region_request_initial( - subscription_id=self._config.subscription_id, + request = build_online_region_request( resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._online_region_initial.metadata['url'], + content=_content, + template_url=self._online_region_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1101,38 +1378,114 @@ async def _online_region_initial( # pylint: disable=inconsistent-return-stateme request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _online_region_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/onlineRegion"} # type: ignore + _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( # pylint: disable=inconsistent-return-statements + @overload + async def begin_online_region( self, resource_group_name: str, account_name: str, region_parameter_for_online: _models.RegionForOnlineOffline, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param region_parameter_for_online: Cosmos DB region to online for the database account. + Required. :type region_parameter_for_online: ~azure.mgmt.cosmosdb.models.RegionForOnlineOffline + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_online_region( + self, + resource_group_name: str, + account_name: str, + region_parameter_for_online: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param region_parameter_for_online: Cosmos DB region to online for the database account. + Required. + :type region_parameter_for_online: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_online_region( + self, + resource_group_name: str, + account_name: str, + region_parameter_for_online: Union[_models.RegionForOnlineOffline, IO], + **kwargs: Any + ) -> AsyncLROPoller[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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param region_parameter_for_online: Cosmos DB region to online for the database account. Is + either a model type or a IO type. Required. + :type region_parameter_for_online: ~azure.mgmt.cosmosdb.models.RegionForOnlineOffline or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -1143,20 +1496,17 @@ async def begin_online_region( # pylint: disable=inconsistent-return-statements 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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._online_region_initial( # type: ignore resource_group_name=resource_group_name, @@ -1164,74 +1514,65 @@ async def begin_online_region( # pylint: disable=inconsistent-return-statements region_parameter_for_online=region_parameter_for_online, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - account_name: str, - **kwargs: Any + self, 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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DatabaseAccountListReadOnlyKeysResult, or the result of cls(response) + :return: DatabaseAccountListReadOnlyKeysResult or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DatabaseAccountListReadOnlyKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountListReadOnlyKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountListReadOnlyKeysResult] - request = build_get_read_only_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_read_only_keys.metadata['url'], + template_url=self.get_read_only_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1239,62 +1580,55 @@ async def get_read_only_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatabaseAccountListReadOnlyKeysResult', pipeline_response) + deserialized = self._deserialize("DatabaseAccountListReadOnlyKeysResult", pipeline_response) if cls: 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 - + 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, - account_name: str, - **kwargs: Any + self, 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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DatabaseAccountListReadOnlyKeysResult, or the result of cls(response) + :return: DatabaseAccountListReadOnlyKeysResult or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DatabaseAccountListReadOnlyKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountListReadOnlyKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountListReadOnlyKeysResult] - request = build_list_read_only_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_read_only_keys.metadata['url'], + template_url=self.list_read_only_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1302,55 +1636,58 @@ async def list_read_only_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatabaseAccountListReadOnlyKeysResult', pipeline_response) + deserialized = self._deserialize("DatabaseAccountListReadOnlyKeysResult", pipeline_response) if cls: 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 - + list_read_only_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys"} # type: ignore async def _regenerate_key_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - key_to_regenerate: _models.DatabaseAccountRegenerateKeyParameters, + key_to_regenerate: Union[_models.DatabaseAccountRegenerateKeyParameters, IO], **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(key_to_regenerate, 'DatabaseAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(key_to_regenerate, (IO, bytes)): + _content = key_to_regenerate + else: + _json = self._serialize.body(key_to_regenerate, "DatabaseAccountRegenerateKeyParameters") - request = build_regenerate_key_request_initial( - subscription_id=self._config.subscription_id, + request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._regenerate_key_initial.metadata['url'], + content=_content, + template_url=self._regenerate_key_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1358,10 +1695,9 @@ async def _regenerate_key_initial( # pylint: disable=inconsistent-return-statem request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1371,25 +1707,100 @@ async def _regenerate_key_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _regenerate_key_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/regenerateKey"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements + @overload + async def begin_regenerate_key( self, resource_group_name: str, account_name: str, key_to_regenerate: _models.DatabaseAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param key_to_regenerate: The name of the key to regenerate. + :param key_to_regenerate: The name of the key to regenerate. Required. :type key_to_regenerate: ~azure.mgmt.cosmosdb.models.DatabaseAccountRegenerateKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_regenerate_key( + self, + resource_group_name: str, + account_name: str, + key_to_regenerate: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param key_to_regenerate: The name of the key to regenerate. Required. + :type key_to_regenerate: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_regenerate_key( + self, + resource_group_name: str, + account_name: str, + key_to_regenerate: Union[_models.DatabaseAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param key_to_regenerate: The name of the key to regenerate. Is either a model type or a IO + type. Required. + :type key_to_regenerate: ~azure.mgmt.cosmosdb.models.DatabaseAccountRegenerateKeyParameters or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -1400,20 +1811,17 @@ async def begin_regenerate_key( # pylint: disable=inconsistent-return-statement 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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._regenerate_key_initial( # type: ignore resource_group_name=resource_group_name, @@ -1421,71 +1829,60 @@ async def begin_regenerate_key( # pylint: disable=inconsistent-return-statement key_to_regenerate=key_to_regenerate, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - **kwargs: Any - ) -> bool: + async def check_name_exists(self, account_name: str, **kwargs: Any) -> bool: """Checks that the Azure Cosmos DB account name already exists. A valid account name may contain only lowercase letters, numbers, and the '-' character, and must be between 3 and 50 characters. - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_check_name_exists_request( account_name=account_name, api_version=api_version, - template_url=self.check_name_exists.metadata['url'], + template_url=self.check_name_exists.metadata["url"], headers=_headers, params=_params, ) @@ -1493,10 +1890,9 @@ async def check_name_exists( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 404]: @@ -1507,52 +1903,47 @@ async def check_name_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_name_exists.metadata = {'url': "/providers/Microsoft.DocumentDB/databaseAccountNames/{accountName}"} # type: ignore - + check_name_exists.metadata = {"url": "/providers/Microsoft.DocumentDB/databaseAccountNames/{accountName}"} # type: ignore @distributed_trace def list_metrics( - self, - resource_group_name: str, - account_name: str, - filter: str, - **kwargs: Any - ) -> AsyncIterable[_models.MetricListResult]: + self, resource_group_name: str, account_name: str, filter: str, **kwargs: Any + ) -> AsyncIterable["_models.Metric"]: """Retrieves the metrics determined by the given filter for the given database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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 MetricListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MetricListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Metric or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.Metric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -1560,17 +1951,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1586,10 +1971,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1599,55 +1982,49 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_metrics.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metrics"} # type: ignore + 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, - account_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable[_models.UsagesResult]: + self, resource_group_name: str, account_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Usage"]: """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param filter: An OData filter expression that describes a subset of usages to return. The supported parameter is name.value (name of the metric, can have an or of multiple names). Default value is None. :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 UsagesResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.UsagesResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsagesResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsagesResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_usages_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_usages.metadata['url'], + api_version=api_version, + template_url=self.list_usages.metadata["url"], headers=_headers, params=_params, ) @@ -1655,17 +2032,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_usages_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1681,10 +2052,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1694,51 +2063,44 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/usages"} # type: ignore + 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, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.MetricDefinitionsListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MetricDefinition"]: """Retrieves metric definitions for the given database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MetricDefinition or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricDefinitionsListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_metric_definitions_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_metric_definitions.metadata['url'], + template_url=self.list_metric_definitions.metadata["url"], headers=_headers, params=_params, ) @@ -1746,16 +2108,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_metric_definitions_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1771,10 +2128,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1784,8 +2139,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_metric_definitions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metricDefinitions"} # type: ignore + list_metric_definitions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metricDefinitions"} # type: ignore 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 59b450090dac..d880c0ac9129 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,10 +26,16 @@ 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') +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]] + class DatabaseOperations: """ .. warning:: @@ -42,55 +55,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( - self, - resource_group_name: str, - account_name: str, - database_rid: str, - filter: str, - **kwargs: Any - ) -> AsyncIterable[_models.MetricListResult]: + self, resource_group_name: str, account_name: str, database_rid: str, filter: str, **kwargs: Any + ) -> AsyncIterable["_models.Metric"]: """Retrieves the metrics determined by the given filter for the given database account and database. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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 MetricListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MetricListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Metric or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.Metric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -98,18 +105,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -125,10 +125,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -138,11 +136,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_metrics.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metrics"} # type: ignore + list_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metrics"} # type: ignore @distributed_trace def list_usages( @@ -152,45 +148,45 @@ def list_usages( database_rid: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.UsagesResult]: + ) -> AsyncIterable["_models.Usage"]: """Retrieves the usages (most recent data) for the given database. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str :param filter: An OData filter expression that describes a subset of usages to return. The supported parameter is name.value (name of the metric, can have an or of multiple names). Default value is None. :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 UsagesResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.UsagesResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsagesResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsagesResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_usages.metadata['url'], + api_version=api_version, + template_url=self.list_usages.metadata["url"], headers=_headers, params=_params, ) @@ -198,18 +194,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -225,10 +214,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -238,55 +225,47 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/usages"} # type: ignore + 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, - account_name: str, - database_rid: str, - **kwargs: Any - ) -> AsyncIterable[_models.MetricDefinitionsListResult]: + self, resource_group_name: str, account_name: str, database_rid: str, **kwargs: Any + ) -> AsyncIterable["_models.MetricDefinition"]: """Retrieves metric definitions for the given database. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MetricDefinition or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricDefinitionsListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_metric_definitions.metadata['url'], + template_url=self.list_metric_definitions.metadata["url"], headers=_headers, params=_params, ) @@ -294,17 +273,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -320,10 +293,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -333,8 +304,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_metric_definitions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metricDefinitions"} # type: ignore + list_metric_definitions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metricDefinitions"} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_graph_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_graph_resources_operations.py index 429d23f4d540..2c8ce7396b7f 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_graph_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_graph_resources_operations.py @@ -6,10 +6,17 @@ # 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 Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,17 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._graph_resources_operations import build_create_update_graph_request_initial, build_delete_graph_resource_request_initial, build_get_graph_request, build_list_graphs_request -T = TypeVar('T') +from ...operations._graph_resources_operations import ( + build_create_update_graph_request, + build_delete_graph_resource_request, + build_get_graph_request, + build_list_graphs_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class GraphResourcesOperations: """ .. warning:: @@ -45,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_graphs( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.GraphResourcesListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GraphResourceGetResults"]: """Lists the graphs under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 GraphResourcesListResult or the result of + :return: An iterator like instance of either GraphResourceGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.GraphResourcesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.GraphResourceGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GraphResourcesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GraphResourcesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_graphs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_graphs.metadata['url'], + template_url=self.list_graphs.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +102,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_graphs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +122,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -130,53 +133,45 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_graphs.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs"} # type: ignore + list_graphs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs"} # type: ignore @distributed_trace_async async def get_graph( - self, - resource_group_name: str, - account_name: str, - graph_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, graph_name: str, **kwargs: Any ) -> _models.GraphResourceGetResults: """Gets the Graph resource under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param graph_name: Cosmos DB graph resource name. + :param graph_name: Cosmos DB graph resource name. Required. :type graph_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GraphResourceGetResults, or the result of cls(response) + :return: GraphResourceGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.GraphResourceGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GraphResourceGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GraphResourceGetResults] - request = build_get_graph_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, graph_name=graph_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_graph.metadata['url'], + template_url=self.get_graph.metadata["url"], headers=_headers, params=_params, ) @@ -184,57 +179,60 @@ async def get_graph( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GraphResourceGetResults', pipeline_response) + deserialized = self._deserialize("GraphResourceGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_graph.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}"} # type: ignore - + get_graph.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}"} # type: ignore async def _create_update_graph_initial( self, resource_group_name: str, account_name: str, graph_name: str, - create_update_graph_parameters: _models.GraphResourceCreateUpdateParameters, + create_update_graph_parameters: Union[_models.GraphResourceCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.GraphResourceGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.GraphResourceGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GraphResourceGetResults]] - _json = self._serialize.body(create_update_graph_parameters, 'GraphResourceCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_graph_parameters, (IO, bytes)): + _content = create_update_graph_parameters + else: + _json = self._serialize.body(create_update_graph_parameters, "GraphResourceCreateUpdateParameters") - request = build_create_update_graph_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_graph_request( resource_group_name=resource_group_name, account_name=account_name, graph_name=graph_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_graph_initial.metadata['url'], + content=_content, + template_url=self._create_update_graph_initial.metadata["url"], headers=_headers, params=_params, ) @@ -242,10 +240,9 @@ async def _create_update_graph_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -254,36 +251,42 @@ async def _create_update_graph_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GraphResourceGetResults', pipeline_response) + deserialized = self._deserialize("GraphResourceGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_update_graph_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}"} # type: ignore - + _create_update_graph_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_update_graph( self, resource_group_name: str, account_name: str, graph_name: str, create_update_graph_parameters: _models.GraphResourceCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.GraphResourceGetResults]: """Create or update an Azure Cosmos DB Graph. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param graph_name: Cosmos DB graph resource name. + :param graph_name: Cosmos DB graph resource name. Required. :type graph_name: str :param create_update_graph_parameters: The parameters to provide for the current graph. + Required. :type create_update_graph_parameters: ~azure.mgmt.cosmosdb.models.GraphResourceCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 @@ -295,20 +298,96 @@ async def begin_create_update_graph( :return: An instance of AsyncLROPoller that returns either GraphResourceGetResults or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GraphResourceGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_update_graph( + self, + resource_group_name: str, + account_name: str, + graph_name: str, + create_update_graph_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GraphResourceGetResults]: + """Create or update an Azure Cosmos DB Graph. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param graph_name: Cosmos DB graph resource name. Required. + :type graph_name: str + :param create_update_graph_parameters: The parameters to provide for the current graph. + Required. + :type create_update_graph_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 GraphResourceGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GraphResourceGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_update_graph( + self, + resource_group_name: str, + account_name: str, + graph_name: str, + create_update_graph_parameters: Union[_models.GraphResourceCreateUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.GraphResourceGetResults]: + """Create or update an Azure Cosmos DB Graph. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param graph_name: Cosmos DB graph resource name. Required. + :type graph_name: str + :param create_update_graph_parameters: The parameters to provide for the current graph. Is + either a model type or a IO type. Required. + :type create_update_graph_parameters: + ~azure.mgmt.cosmosdb.models.GraphResourceCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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 GraphResourceGetResults or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GraphResourceGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.GraphResourceGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GraphResourceGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_update_graph_initial( # type: ignore resource_group_name=resource_group_name, @@ -317,66 +396,55 @@ async def begin_create_update_graph( create_update_graph_parameters=create_update_graph_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('GraphResourceGetResults', pipeline_response) + deserialized = self._deserialize("GraphResourceGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_update_graph.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}"} # type: ignore + begin_create_update_graph.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}"} # type: ignore async def _delete_graph_resource_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - graph_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, graph_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_graph_resource_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_graph_resource_request( resource_group_name=resource_group_name, account_name=account_name, graph_name=graph_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_graph_resource_initial.metadata['url'], + template_url=self._delete_graph_resource_initial.metadata["url"], headers=_headers, params=_params, ) @@ -384,10 +452,9 @@ async def _delete_graph_resource_initial( # pylint: disable=inconsistent-return request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -397,24 +464,20 @@ async def _delete_graph_resource_initial( # pylint: disable=inconsistent-return if cls: return cls(pipeline_response, None, {}) - _delete_graph_resource_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}"} # type: ignore - + _delete_graph_resource_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}"} # type: ignore @distributed_trace_async - async def begin_delete_graph_resource( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - graph_name: str, - **kwargs: Any + async def begin_delete_graph_resource( + self, resource_group_name: str, account_name: str, graph_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Azure Cosmos DB Graph Resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param graph_name: Cosmos DB graph resource name. + :param graph_name: Cosmos DB graph resource name. Required. :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. @@ -426,53 +489,46 @@ async def begin_delete_graph_resource( # pylint: disable=inconsistent-return-st 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_graph_resource_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, graph_name=graph_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_graph_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}"} # type: ignore + begin_delete_graph_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}"} # type: ignore 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 f372b192a2ec..a3e4826e6a6c 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 @@ -6,10 +6,17 @@ # 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 Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,30 @@ 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_retrieve_continuous_backup_information_request_initial, build_update_gremlin_database_throughput_request_initial, build_update_gremlin_graph_throughput_request_initial -T = TypeVar('T') +from ...operations._gremlin_resources_operations import ( + build_create_update_gremlin_database_request, + build_create_update_gremlin_graph_request, + build_delete_gremlin_database_request, + build_delete_gremlin_graph_request, + 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, + build_migrate_gremlin_database_to_manual_throughput_request, + build_migrate_gremlin_graph_to_autoscale_request, + build_migrate_gremlin_graph_to_manual_throughput_request, + build_retrieve_continuous_backup_information_request, + build_update_gremlin_database_throughput_request, + build_update_gremlin_graph_throughput_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class GremlinResourcesOperations: # pylint: disable=too-many-public-methods """ .. warning:: @@ -45,46 +72,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_gremlin_databases( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.GremlinDatabaseListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GremlinDatabaseGetResults"]: """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 + :return: An iterator like instance of either GremlinDatabaseGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.GremlinDatabaseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.GremlinDatabaseGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GremlinDatabaseListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GremlinDatabaseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_gremlin_databases_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_gremlin_databases.metadata['url'], + template_url=self.list_gremlin_databases.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +115,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_gremlin_databases_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +135,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -130,53 +146,45 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_gremlin_databases.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases"} # type: ignore + 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, - account_name: str, - database_name: str, - **kwargs: Any + self, 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. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GremlinDatabaseGetResults, or the result of cls(response) + :return: GremlinDatabaseGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.GremlinDatabaseGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GremlinDatabaseGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GremlinDatabaseGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_gremlin_database.metadata['url'], + template_url=self.get_gremlin_database.metadata["url"], headers=_headers, params=_params, ) @@ -184,57 +192,62 @@ async def get_gremlin_database( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GremlinDatabaseGetResults', pipeline_response) + deserialized = self._deserialize("GremlinDatabaseGetResults", pipeline_response) if cls: 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 - + 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, account_name: str, database_name: str, - create_update_gremlin_database_parameters: _models.GremlinDatabaseCreateUpdateParameters, + create_update_gremlin_database_parameters: Union[_models.GremlinDatabaseCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.GremlinDatabaseGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.GremlinDatabaseGetResults]] - - _json = self._serialize.body(create_update_gremlin_database_parameters, 'GremlinDatabaseCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GremlinDatabaseGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_gremlin_database_parameters, (IO, bytes)): + _content = create_update_gremlin_database_parameters + else: + _json = self._serialize.body( + create_update_gremlin_database_parameters, "GremlinDatabaseCreateUpdateParameters" + ) - request = build_create_update_gremlin_database_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_gremlin_database_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_gremlin_database_initial.metadata['url'], + content=_content, + template_url=self._create_update_gremlin_database_initial.metadata["url"], headers=_headers, params=_params, ) @@ -242,10 +255,9 @@ async def _create_update_gremlin_database_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -254,37 +266,123 @@ async def _create_update_gremlin_database_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GremlinDatabaseGetResults', pipeline_response) + deserialized = self._deserialize("GremlinDatabaseGetResults", pipeline_response) if cls: 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 - + _create_update_gremlin_database_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_update_gremlin_database( self, resource_group_name: str, account_name: str, database_name: str, create_update_gremlin_database_parameters: _models.GremlinDatabaseCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :param create_update_gremlin_database_parameters: The parameters to provide for the current - Gremlin database. + Gremlin database. Required. :type create_update_gremlin_database_parameters: ~azure.mgmt.cosmosdb.models.GremlinDatabaseCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + async def begin_create_update_gremlin_database( + self, + resource_group_name: str, + account_name: str, + database_name: str, + create_update_gremlin_database_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param create_update_gremlin_database_parameters: The parameters to provide for the current + Gremlin database. Required. + :type create_update_gremlin_database_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_create_update_gremlin_database( + self, + resource_group_name: str, + account_name: str, + database_name: str, + create_update_gremlin_database_parameters: Union[_models.GremlinDatabaseCreateUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param create_update_gremlin_database_parameters: The parameters to provide for the current + Gremlin database. Is either a model type or a IO type. Required. + :type create_update_gremlin_database_parameters: + ~azure.mgmt.cosmosdb.models.GremlinDatabaseCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -297,20 +395,17 @@ async def begin_create_update_gremlin_database( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinDatabaseGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.GremlinDatabaseGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GremlinDatabaseGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_update_gremlin_database_initial( # type: ignore resource_group_name=resource_group_name, @@ -319,66 +414,55 @@ async def begin_create_update_gremlin_database( create_update_gremlin_database_parameters=create_update_gremlin_database_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('GremlinDatabaseGetResults', pipeline_response) + deserialized = self._deserialize("GremlinDatabaseGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_gremlin_database_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_gremlin_database_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_gremlin_database_initial.metadata['url'], + template_url=self._delete_gremlin_database_initial.metadata["url"], headers=_headers, params=_params, ) @@ -386,10 +470,9 @@ async def _delete_gremlin_database_initial( # pylint: disable=inconsistent-retu request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -399,24 +482,20 @@ async def _delete_gremlin_database_initial( # pylint: disable=inconsistent-retu if cls: return cls(pipeline_response, None, {}) - _delete_gremlin_database_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + async def begin_delete_gremlin_database( + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Azure Cosmos DB Gremlin database. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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. @@ -428,98 +507,85 @@ async def begin_delete_gremlin_database( # pylint: disable=inconsistent-return- 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_gremlin_database_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: """Gets the RUs per second of the Gremlin database under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ThroughputSettingsGetResults, or the result of cls(response) + :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_gremlin_database_throughput.metadata['url'], + template_url=self.get_gremlin_database_throughput.metadata["url"], headers=_headers, params=_params, ) @@ -527,57 +593,60 @@ async def get_gremlin_database_throughput( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + 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, account_name: str, database_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IO, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - request = build_update_gremlin_database_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_gremlin_database_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_gremlin_database_throughput_initial.metadata['url'], + content=_content, + template_url=self._update_gremlin_database_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -585,10 +654,9 @@ async def _update_gremlin_database_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -597,37 +665,123 @@ async def _update_gremlin_database_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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 + @overload async def begin_update_gremlin_database_throughput( self, resource_group_name: str, account_name: str, database_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Update RUs per second of an Azure Cosmos DB Gremlin database. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Gremlin database. + current Gremlin database. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + async def begin_update_gremlin_database_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + update_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Gremlin database. Required. + :type update_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_update_gremlin_database_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Gremlin database. Is either a model type or a IO type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -640,20 +794,17 @@ async def begin_update_gremlin_database_throughput( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._update_gremlin_database_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -662,66 +813,55 @@ async def begin_update_gremlin_database_throughput( update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_gremlin_database_to_autoscale_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_gremlin_database_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_gremlin_database_to_autoscale_initial.metadata['url'], + template_url=self._migrate_gremlin_database_to_autoscale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -729,10 +869,9 @@ async def _migrate_gremlin_database_to_autoscale_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -741,31 +880,27 @@ async def _migrate_gremlin_database_to_autoscale_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB Gremlin database from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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. @@ -779,85 +914,71 @@ async def begin_migrate_gremlin_database_to_autoscale( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._migrate_gremlin_database_to_autoscale_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_gremlin_database_to_manual_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_gremlin_database_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_gremlin_database_to_manual_throughput_initial.metadata['url'], + template_url=self._migrate_gremlin_database_to_manual_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -865,10 +986,9 @@ async def _migrate_gremlin_database_to_manual_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -877,31 +997,27 @@ async def _migrate_gremlin_database_to_manual_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB Gremlin database from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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. @@ -915,102 +1031,91 @@ async def begin_migrate_gremlin_database_to_manual_throughput( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._migrate_gremlin_database_to_manual_throughput_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - account_name: str, - database_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.GremlinGraphListResult]: + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GremlinGraphGetResults"]: """Lists the Gremlin graph under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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 + :return: An iterator like instance of either GremlinGraphGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.GremlinGraphListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GremlinGraphListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GremlinGraphListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_gremlin_graphs.metadata['url'], + template_url=self.list_gremlin_graphs.metadata["url"], headers=_headers, params=_params, ) @@ -1018,17 +1123,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1044,10 +1143,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1057,56 +1154,47 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + 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, - account_name: str, - database_name: str, - graph_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any ) -> _models.GremlinGraphGetResults: """Gets the Gremlin graph under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. + :param graph_name: Cosmos DB graph name. Required. :type graph_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GremlinGraphGetResults, or the result of cls(response) + :return: GremlinGraphGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.GremlinGraphGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GremlinGraphGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GremlinGraphGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_gremlin_graph.metadata['url'], + template_url=self.get_gremlin_graph.metadata["url"], headers=_headers, params=_params, ) @@ -1114,25 +1202,23 @@ async def get_gremlin_graph( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GremlinGraphGetResults', pipeline_response) + deserialized = self._deserialize("GremlinGraphGetResults", pipeline_response) if cls: 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 - + 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, @@ -1140,33 +1226,38 @@ async def _create_update_gremlin_graph_initial( account_name: str, database_name: str, graph_name: str, - create_update_gremlin_graph_parameters: _models.GremlinGraphCreateUpdateParameters, + create_update_gremlin_graph_parameters: Union[_models.GremlinGraphCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.GremlinGraphGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.GremlinGraphGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GremlinGraphGetResults]] - _json = self._serialize.body(create_update_gremlin_graph_parameters, 'GremlinGraphCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_gremlin_graph_parameters, (IO, bytes)): + _content = create_update_gremlin_graph_parameters + else: + _json = self._serialize.body(create_update_gremlin_graph_parameters, "GremlinGraphCreateUpdateParameters") - request = build_create_update_gremlin_graph_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_gremlin_graph_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, graph_name=graph_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_gremlin_graph_initial.metadata['url'], + content=_content, + template_url=self._create_update_gremlin_graph_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1174,10 +1265,9 @@ async def _create_update_gremlin_graph_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1186,17 +1276,16 @@ async def _create_update_gremlin_graph_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GremlinGraphGetResults', pipeline_response) + deserialized = self._deserialize("GremlinGraphGetResults", pipeline_response) if cls: 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 - + _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 + @overload async def begin_create_update_gremlin_graph( self, resource_group_name: str, @@ -1204,22 +1293,71 @@ async def begin_create_update_gremlin_graph( database_name: str, graph_name: str, create_update_gremlin_graph_parameters: _models.GremlinGraphCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.GremlinGraphGetResults]: """Create or update an Azure Cosmos DB Gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. + :param graph_name: Cosmos DB graph name. Required. :type graph_name: str :param create_update_gremlin_graph_parameters: The parameters to provide for the current - Gremlin graph. + Gremlin graph. Required. :type create_update_gremlin_graph_parameters: ~azure.mgmt.cosmosdb.models.GremlinGraphCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_update_gremlin_graph( + self, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + create_update_gremlin_graph_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GremlinGraphGetResults]: + """Create or update an Azure Cosmos DB Gremlin graph. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param create_update_gremlin_graph_parameters: The parameters to provide for the current + Gremlin graph. Required. + :type create_update_gremlin_graph_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -1231,20 +1369,59 @@ async def begin_create_update_gremlin_graph( :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: + """ + + @distributed_trace_async + async def begin_create_update_gremlin_graph( + self, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + create_update_gremlin_graph_parameters: Union[_models.GremlinGraphCreateUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.GremlinGraphGetResults]: + """Create or update an Azure Cosmos DB Gremlin graph. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param create_update_gremlin_graph_parameters: The parameters to provide for the current + Gremlin graph. Is either a model type or a IO type. Required. + :type create_update_gremlin_graph_parameters: + ~azure.mgmt.cosmosdb.models.GremlinGraphCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.GremlinGraphGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GremlinGraphGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_update_gremlin_graph_initial( # type: ignore resource_group_name=resource_group_name, @@ -1254,68 +1431,56 @@ async def begin_create_update_gremlin_graph( create_update_gremlin_graph_parameters=create_update_gremlin_graph_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('GremlinGraphGetResults', pipeline_response) + deserialized = self._deserialize("GremlinGraphGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - graph_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_gremlin_graph_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_gremlin_graph_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, graph_name=graph_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_gremlin_graph_initial.metadata['url'], + template_url=self._delete_gremlin_graph_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1323,10 +1488,9 @@ async def _delete_gremlin_graph_initial( # pylint: disable=inconsistent-return- request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1336,27 +1500,22 @@ async def _delete_gremlin_graph_initial( # pylint: disable=inconsistent-return- if cls: return cls(pipeline_response, None, {}) - _delete_gremlin_graph_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - graph_name: str, - **kwargs: Any + async def begin_delete_gremlin_graph( + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Azure Cosmos DB Gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. + :param graph_name: Cosmos DB graph name. Required. :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. @@ -1368,19 +1527,16 @@ async def begin_delete_gremlin_graph( # pylint: disable=inconsistent-return-sta 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_gremlin_graph_initial( # type: ignore resource_group_name=resource_group_name, @@ -1388,83 +1544,72 @@ async def begin_delete_gremlin_graph( # pylint: disable=inconsistent-return-sta database_name=database_name, graph_name=graph_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - account_name: str, - database_name: str, - graph_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: """Gets the Gremlin graph throughput under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. + :param graph_name: Cosmos DB graph name. Required. :type graph_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ThroughputSettingsGetResults, or the result of cls(response) + :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_gremlin_graph_throughput.metadata['url'], + template_url=self.get_gremlin_graph_throughput.metadata["url"], headers=_headers, params=_params, ) @@ -1472,25 +1617,23 @@ async def get_gremlin_graph_throughput( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + 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, @@ -1498,33 +1641,38 @@ async def _update_gremlin_graph_throughput_initial( account_name: str, database_name: str, graph_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IO, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - request = build_update_gremlin_graph_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_gremlin_graph_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, graph_name=graph_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_gremlin_graph_throughput_initial.metadata['url'], + content=_content, + template_url=self._update_gremlin_graph_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1532,10 +1680,9 @@ async def _update_gremlin_graph_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1544,17 +1691,16 @@ async def _update_gremlin_graph_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 + _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 + @overload async def begin_update_gremlin_graph_throughput( self, resource_group_name: str, @@ -1562,22 +1708,115 @@ async def begin_update_gremlin_graph_throughput( database_name: str, graph_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Update RUs per second of an Azure Cosmos DB Gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. + :param graph_name: Cosmos DB graph name. Required. :type graph_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Gremlin graph. + current Gremlin graph. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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: + """ + + @overload + async def begin_update_gremlin_graph_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + update_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Gremlin graph. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Gremlin graph. Required. + :type update_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_update_gremlin_graph_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Gremlin graph. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Gremlin graph. Is either a model type or a IO type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -1590,20 +1829,17 @@ async def begin_update_gremlin_graph_throughput( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._update_gremlin_graph_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -1613,68 +1849,56 @@ async def begin_update_gremlin_graph_throughput( update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( - self, - resource_group_name: str, - account_name: str, - database_name: str, - graph_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_gremlin_graph_to_autoscale_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_gremlin_graph_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, graph_name=graph_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_gremlin_graph_to_autoscale_initial.metadata['url'], + template_url=self._migrate_gremlin_graph_to_autoscale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1682,10 +1906,9 @@ async def _migrate_gremlin_graph_to_autoscale_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1694,34 +1917,29 @@ async def _migrate_gremlin_graph_to_autoscale_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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, - account_name: str, - database_name: str, - graph_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB Gremlin graph from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. + :param graph_name: Cosmos DB graph name. Required. :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. @@ -1735,19 +1953,16 @@ async def begin_migrate_gremlin_graph_to_autoscale( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._migrate_gremlin_graph_to_autoscale_initial( # type: ignore resource_group_name=resource_group_name, @@ -1755,68 +1970,56 @@ async def begin_migrate_gremlin_graph_to_autoscale( database_name=database_name, graph_name=graph_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( - self, - resource_group_name: str, - account_name: str, - database_name: str, - graph_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_gremlin_graph_to_manual_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_gremlin_graph_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, graph_name=graph_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_gremlin_graph_to_manual_throughput_initial.metadata['url'], + template_url=self._migrate_gremlin_graph_to_manual_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1824,10 +2027,9 @@ async def _migrate_gremlin_graph_to_manual_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1836,34 +2038,29 @@ async def _migrate_gremlin_graph_to_manual_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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, - account_name: str, - database_name: str, - graph_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB Gremlin graph from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. + :param graph_name: Cosmos DB graph name. Required. :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. @@ -1877,19 +2074,16 @@ async def begin_migrate_gremlin_graph_to_manual_throughput( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._migrate_gremlin_graph_to_manual_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -1897,39 +2091,35 @@ async def begin_migrate_gremlin_graph_to_manual_throughput( database_name=database_name, graph_name=graph_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 async def _retrieve_continuous_backup_information_initial( self, @@ -1937,33 +2127,38 @@ async def _retrieve_continuous_backup_information_initial( account_name: str, database_name: str, graph_name: str, - location: _models.ContinuousBackupRestoreLocation, + location: Union[_models.ContinuousBackupRestoreLocation, IO], **kwargs: Any ) -> Optional[_models.BackupInformation]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.BackupInformation]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.BackupInformation]] - _json = self._serialize.body(location, 'ContinuousBackupRestoreLocation') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(location, (IO, bytes)): + _content = location + else: + _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") - request = build_retrieve_continuous_backup_information_request_initial( - subscription_id=self._config.subscription_id, + request = build_retrieve_continuous_backup_information_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, graph_name=graph_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._retrieve_continuous_backup_information_initial.metadata['url'], + content=_content, + template_url=self._retrieve_continuous_backup_information_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1971,10 +2166,9 @@ async def _retrieve_continuous_backup_information_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1983,17 +2177,16 @@ async def _retrieve_continuous_backup_information_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BackupInformation', pipeline_response) + deserialized = self._deserialize("BackupInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _retrieve_continuous_backup_information_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/retrieveContinuousBackupInformation"} # type: ignore - + _retrieve_continuous_backup_information_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/retrieveContinuousBackupInformation"} # type: ignore - @distributed_trace_async + @overload async def begin_retrieve_continuous_backup_information( self, resource_group_name: str, @@ -2001,20 +2194,109 @@ async def begin_retrieve_continuous_backup_information( database_name: str, graph_name: str, location: _models.ContinuousBackupRestoreLocation, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.BackupInformation]: """Retrieves continuous backup information for a gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. + :param graph_name: Cosmos DB graph name. Required. :type graph_name: str - :param location: The name of the continuous backup restore location. + :param location: The name of the continuous backup restore location. Required. :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_retrieve_continuous_backup_information( + self, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + location: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a gremlin graph. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param location: The name of the continuous backup restore location. Required. + :type location: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_retrieve_continuous_backup_information( + self, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + location: Union[_models.ContinuousBackupRestoreLocation, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a gremlin graph. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param location: The name of the continuous backup restore location. Is either a model type or + a IO type. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -2026,20 +2308,17 @@ async def begin_retrieve_continuous_backup_information( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BackupInformation] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupInformation] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._retrieve_continuous_backup_information_initial( # type: ignore resource_group_name=resource_group_name, @@ -2049,36 +2328,34 @@ async def begin_retrieve_continuous_backup_information( location=location, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BackupInformation', pipeline_response) + deserialized = self._deserialize("BackupInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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}/gremlinDatabases/{databaseName}/graphs/{graphName}/retrieveContinuousBackupInformation"} # type: ignore + begin_retrieve_continuous_backup_information.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/retrieveContinuousBackupInformation"} # 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 9035e3a4367e..fe3e9ef4bd75 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,9 +28,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._locations_operations import build_get_request, build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class LocationsOperations: """ .. warning:: @@ -43,36 +52,31 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.LocationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.LocationGetResult"]: """List Cosmos DB locations and their properties. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.LocationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either LocationGetResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.LocationGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -80,14 +84,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -103,10 +104,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -116,44 +115,36 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations"} # type: ignore @distributed_trace_async - async def get( - self, - location: str, - **kwargs: Any - ) -> _models.LocationGetResult: + async def get(self, 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. + Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocationGetResult, or the result of cls(response) + :return: LocationGetResult or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.LocationGetResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocationGetResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocationGetResult] - request = build_get_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -161,22 +152,20 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocationGetResult', pipeline_response) + deserialized = self._deserialize("LocationGetResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}"} # type: ignore - + 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 519f6842fb6a..3aa1e7686992 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 @@ -6,10 +6,17 @@ # 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 Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,41 @@ 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_create_update_mongo_role_definition_request_initial, build_create_update_mongo_user_definition_request_initial, build_delete_mongo_db_collection_request_initial, build_delete_mongo_db_database_request_initial, build_delete_mongo_role_definition_request_initial, build_delete_mongo_user_definition_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_get_mongo_role_definition_request, build_get_mongo_user_definition_request, build_list_mongo_db_collection_partition_merge_request_initial, build_list_mongo_db_collections_request, build_list_mongo_db_databases_request, build_list_mongo_role_definitions_request, build_list_mongo_user_definitions_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_mongo_db_container_redistribute_throughput_request_initial, build_mongo_db_container_retrieve_throughput_distribution_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') +from ...operations._mongo_db_resources_operations import ( + build_create_update_mongo_db_collection_request, + build_create_update_mongo_db_database_request, + build_create_update_mongo_role_definition_request, + build_create_update_mongo_user_definition_request, + build_delete_mongo_db_collection_request, + build_delete_mongo_db_database_request, + build_delete_mongo_role_definition_request, + build_delete_mongo_user_definition_request, + 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_get_mongo_role_definition_request, + build_get_mongo_user_definition_request, + build_list_mongo_db_collection_partition_merge_request, + build_list_mongo_db_collections_request, + build_list_mongo_db_databases_request, + build_list_mongo_role_definitions_request, + build_list_mongo_user_definitions_request, + build_migrate_mongo_db_collection_to_autoscale_request, + build_migrate_mongo_db_collection_to_manual_throughput_request, + build_migrate_mongo_db_database_to_autoscale_request, + build_migrate_mongo_db_database_to_manual_throughput_request, + build_mongo_db_container_redistribute_throughput_request, + build_mongo_db_container_retrieve_throughput_distribution_request, + build_retrieve_continuous_backup_information_request, + build_update_mongo_db_collection_throughput_request, + build_update_mongo_db_database_throughput_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class MongoDBResourcesOperations: # pylint: disable=too-many-public-methods """ .. warning:: @@ -45,46 +83,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_mongo_db_databases( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.MongoDBDatabaseListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MongoDBDatabaseGetResults"]: """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 + :return: An iterator like instance of either MongoDBDatabaseGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MongoDBDatabaseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MongoDBDatabaseGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoDBDatabaseListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoDBDatabaseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_mongo_db_databases_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_mongo_db_databases.metadata['url'], + template_url=self.list_mongo_db_databases.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +126,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_mongo_db_databases_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +146,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -130,53 +157,45 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_mongo_db_databases.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases"} # type: ignore + 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, - account_name: str, - database_name: str, - **kwargs: Any + self, 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. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MongoDBDatabaseGetResults, or the result of cls(response) + :return: MongoDBDatabaseGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.MongoDBDatabaseGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoDBDatabaseGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoDBDatabaseGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_mongo_db_database.metadata['url'], + template_url=self.get_mongo_db_database.metadata["url"], headers=_headers, params=_params, ) @@ -184,57 +203,62 @@ async def get_mongo_db_database( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MongoDBDatabaseGetResults', pipeline_response) + deserialized = self._deserialize("MongoDBDatabaseGetResults", pipeline_response) if cls: 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 - + 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, account_name: str, database_name: str, - create_update_mongo_db_database_parameters: _models.MongoDBDatabaseCreateUpdateParameters, + create_update_mongo_db_database_parameters: Union[_models.MongoDBDatabaseCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.MongoDBDatabaseGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MongoDBDatabaseGetResults]] - - _json = self._serialize.body(create_update_mongo_db_database_parameters, 'MongoDBDatabaseCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MongoDBDatabaseGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_mongo_db_database_parameters, (IO, bytes)): + _content = create_update_mongo_db_database_parameters + else: + _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, + request = build_create_update_mongo_db_database_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_mongo_db_database_initial.metadata['url'], + content=_content, + template_url=self._create_update_mongo_db_database_initial.metadata["url"], headers=_headers, params=_params, ) @@ -242,10 +266,9 @@ async def _create_update_mongo_db_database_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -254,37 +277,123 @@ async def _create_update_mongo_db_database_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MongoDBDatabaseGetResults', pipeline_response) + deserialized = self._deserialize("MongoDBDatabaseGetResults", pipeline_response) if cls: 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 - + _create_update_mongo_db_database_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_update_mongo_db_database( self, resource_group_name: str, account_name: str, database_name: str, create_update_mongo_db_database_parameters: _models.MongoDBDatabaseCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :param create_update_mongo_db_database_parameters: The parameters to provide for the current - MongoDB database. + MongoDB database. Required. :type create_update_mongo_db_database_parameters: ~azure.mgmt.cosmosdb.models.MongoDBDatabaseCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + async def begin_create_update_mongo_db_database( + self, + resource_group_name: str, + account_name: str, + database_name: str, + create_update_mongo_db_database_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param create_update_mongo_db_database_parameters: The parameters to provide for the current + MongoDB database. Required. + :type create_update_mongo_db_database_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_create_update_mongo_db_database( + self, + resource_group_name: str, + account_name: str, + database_name: str, + create_update_mongo_db_database_parameters: Union[_models.MongoDBDatabaseCreateUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param create_update_mongo_db_database_parameters: The parameters to provide for the current + MongoDB database. Is either a model type or a IO type. Required. + :type create_update_mongo_db_database_parameters: + ~azure.mgmt.cosmosdb.models.MongoDBDatabaseCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -297,20 +406,17 @@ async def begin_create_update_mongo_db_database( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoDBDatabaseGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoDBDatabaseGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoDBDatabaseGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_update_mongo_db_database_initial( # type: ignore resource_group_name=resource_group_name, @@ -319,66 +425,55 @@ async def begin_create_update_mongo_db_database( create_update_mongo_db_database_parameters=create_update_mongo_db_database_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MongoDBDatabaseGetResults', pipeline_response) + deserialized = self._deserialize("MongoDBDatabaseGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_mongo_db_database_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_mongo_db_database_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_mongo_db_database_initial.metadata['url'], + template_url=self._delete_mongo_db_database_initial.metadata["url"], headers=_headers, params=_params, ) @@ -386,10 +481,9 @@ async def _delete_mongo_db_database_initial( # pylint: disable=inconsistent-ret request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -399,24 +493,20 @@ async def _delete_mongo_db_database_initial( # pylint: disable=inconsistent-ret if cls: return cls(pipeline_response, None, {}) - _delete_mongo_db_database_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + async def begin_delete_mongo_db_database( + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Azure Cosmos DB MongoDB database. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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. @@ -428,98 +518,85 @@ async def begin_delete_mongo_db_database( # pylint: disable=inconsistent-return 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_mongo_db_database_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: """Gets the RUs per second of the MongoDB database under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ThroughputSettingsGetResults, or the result of cls(response) + :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_mongo_db_database_throughput.metadata['url'], + template_url=self.get_mongo_db_database_throughput.metadata["url"], headers=_headers, params=_params, ) @@ -527,57 +604,60 @@ async def get_mongo_db_database_throughput( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + 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, account_name: str, database_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IO, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - request = build_update_mongo_db_database_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_mongo_db_database_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_mongo_db_database_throughput_initial.metadata['url'], + content=_content, + template_url=self._update_mongo_db_database_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -585,10 +665,9 @@ async def _update_mongo_db_database_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -597,37 +676,123 @@ async def _update_mongo_db_database_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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 + @overload async def begin_update_mongo_db_database_throughput( self, resource_group_name: str, account_name: str, database_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Update RUs per second of the an Azure Cosmos DB MongoDB database. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current MongoDB database. + current MongoDB database. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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: + """ + + @overload + async def begin_update_mongo_db_database_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + update_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of the an Azure Cosmos DB MongoDB database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current MongoDB database. Required. + :type update_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_update_mongo_db_database_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of the an Azure Cosmos DB MongoDB database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current MongoDB database. Is either a model type or a IO type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -640,20 +805,17 @@ async def begin_update_mongo_db_database_throughput( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._update_mongo_db_database_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -662,66 +824,55 @@ async def begin_update_mongo_db_database_throughput( update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_mongo_db_database_to_autoscale_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_mongo_db_database_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_mongo_db_database_to_autoscale_initial.metadata['url'], + template_url=self._migrate_mongo_db_database_to_autoscale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -729,10 +880,9 @@ async def _migrate_mongo_db_database_to_autoscale_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -741,31 +891,27 @@ async def _migrate_mongo_db_database_to_autoscale_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB MongoDB database from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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. @@ -779,85 +925,71 @@ async def begin_migrate_mongo_db_database_to_autoscale( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._migrate_mongo_db_database_to_autoscale_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_mongo_db_database_to_manual_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_mongo_db_database_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_mongo_db_database_to_manual_throughput_initial.metadata['url'], + template_url=self._migrate_mongo_db_database_to_manual_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -865,10 +997,9 @@ async def _migrate_mongo_db_database_to_manual_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -877,31 +1008,27 @@ async def _migrate_mongo_db_database_to_manual_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB MongoDB database from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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. @@ -915,58 +1042,51 @@ async def begin_migrate_mongo_db_database_to_manual_throughput( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._migrate_mongo_db_database_to_manual_throughput_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 async def _mongo_db_container_retrieve_throughput_distribution_initial( self, @@ -974,33 +1094,38 @@ async def _mongo_db_container_retrieve_throughput_distribution_initial( account_name: str, database_name: str, collection_name: str, - retrieve_throughput_parameters: _models.RetrieveThroughputParameters, + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO], **kwargs: Any ) -> Optional[_models.PhysicalPartitionThroughputInfoResult]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PhysicalPartitionThroughputInfoResult]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PhysicalPartitionThroughputInfoResult]] - _json = self._serialize.body(retrieve_throughput_parameters, 'RetrieveThroughputParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(retrieve_throughput_parameters, (IO, bytes)): + _content = retrieve_throughput_parameters + else: + _json = self._serialize.body(retrieve_throughput_parameters, "RetrieveThroughputParameters") - request = build_mongo_db_container_retrieve_throughput_distribution_request_initial( - subscription_id=self._config.subscription_id, + request = build_mongo_db_container_retrieve_throughput_distribution_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._mongo_db_container_retrieve_throughput_distribution_initial.metadata['url'], + content=_content, + template_url=self._mongo_db_container_retrieve_throughput_distribution_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1008,10 +1133,9 @@ async def _mongo_db_container_retrieve_throughput_distribution_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1020,17 +1144,16 @@ async def _mongo_db_container_retrieve_throughput_distribution_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PhysicalPartitionThroughputInfoResult', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _mongo_db_container_retrieve_throughput_distribution_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/retrieveThroughputDistribution"} # type: ignore + _mongo_db_container_retrieve_throughput_distribution_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/retrieveThroughputDistribution"} # type: ignore - - @distributed_trace_async + @overload async def begin_mongo_db_container_retrieve_throughput_distribution( self, resource_group_name: str, @@ -1038,21 +1161,27 @@ async def begin_mongo_db_container_retrieve_throughput_distribution( database_name: str, collection_name: str, retrieve_throughput_parameters: _models.RetrieveThroughputParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: """Retrieve throughput distribution for an Azure Cosmos DB MongoDB container. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :type collection_name: str :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current MongoDB container. + distribution for the current MongoDB container. Required. :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :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 @@ -1065,62 +1194,144 @@ async def begin_mongo_db_container_retrieve_throughput_distribution( PhysicalPartitionThroughputInfoResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PhysicalPartitionThroughputInfoResult] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._mongo_db_container_retrieve_throughput_distribution_initial( # type: ignore - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - collection_name=collection_name, - retrieve_throughput_parameters=retrieve_throughput_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PhysicalPartitionThroughputInfoResult', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - + @overload + async def begin_mongo_db_container_retrieve_throughput_distribution( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + retrieve_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB MongoDB container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current MongoDB container. Required. + :type retrieve_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 + PhysicalPartitionThroughputInfoResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_mongo_db_container_retrieve_throughput_distribution( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB MongoDB container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current MongoDB container. Is either a model type or a IO type. Required. + :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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 + PhysicalPartitionThroughputInfoResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhysicalPartitionThroughputInfoResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._mongo_db_container_retrieve_throughput_distribution_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + collection_name=collection_name, + retrieve_throughput_parameters=retrieve_throughput_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_mongo_db_container_retrieve_throughput_distribution.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/retrieveThroughputDistribution"} # type: ignore + begin_mongo_db_container_retrieve_throughput_distribution.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/retrieveThroughputDistribution"} # type: ignore async def _mongo_db_container_redistribute_throughput_initial( self, @@ -1128,33 +1339,38 @@ async def _mongo_db_container_redistribute_throughput_initial( account_name: str, database_name: str, collection_name: str, - redistribute_throughput_parameters: _models.RedistributeThroughputParameters, + redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO], **kwargs: Any ) -> Optional[_models.PhysicalPartitionThroughputInfoResult]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PhysicalPartitionThroughputInfoResult]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PhysicalPartitionThroughputInfoResult]] - _json = self._serialize.body(redistribute_throughput_parameters, 'RedistributeThroughputParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(redistribute_throughput_parameters, (IO, bytes)): + _content = redistribute_throughput_parameters + else: + _json = self._serialize.body(redistribute_throughput_parameters, "RedistributeThroughputParameters") - request = build_mongo_db_container_redistribute_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_mongo_db_container_redistribute_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._mongo_db_container_redistribute_throughput_initial.metadata['url'], + content=_content, + template_url=self._mongo_db_container_redistribute_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1162,10 +1378,9 @@ async def _mongo_db_container_redistribute_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1174,17 +1389,16 @@ async def _mongo_db_container_redistribute_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PhysicalPartitionThroughputInfoResult', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _mongo_db_container_redistribute_throughput_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/redistributeThroughput"} # type: ignore + _mongo_db_container_redistribute_throughput_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/redistributeThroughput"} # type: ignore - - @distributed_trace_async + @overload async def begin_mongo_db_container_redistribute_throughput( self, resource_group_name: str, @@ -1192,22 +1406,28 @@ async def begin_mongo_db_container_redistribute_throughput( database_name: str, collection_name: str, redistribute_throughput_parameters: _models.RedistributeThroughputParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: """Redistribute throughput for an Azure Cosmos DB MongoDB container. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :type collection_name: str :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current MongoDB container. + throughput for the current MongoDB container. Required. :type redistribute_throughput_parameters: ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :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 @@ -1220,20 +1440,104 @@ async def begin_mongo_db_container_redistribute_throughput( PhysicalPartitionThroughputInfoResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_mongo_db_container_redistribute_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + redistribute_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Redistribute throughput for an Azure Cosmos DB MongoDB container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current MongoDB container. Required. + :type redistribute_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 + PhysicalPartitionThroughputInfoResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_mongo_db_container_redistribute_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Redistribute throughput for an Azure Cosmos DB MongoDB container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current MongoDB container. Is either a model type or a IO type. Required. + :type redistribute_throughput_parameters: + ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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 + PhysicalPartitionThroughputInfoResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PhysicalPartitionThroughputInfoResult] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhysicalPartitionThroughputInfoResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._mongo_db_container_redistribute_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -1243,83 +1547,77 @@ async def begin_mongo_db_container_redistribute_throughput( redistribute_throughput_parameters=redistribute_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PhysicalPartitionThroughputInfoResult', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_mongo_db_container_redistribute_throughput.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/redistributeThroughput"} # type: ignore + begin_mongo_db_container_redistribute_throughput.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/redistributeThroughput"} # type: ignore @distributed_trace def list_mongo_db_collections( - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.MongoDBCollectionListResult]: + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MongoDBCollectionGetResults"]: """Lists the MongoDB collection under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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 + :return: An iterator like instance of either MongoDBCollectionGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MongoDBCollectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoDBCollectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoDBCollectionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_mongo_db_collections_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_mongo_db_collections.metadata['url'], + template_url=self.list_mongo_db_collections.metadata["url"], headers=_headers, params=_params, ) @@ -1327,17 +1625,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1353,10 +1645,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1366,56 +1656,47 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + 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, - account_name: str, - database_name: str, - collection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any ) -> _models.MongoDBCollectionGetResults: """Gets the MongoDB collection under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :type collection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MongoDBCollectionGetResults, or the result of cls(response) + :return: MongoDBCollectionGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoDBCollectionGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoDBCollectionGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_mongo_db_collection.metadata['url'], + template_url=self.get_mongo_db_collection.metadata["url"], headers=_headers, params=_params, ) @@ -1423,25 +1704,23 @@ async def get_mongo_db_collection( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MongoDBCollectionGetResults', pipeline_response) + deserialized = self._deserialize("MongoDBCollectionGetResults", pipeline_response) if cls: 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 - + 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, @@ -1449,33 +1728,40 @@ async def _create_update_mongo_db_collection_initial( account_name: str, database_name: str, collection_name: str, - create_update_mongo_db_collection_parameters: _models.MongoDBCollectionCreateUpdateParameters, + create_update_mongo_db_collection_parameters: Union[_models.MongoDBCollectionCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.MongoDBCollectionGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MongoDBCollectionGetResults]] - - _json = self._serialize.body(create_update_mongo_db_collection_parameters, 'MongoDBCollectionCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MongoDBCollectionGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_mongo_db_collection_parameters, (IO, bytes)): + _content = create_update_mongo_db_collection_parameters + else: + _json = self._serialize.body( + create_update_mongo_db_collection_parameters, "MongoDBCollectionCreateUpdateParameters" + ) - request = build_create_update_mongo_db_collection_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_mongo_db_collection_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_mongo_db_collection_initial.metadata['url'], + content=_content, + template_url=self._create_update_mongo_db_collection_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1483,10 +1769,9 @@ async def _create_update_mongo_db_collection_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1495,17 +1780,16 @@ async def _create_update_mongo_db_collection_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MongoDBCollectionGetResults', pipeline_response) + deserialized = self._deserialize("MongoDBCollectionGetResults", pipeline_response) if cls: 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 - + _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 + @overload async def begin_create_update_mongo_db_collection( self, resource_group_name: str, @@ -1513,22 +1797,115 @@ async def begin_create_update_mongo_db_collection( database_name: str, collection_name: str, create_update_mongo_db_collection_parameters: _models.MongoDBCollectionCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.MongoDBCollectionGetResults]: """Create or update an Azure Cosmos DB MongoDB Collection. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :type collection_name: str :param create_update_mongo_db_collection_parameters: The parameters to provide for the current - MongoDB Collection. + MongoDB Collection. Required. :type create_update_mongo_db_collection_parameters: ~azure.mgmt.cosmosdb.models.MongoDBCollectionCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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: + """ + + @overload + async def begin_create_update_mongo_db_collection( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + create_update_mongo_db_collection_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MongoDBCollectionGetResults]: + """Create or update an Azure Cosmos DB MongoDB Collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param create_update_mongo_db_collection_parameters: The parameters to provide for the current + MongoDB Collection. Required. + :type create_update_mongo_db_collection_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_create_update_mongo_db_collection( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + create_update_mongo_db_collection_parameters: Union[_models.MongoDBCollectionCreateUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.MongoDBCollectionGetResults]: + """Create or update an Azure Cosmos DB MongoDB Collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param create_update_mongo_db_collection_parameters: The parameters to provide for the current + MongoDB Collection. Is either a model type or a IO type. Required. + :type create_update_mongo_db_collection_parameters: + ~azure.mgmt.cosmosdb.models.MongoDBCollectionCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -1541,20 +1918,17 @@ async def begin_create_update_mongo_db_collection( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoDBCollectionGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoDBCollectionGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_update_mongo_db_collection_initial( # type: ignore resource_group_name=resource_group_name, @@ -1564,68 +1938,56 @@ async def begin_create_update_mongo_db_collection( create_update_mongo_db_collection_parameters=create_update_mongo_db_collection_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MongoDBCollectionGetResults', pipeline_response) + deserialized = self._deserialize("MongoDBCollectionGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_mongo_db_collection_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_mongo_db_collection_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_mongo_db_collection_initial.metadata['url'], + template_url=self._delete_mongo_db_collection_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1633,10 +1995,9 @@ async def _delete_mongo_db_collection_initial( # pylint: disable=inconsistent-r request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1646,27 +2007,22 @@ async def _delete_mongo_db_collection_initial( # pylint: disable=inconsistent-r if cls: return cls(pipeline_response, None, {}) - _delete_mongo_db_collection_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - **kwargs: Any + async def begin_delete_mongo_db_collection( + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Azure Cosmos DB MongoDB Collection. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :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. @@ -1678,19 +2034,16 @@ async def begin_delete_mongo_db_collection( # pylint: disable=inconsistent-retu 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_mongo_db_collection_initial( # type: ignore resource_group_name=resource_group_name, @@ -1698,37 +2051,33 @@ async def begin_delete_mongo_db_collection( # pylint: disable=inconsistent-retu database_name=database_name, collection_name=collection_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_delete_mongo_db_collection.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}"} # type: ignore async def _list_mongo_db_collection_partition_merge_initial( self, @@ -1736,33 +2085,38 @@ async def _list_mongo_db_collection_partition_merge_initial( account_name: str, database_name: str, collection_name: str, - merge_parameters: _models.MergeParameters, + merge_parameters: Union[_models.MergeParameters, IO], **kwargs: Any ) -> Optional[_models.PhysicalPartitionStorageInfoCollection]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PhysicalPartitionStorageInfoCollection]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PhysicalPartitionStorageInfoCollection]] - _json = self._serialize.body(merge_parameters, 'MergeParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(merge_parameters, (IO, bytes)): + _content = merge_parameters + else: + _json = self._serialize.body(merge_parameters, "MergeParameters") - request = build_list_mongo_db_collection_partition_merge_request_initial( - subscription_id=self._config.subscription_id, + request = build_list_mongo_db_collection_partition_merge_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._list_mongo_db_collection_partition_merge_initial.metadata['url'], + content=_content, + template_url=self._list_mongo_db_collection_partition_merge_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1770,10 +2124,9 @@ async def _list_mongo_db_collection_partition_merge_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1782,17 +2135,16 @@ async def _list_mongo_db_collection_partition_merge_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PhysicalPartitionStorageInfoCollection', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionStorageInfoCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _list_mongo_db_collection_partition_merge_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/partitionMerge"} # type: ignore + _list_mongo_db_collection_partition_merge_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/partitionMerge"} # type: ignore - - @distributed_trace_async + @overload async def begin_list_mongo_db_collection_partition_merge( self, resource_group_name: str, @@ -1800,20 +2152,111 @@ async def begin_list_mongo_db_collection_partition_merge( database_name: str, collection_name: str, merge_parameters: _models.MergeParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: """Merges the partitions of a MongoDB Collection. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :type collection_name: str - :param merge_parameters: The parameters for the merge operation. + :param merge_parameters: The parameters for the merge operation. Required. :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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 + PhysicalPartitionStorageInfoCollection or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_list_mongo_db_collection_partition_merge( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + merge_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: + """Merges the partitions of a MongoDB Collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param merge_parameters: The parameters for the merge operation. Required. + :type merge_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 + PhysicalPartitionStorageInfoCollection or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_list_mongo_db_collection_partition_merge( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + merge_parameters: Union[_models.MergeParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: + """Merges the partitions of a MongoDB Collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param merge_parameters: The parameters for the merge operation. Is either a model type or a IO + type. Required. + :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -1826,20 +2269,17 @@ async def begin_list_mongo_db_collection_partition_merge( PhysicalPartitionStorageInfoCollection or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PhysicalPartitionStorageInfoCollection] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhysicalPartitionStorageInfoCollection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._list_mongo_db_collection_partition_merge_initial( # type: ignore resource_group_name=resource_group_name, @@ -1849,85 +2289,76 @@ async def begin_list_mongo_db_collection_partition_merge( merge_parameters=merge_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PhysicalPartitionStorageInfoCollection', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionStorageInfoCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_list_mongo_db_collection_partition_merge.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/partitionMerge"} # type: ignore + begin_list_mongo_db_collection_partition_merge.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/partitionMerge"} # type: ignore @distributed_trace_async async def get_mongo_db_collection_throughput( - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: """Gets the RUs per second of the MongoDB collection under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :type collection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ThroughputSettingsGetResults, or the result of cls(response) + :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_mongo_db_collection_throughput.metadata['url'], + template_url=self.get_mongo_db_collection_throughput.metadata["url"], headers=_headers, params=_params, ) @@ -1935,25 +2366,23 @@ async def get_mongo_db_collection_throughput( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + 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, @@ -1961,33 +2390,38 @@ async def _update_mongo_db_collection_throughput_initial( account_name: str, database_name: str, collection_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IO, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - request = build_update_mongo_db_collection_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_mongo_db_collection_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_mongo_db_collection_throughput_initial.metadata['url'], + content=_content, + template_url=self._update_mongo_db_collection_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1995,10 +2429,9 @@ async def _update_mongo_db_collection_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2007,17 +2440,16 @@ async def _update_mongo_db_collection_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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 + @overload async def begin_update_mongo_db_collection_throughput( self, resource_group_name: str, @@ -2025,22 +2457,28 @@ async def begin_update_mongo_db_collection_throughput( database_name: str, collection_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Update the RUs per second of an Azure Cosmos DB MongoDB collection. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :type collection_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current MongoDB collection. + current MongoDB collection. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :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 @@ -2053,20 +2491,104 @@ async def begin_update_mongo_db_collection_throughput( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_mongo_db_collection_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + update_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update the RUs per second of an Azure Cosmos DB MongoDB collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current MongoDB collection. Required. + :type update_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_update_mongo_db_collection_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update the RUs per second of an Azure Cosmos DB MongoDB collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current MongoDB collection. Is either a model type or a IO type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._update_mongo_db_collection_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -2076,68 +2598,56 @@ async def begin_update_mongo_db_collection_throughput( update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_mongo_db_collection_to_autoscale_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_mongo_db_collection_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_mongo_db_collection_to_autoscale_initial.metadata['url'], + template_url=self._migrate_mongo_db_collection_to_autoscale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2145,10 +2655,9 @@ async def _migrate_mongo_db_collection_to_autoscale_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2157,34 +2666,29 @@ async def _migrate_mongo_db_collection_to_autoscale_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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, - account_name: str, - database_name: str, - collection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB MongoDB collection from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :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. @@ -2198,19 +2702,16 @@ async def begin_migrate_mongo_db_collection_to_autoscale( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._migrate_mongo_db_collection_to_autoscale_initial( # type: ignore resource_group_name=resource_group_name, @@ -2218,68 +2719,56 @@ async def begin_migrate_mongo_db_collection_to_autoscale( database_name=database_name, collection_name=collection_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_mongo_db_collection_to_manual_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_mongo_db_collection_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_mongo_db_collection_to_manual_throughput_initial.metadata['url'], + template_url=self._migrate_mongo_db_collection_to_manual_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2287,10 +2776,9 @@ async def _migrate_mongo_db_collection_to_manual_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2299,34 +2787,29 @@ async def _migrate_mongo_db_collection_to_manual_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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, - account_name: str, - database_name: str, - collection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB MongoDB collection from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :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. @@ -2340,19 +2823,16 @@ async def begin_migrate_mongo_db_collection_to_manual_throughput( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._migrate_mongo_db_collection_to_manual_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -2360,81 +2840,71 @@ async def begin_migrate_mongo_db_collection_to_manual_throughput( database_name=database_name, collection_name=collection_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 @distributed_trace_async async def get_mongo_role_definition( - self, - mongo_role_definition_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, mongo_role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.MongoRoleDefinitionGetResults: """Retrieves the properties of an existing Azure Cosmos DB Mongo Role Definition with the given Id. - :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. + :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. :type mongo_role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MongoRoleDefinitionGetResults, or the result of cls(response) + :return: MongoRoleDefinitionGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoRoleDefinitionGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoRoleDefinitionGetResults] - request = build_get_mongo_role_definition_request( mongo_role_definition_id=mongo_role_definition_id, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_mongo_role_definition.metadata['url'], + template_url=self.get_mongo_role_definition.metadata["url"], headers=_headers, params=_params, ) @@ -2442,57 +2912,62 @@ async def get_mongo_role_definition( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MongoRoleDefinitionGetResults', pipeline_response) + deserialized = self._deserialize("MongoRoleDefinitionGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_mongo_role_definition.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}"} # type: ignore - + get_mongo_role_definition.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}"} # type: ignore async def _create_update_mongo_role_definition_initial( self, mongo_role_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_role_definition_parameters: _models.MongoRoleDefinitionCreateUpdateParameters, + create_update_mongo_role_definition_parameters: Union[_models.MongoRoleDefinitionCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.MongoRoleDefinitionGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MongoRoleDefinitionGetResults]] - - _json = self._serialize.body(create_update_mongo_role_definition_parameters, 'MongoRoleDefinitionCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MongoRoleDefinitionGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_mongo_role_definition_parameters, (IO, bytes)): + _content = create_update_mongo_role_definition_parameters + else: + _json = self._serialize.body( + create_update_mongo_role_definition_parameters, "MongoRoleDefinitionCreateUpdateParameters" + ) - request = build_create_update_mongo_role_definition_request_initial( + request = build_create_update_mongo_role_definition_request( mongo_role_definition_id=mongo_role_definition_id, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_mongo_role_definition_initial.metadata['url'], + content=_content, + template_url=self._create_update_mongo_role_definition_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2500,10 +2975,9 @@ async def _create_update_mongo_role_definition_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2512,15 +2986,97 @@ async def _create_update_mongo_role_definition_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MongoRoleDefinitionGetResults', pipeline_response) + deserialized = self._deserialize("MongoRoleDefinitionGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_update_mongo_role_definition_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}"} # type: ignore + _create_update_mongo_role_definition_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}"} # type: ignore + + @overload + async def begin_create_update_mongo_role_definition( + self, + mongo_role_definition_id: str, + resource_group_name: str, + account_name: str, + create_update_mongo_role_definition_parameters: _models.MongoRoleDefinitionCreateUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MongoRoleDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB Mongo Role Definition. + + :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. + :type mongo_role_definition_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param create_update_mongo_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_mongo_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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 MongoRoleDefinitionGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_update_mongo_role_definition( + self, + mongo_role_definition_id: str, + resource_group_name: str, + account_name: str, + create_update_mongo_role_definition_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MongoRoleDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB Mongo Role Definition. + :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. + :type mongo_role_definition_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param create_update_mongo_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_mongo_role_definition_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 MongoRoleDefinitionGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_update_mongo_role_definition( @@ -2528,21 +3084,25 @@ async def begin_create_update_mongo_role_definition( mongo_role_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_role_definition_parameters: _models.MongoRoleDefinitionCreateUpdateParameters, + create_update_mongo_role_definition_parameters: Union[_models.MongoRoleDefinitionCreateUpdateParameters, IO], **kwargs: Any ) -> AsyncLROPoller[_models.MongoRoleDefinitionGetResults]: """Creates or updates an Azure Cosmos DB Mongo Role Definition. - :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. + :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. :type mongo_role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param create_update_mongo_role_definition_parameters: The properties required to create or - update a Role Definition. + update a Role Definition. Is either a model type or a IO type. Required. :type create_update_mongo_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionCreateUpdateParameters + ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -2555,20 +3115,17 @@ async def begin_create_update_mongo_role_definition( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoRoleDefinitionGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoRoleDefinitionGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_update_mongo_role_definition_initial( # type: ignore mongo_role_definition_id=mongo_role_definition_id, @@ -2577,66 +3134,55 @@ async def begin_create_update_mongo_role_definition( create_update_mongo_role_definition_parameters=create_update_mongo_role_definition_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MongoRoleDefinitionGetResults', pipeline_response) + deserialized = self._deserialize("MongoRoleDefinitionGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_update_mongo_role_definition.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}"} # type: ignore + begin_create_update_mongo_role_definition.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}"} # type: ignore async def _delete_mongo_role_definition_initial( # pylint: disable=inconsistent-return-statements - self, - mongo_role_definition_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, mongo_role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_mongo_role_definition_request_initial( + request = build_delete_mongo_role_definition_request( mongo_role_definition_id=mongo_role_definition_id, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_mongo_role_definition_initial.metadata['url'], + template_url=self._delete_mongo_role_definition_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2644,10 +3190,9 @@ async def _delete_mongo_role_definition_initial( # pylint: disable=inconsistent request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -2657,24 +3202,20 @@ async def _delete_mongo_role_definition_initial( # pylint: disable=inconsistent if cls: return cls(pipeline_response, None, {}) - _delete_mongo_role_definition_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}"} # type: ignore - + _delete_mongo_role_definition_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}"} # type: ignore @distributed_trace_async - async def begin_delete_mongo_role_definition( # pylint: disable=inconsistent-return-statements - self, - mongo_role_definition_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + async def begin_delete_mongo_role_definition( + self, mongo_role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Azure Cosmos DB Mongo Role Definition. - :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. + :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. :type mongo_role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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. @@ -2686,96 +3227,86 @@ async def begin_delete_mongo_role_definition( # pylint: disable=inconsistent-re 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_mongo_role_definition_initial( # type: ignore mongo_role_definition_id=mongo_role_definition_id, resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_mongo_role_definition.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}"} # type: ignore + begin_delete_mongo_role_definition.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}"} # type: ignore @distributed_trace def list_mongo_role_definitions( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.MongoRoleDefinitionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MongoRoleDefinitionGetResults"]: """Retrieves the list of all Azure Cosmos DB Mongo Role Definitions. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 MongoRoleDefinitionListResult or the result of + :return: An iterator like instance of either MongoRoleDefinitionGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoRoleDefinitionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoRoleDefinitionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_mongo_role_definitions_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_mongo_role_definitions.metadata['url'], + template_url=self.list_mongo_role_definitions.metadata["url"], headers=_headers, params=_params, ) @@ -2783,16 +3314,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_mongo_role_definitions_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -2808,10 +3334,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2821,53 +3345,45 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_mongo_role_definitions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions"} # type: ignore + list_mongo_role_definitions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions"} # type: ignore @distributed_trace_async async def get_mongo_user_definition( - self, - mongo_user_definition_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, mongo_user_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.MongoUserDefinitionGetResults: """Retrieves the properties of an existing Azure Cosmos DB Mongo User Definition with the given Id. - :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. + :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. :type mongo_user_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MongoUserDefinitionGetResults, or the result of cls(response) + :return: MongoUserDefinitionGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoUserDefinitionGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoUserDefinitionGetResults] - request = build_get_mongo_user_definition_request( mongo_user_definition_id=mongo_user_definition_id, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_mongo_user_definition.metadata['url'], + template_url=self.get_mongo_user_definition.metadata["url"], headers=_headers, params=_params, ) @@ -2875,57 +3391,62 @@ async def get_mongo_user_definition( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MongoUserDefinitionGetResults', pipeline_response) + deserialized = self._deserialize("MongoUserDefinitionGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_mongo_user_definition.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}"} # type: ignore - + get_mongo_user_definition.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}"} # type: ignore async def _create_update_mongo_user_definition_initial( self, mongo_user_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_user_definition_parameters: _models.MongoUserDefinitionCreateUpdateParameters, + create_update_mongo_user_definition_parameters: Union[_models.MongoUserDefinitionCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.MongoUserDefinitionGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MongoUserDefinitionGetResults]] - - _json = self._serialize.body(create_update_mongo_user_definition_parameters, 'MongoUserDefinitionCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MongoUserDefinitionGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_mongo_user_definition_parameters, (IO, bytes)): + _content = create_update_mongo_user_definition_parameters + else: + _json = self._serialize.body( + create_update_mongo_user_definition_parameters, "MongoUserDefinitionCreateUpdateParameters" + ) - request = build_create_update_mongo_user_definition_request_initial( + request = build_create_update_mongo_user_definition_request( mongo_user_definition_id=mongo_user_definition_id, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_mongo_user_definition_initial.metadata['url'], + content=_content, + template_url=self._create_update_mongo_user_definition_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2933,10 +3454,9 @@ async def _create_update_mongo_user_definition_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2945,37 +3465,123 @@ async def _create_update_mongo_user_definition_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MongoUserDefinitionGetResults', pipeline_response) + deserialized = self._deserialize("MongoUserDefinitionGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_update_mongo_user_definition_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}"} # type: ignore - + _create_update_mongo_user_definition_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_update_mongo_user_definition( self, mongo_user_definition_id: str, resource_group_name: str, account_name: str, create_update_mongo_user_definition_parameters: _models.MongoUserDefinitionCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.MongoUserDefinitionGetResults]: """Creates or updates an Azure Cosmos DB Mongo User Definition. - :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. + :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. :type mongo_user_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param create_update_mongo_user_definition_parameters: The properties required to create or - update a User Definition. + update a User Definition. Required. :type create_update_mongo_user_definition_parameters: ~azure.mgmt.cosmosdb.models.MongoUserDefinitionCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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 MongoUserDefinitionGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_update_mongo_user_definition( + self, + mongo_user_definition_id: str, + resource_group_name: str, + account_name: str, + create_update_mongo_user_definition_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MongoUserDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB Mongo User Definition. + + :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. + :type mongo_user_definition_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param create_update_mongo_user_definition_parameters: The properties required to create or + update a User Definition. Required. + :type create_update_mongo_user_definition_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 MongoUserDefinitionGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_update_mongo_user_definition( + self, + mongo_user_definition_id: str, + resource_group_name: str, + account_name: str, + create_update_mongo_user_definition_parameters: Union[_models.MongoUserDefinitionCreateUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.MongoUserDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB Mongo User Definition. + + :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. + :type mongo_user_definition_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param create_update_mongo_user_definition_parameters: The properties required to create or + update a User Definition. Is either a model type or a IO type. Required. + :type create_update_mongo_user_definition_parameters: + ~azure.mgmt.cosmosdb.models.MongoUserDefinitionCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -2988,20 +3594,17 @@ async def begin_create_update_mongo_user_definition( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoUserDefinitionGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoUserDefinitionGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_update_mongo_user_definition_initial( # type: ignore mongo_user_definition_id=mongo_user_definition_id, @@ -3010,66 +3613,55 @@ async def begin_create_update_mongo_user_definition( create_update_mongo_user_definition_parameters=create_update_mongo_user_definition_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MongoUserDefinitionGetResults', pipeline_response) + deserialized = self._deserialize("MongoUserDefinitionGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_update_mongo_user_definition.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}"} # type: ignore + begin_create_update_mongo_user_definition.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}"} # type: ignore async def _delete_mongo_user_definition_initial( # pylint: disable=inconsistent-return-statements - self, - mongo_user_definition_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, mongo_user_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_mongo_user_definition_request_initial( + request = build_delete_mongo_user_definition_request( mongo_user_definition_id=mongo_user_definition_id, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_mongo_user_definition_initial.metadata['url'], + template_url=self._delete_mongo_user_definition_initial.metadata["url"], headers=_headers, params=_params, ) @@ -3077,10 +3669,9 @@ async def _delete_mongo_user_definition_initial( # pylint: disable=inconsistent request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -3090,24 +3681,20 @@ async def _delete_mongo_user_definition_initial( # pylint: disable=inconsistent if cls: return cls(pipeline_response, None, {}) - _delete_mongo_user_definition_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}"} # type: ignore - + _delete_mongo_user_definition_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}"} # type: ignore @distributed_trace_async - async def begin_delete_mongo_user_definition( # pylint: disable=inconsistent-return-statements - self, - mongo_user_definition_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + async def begin_delete_mongo_user_definition( + self, mongo_user_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Azure Cosmos DB Mongo User Definition. - :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. + :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. :type mongo_user_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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. @@ -3119,96 +3706,86 @@ async def begin_delete_mongo_user_definition( # pylint: disable=inconsistent-re 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_mongo_user_definition_initial( # type: ignore mongo_user_definition_id=mongo_user_definition_id, resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_mongo_user_definition.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}"} # type: ignore + begin_delete_mongo_user_definition.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}"} # type: ignore @distributed_trace def list_mongo_user_definitions( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.MongoUserDefinitionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.MongoUserDefinitionGetResults"]: """Retrieves the list of all Azure Cosmos DB Mongo User Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 MongoUserDefinitionListResult or the result of + :return: An iterator like instance of either MongoUserDefinitionGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MongoUserDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoUserDefinitionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoUserDefinitionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_mongo_user_definitions_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_mongo_user_definitions.metadata['url'], + template_url=self.list_mongo_user_definitions.metadata["url"], headers=_headers, params=_params, ) @@ -3216,16 +3793,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_mongo_user_definitions_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -3241,10 +3813,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3254,11 +3824,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_mongo_user_definitions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions"} # type: ignore + list_mongo_user_definitions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions"} # type: ignore async def _retrieve_continuous_backup_information_initial( self, @@ -3266,33 +3834,38 @@ async def _retrieve_continuous_backup_information_initial( account_name: str, database_name: str, collection_name: str, - location: _models.ContinuousBackupRestoreLocation, + location: Union[_models.ContinuousBackupRestoreLocation, IO], **kwargs: Any ) -> Optional[_models.BackupInformation]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.BackupInformation]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.BackupInformation]] - _json = self._serialize.body(location, 'ContinuousBackupRestoreLocation') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(location, (IO, bytes)): + _content = location + else: + _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") - request = build_retrieve_continuous_backup_information_request_initial( - subscription_id=self._config.subscription_id, + request = build_retrieve_continuous_backup_information_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._retrieve_continuous_backup_information_initial.metadata['url'], + content=_content, + template_url=self._retrieve_continuous_backup_information_initial.metadata["url"], headers=_headers, params=_params, ) @@ -3300,10 +3873,9 @@ async def _retrieve_continuous_backup_information_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3312,17 +3884,16 @@ async def _retrieve_continuous_backup_information_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BackupInformation', pipeline_response) + deserialized = self._deserialize("BackupInformation", pipeline_response) if cls: 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 + _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 + @overload async def begin_retrieve_continuous_backup_information( self, resource_group_name: str, @@ -3330,20 +3901,68 @@ async def begin_retrieve_continuous_backup_information( database_name: str, collection_name: str, location: _models.ContinuousBackupRestoreLocation, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.BackupInformation]: """Retrieves continuous backup information for a Mongodb collection. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :type collection_name: str - :param location: The name of the continuous backup restore location. + :param location: The name of the continuous backup restore location. Required. :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_retrieve_continuous_backup_information( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + location: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a Mongodb collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param location: The name of the continuous backup restore location. Required. + :type location: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -3355,20 +3974,58 @@ async def begin_retrieve_continuous_backup_information( :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: + """ + + @distributed_trace_async + async def begin_retrieve_continuous_backup_information( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + location: Union[_models.ContinuousBackupRestoreLocation, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a Mongodb collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param location: The name of the continuous backup restore location. Is either a model type or + a IO type. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BackupInformation] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupInformation] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._retrieve_continuous_backup_information_initial( # type: ignore resource_group_name=resource_group_name, @@ -3378,36 +4035,34 @@ async def begin_retrieve_continuous_backup_information( location=location, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BackupInformation', pipeline_response) + deserialized = self._deserialize("BackupInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 1e189f4f0b5d..dd048dc62f53 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 @@ -6,10 +6,17 @@ # 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 Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,20 @@ 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') +from ...operations._notebook_workspaces_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_database_account_request, + build_list_connection_info_request, + build_regenerate_auth_token_request, + build_start_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class NotebookWorkspacesOperations: """ .. warning:: @@ -45,46 +62,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_database_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.NotebookWorkspaceListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NotebookWorkspace"]: """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either NotebookWorkspace or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.NotebookWorkspace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NotebookWorkspaceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NotebookWorkspaceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_database_account_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_database_account.metadata['url'], + template_url=self.list_by_database_account.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +103,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_database_account_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +123,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,11 +135,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_database_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces"} # type: ignore + list_by_database_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces"} # type: ignore @distributed_trace_async async def get( @@ -148,35 +150,34 @@ async def get( """Gets the notebook workspace for a Cosmos DB account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param notebook_workspace_name: The name of the notebook workspace resource. + :param notebook_workspace_name: The name of the notebook workspace resource. "default" + Required. :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 - :return: NotebookWorkspace, or the result of cls(response) + :return: NotebookWorkspace or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.NotebookWorkspace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NotebookWorkspace] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NotebookWorkspace] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -184,10 +185,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -195,47 +195,51 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NotebookWorkspace', pipeline_response) + deserialized = self._deserialize("NotebookWorkspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}"} # type: ignore - + 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, account_name: str, notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], - notebook_create_update_parameters: _models.NotebookWorkspaceCreateUpdateParameters, + notebook_create_update_parameters: Union[_models.NotebookWorkspaceCreateUpdateParameters, IO], **kwargs: Any ) -> _models.NotebookWorkspace: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NotebookWorkspace] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NotebookWorkspace] - _json = self._serialize.body(notebook_create_update_parameters, 'NotebookWorkspaceCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notebook_create_update_parameters, (IO, bytes)): + _content = notebook_create_update_parameters + else: + _json = self._serialize.body(notebook_create_update_parameters, "NotebookWorkspaceCreateUpdateParameters") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, notebook_workspace_name=notebook_workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -243,47 +247,134 @@ async def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NotebookWorkspace', pipeline_response) + deserialized = self._deserialize("NotebookWorkspace", pipeline_response) if cls: 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 - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, account_name: str, notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], notebook_create_update_parameters: _models.NotebookWorkspaceCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param notebook_workspace_name: The name of the notebook workspace resource. + :param notebook_workspace_name: The name of the notebook workspace resource. "default" + Required. :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. + database account. Required. :type notebook_create_update_parameters: ~azure.mgmt.cosmosdb.models.NotebookWorkspaceCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.NotebookWorkspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + notebook_create_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param notebook_workspace_name: The name of the notebook workspace resource. "default" + Required. + :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. Required. + :type notebook_create_update_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.NotebookWorkspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + notebook_create_update_parameters: Union[_models.NotebookWorkspaceCreateUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param notebook_workspace_name: The name of the notebook workspace resource. "default" + Required. + :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. Is either a model type or a IO type. Required. + :type notebook_create_update_parameters: + ~azure.mgmt.cosmosdb.models.NotebookWorkspaceCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -295,20 +386,17 @@ async def begin_create_or_update( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NotebookWorkspace] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NotebookWorkspace] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -317,39 +405,35 @@ async def begin_create_or_update( notebook_create_update_parameters=notebook_create_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('NotebookWorkspace', pipeline_response) + deserialized = self._deserialize("NotebookWorkspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -358,25 +442,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, notebook_workspace_name=notebook_workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -384,24 +465,23 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, account_name: str, @@ -411,10 +491,12 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes the notebook workspace for a Cosmos DB account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param notebook_workspace_name: The name of the notebook workspace resource. + :param notebook_workspace_name: The name of the notebook workspace resource. "default" + Required. :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. @@ -426,56 +508,49 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, notebook_workspace_name=notebook_workspace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( @@ -488,35 +563,34 @@ async def list_connection_info( """Retrieves the connection info for the notebook workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param notebook_workspace_name: The name of the notebook workspace resource. + :param notebook_workspace_name: The name of the notebook workspace resource. "default" + Required. :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 - :return: NotebookWorkspaceConnectionInfoResult, or the result of cls(response) + :return: NotebookWorkspaceConnectionInfoResult or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.NotebookWorkspaceConnectionInfoResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NotebookWorkspaceConnectionInfoResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NotebookWorkspaceConnectionInfoResult] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_connection_info.metadata['url'], + template_url=self.list_connection_info.metadata["url"], headers=_headers, params=_params, ) @@ -524,10 +598,9 @@ async def list_connection_info( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -535,15 +608,14 @@ async def list_connection_info( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NotebookWorkspaceConnectionInfoResult', pipeline_response) + deserialized = self._deserialize("NotebookWorkspaceConnectionInfoResult", pipeline_response) if cls: 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 - + 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( # pylint: disable=inconsistent-return-statements self, @@ -552,25 +624,22 @@ async def _regenerate_auth_token_initial( # pylint: disable=inconsistent-return notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_regenerate_auth_token_request_initial( - subscription_id=self._config.subscription_id, + request = build_regenerate_auth_token_request( resource_group_name=resource_group_name, account_name=account_name, notebook_workspace_name=notebook_workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._regenerate_auth_token_initial.metadata['url'], + template_url=self._regenerate_auth_token_initial.metadata["url"], headers=_headers, params=_params, ) @@ -578,24 +647,23 @@ async def _regenerate_auth_token_initial( # pylint: disable=inconsistent-return request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) 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 - + _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( # pylint: disable=inconsistent-return-statements + async def begin_regenerate_auth_token( self, resource_group_name: str, account_name: str, @@ -605,10 +673,12 @@ async def begin_regenerate_auth_token( # pylint: disable=inconsistent-return-st """Regenerates the auth token for the notebook workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param notebook_workspace_name: The name of the notebook workspace resource. + :param notebook_workspace_name: The name of the notebook workspace resource. "default" + Required. :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. @@ -620,56 +690,49 @@ async def begin_regenerate_auth_token( # pylint: disable=inconsistent-return-st 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._regenerate_auth_token_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, notebook_workspace_name=notebook_workspace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_regenerate_auth_token.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/regenerateAuthToken"} # type: ignore async def _start_initial( # pylint: disable=inconsistent-return-statements self, @@ -678,25 +741,22 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + request = build_start_request( resource_group_name=resource_group_name, account_name=account_name, notebook_workspace_name=notebook_workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], headers=_headers, params=_params, ) @@ -704,24 +764,23 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) 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 - + _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( # pylint: disable=inconsistent-return-statements + async def begin_start( self, resource_group_name: str, account_name: str, @@ -731,10 +790,12 @@ async def begin_start( # pylint: disable=inconsistent-return-statements """Starts the notebook workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param notebook_workspace_name: The name of the notebook workspace resource. + :param notebook_workspace_name: The name of the notebook workspace resource. "default" + Required. :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. @@ -746,53 +807,46 @@ async def begin_start( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, notebook_workspace_name=notebook_workspace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 0b1c277e0cdd..b6ef18ecd732 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +51,30 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """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 - :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,13 +82,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -101,10 +102,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -114,8 +113,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.DocumentDB/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.DocumentDB/operations"} # type: ignore 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 464a8c94acf9..c6f8c65e77d9 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ 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') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PartitionKeyRangeIdOperations: """ .. warning:: @@ -42,7 +51,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( self, @@ -53,53 +61,51 @@ def list_metrics( partition_key_range_id: str, filter: str, **kwargs: Any - ) -> AsyncIterable[_models.PartitionMetricListResult]: + ) -> AsyncIterable["_models.PartitionMetric"]: """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param collection_rid: Cosmos DB collection rid. + :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str - :param partition_key_range_id: Partition Key Range Id for which to get data. + :param partition_key_range_id: Partition Key Range Id for which to get data. Required. :type partition_key_range_id: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PartitionMetric or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PartitionMetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartitionMetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -107,20 +113,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -136,10 +133,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -149,8 +144,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_metrics.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/metrics"} # type: ignore + list_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/metrics"} # type: ignore 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 b54402364783..69d4d32b9c3d 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ 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') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PartitionKeyRangeIdRegionOperations: """ .. warning:: @@ -42,7 +51,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( self, @@ -54,57 +62,55 @@ def list_metrics( partition_key_range_id: str, filter: str, **kwargs: Any - ) -> AsyncIterable[_models.PartitionMetricListResult]: + ) -> AsyncIterable["_models.PartitionMetric"]: """Retrieves the metrics determined by the given filter for the given partition key range id and region. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param region: Cosmos DB region, with spaces between words and each word capitalized. + :param region: Cosmos DB region, with spaces between words and each word capitalized. Required. :type region: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param collection_rid: Cosmos DB collection rid. + :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str - :param partition_key_range_id: Partition Key Range Id for which to get data. + :param partition_key_range_id: Partition Key Range Id for which to get data. Required. :type partition_key_range_id: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PartitionMetric or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PartitionMetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartitionMetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -112,21 +118,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -142,10 +138,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -155,8 +149,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_metrics.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/metrics"} # type: ignore + list_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/metrics"} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_patch.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_patch.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 93a05a9f560e..8ee5ef1a7d75 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._percentile_operations import build_list_metrics_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PercentileOperations: """ .. warning:: @@ -42,53 +51,46 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( - self, - resource_group_name: str, - account_name: str, - filter: str, - **kwargs: Any - ) -> AsyncIterable[_models.PercentileMetricListResult]: + self, resource_group_name: str, account_name: str, filter: str, **kwargs: Any + ) -> AsyncIterable["_models.PercentileMetric"]: """Retrieves the metrics determined by the given filter for the given database account. This url is only for PBS and Replication Latency data. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PercentileMetric or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PercentileMetric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PercentileMetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PercentileMetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -96,17 +98,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -122,10 +118,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -135,8 +129,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_metrics.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/percentile/metrics"} # type: ignore + list_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/percentile/metrics"} # type: ignore 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 31671c1c4a86..27676a9b803a 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._percentile_source_target_operations import build_list_metrics_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PercentileSourceTargetOperations: """ .. warning:: @@ -42,7 +51,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( self, @@ -52,53 +60,51 @@ def list_metrics( target_region: str, filter: str, **kwargs: Any - ) -> AsyncIterable[_models.PercentileMetricListResult]: + ) -> AsyncIterable["_models.PercentileMetric"]: """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. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param source_region: Source region from which data is written. Cosmos DB region, with spaces - between words and each word capitalized. + between words and each word capitalized. Required. :type source_region: str :param target_region: Target region to which data is written. Cosmos DB region, with spaces - between words and each word capitalized. + between words and each word capitalized. Required. :type target_region: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PercentileMetric or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PercentileMetric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PercentileMetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PercentileMetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -106,19 +112,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -134,10 +132,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -147,8 +143,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_metrics.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sourceRegion/{sourceRegion}/targetRegion/{targetRegion}/percentile/metrics"} # type: ignore + list_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sourceRegion/{sourceRegion}/targetRegion/{targetRegion}/percentile/metrics"} # type: ignore 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 f7eb273eecf0..7e7c3c2c8c48 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._percentile_target_operations import build_list_metrics_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PercentileTargetOperations: """ .. warning:: @@ -42,58 +51,50 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( - self, - resource_group_name: str, - account_name: str, - target_region: str, - filter: str, - **kwargs: Any - ) -> AsyncIterable[_models.PercentileMetricListResult]: + self, resource_group_name: str, account_name: str, target_region: str, filter: str, **kwargs: Any + ) -> AsyncIterable["_models.PercentileMetric"]: """Retrieves the metrics determined by the given filter for the given account target region. This url is only for PBS and Replication Latency data. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param target_region: Target region to which data is written. Cosmos DB region, with spaces - between words and each word capitalized. + between words and each word capitalized. Required. :type target_region: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PercentileMetric or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PercentileMetric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PercentileMetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PercentileMetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -101,18 +102,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -128,10 +122,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -141,8 +133,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_metrics.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/targetRegion/{targetRegion}/percentile/metrics"} # type: ignore + list_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/targetRegion/{targetRegion}/percentile/metrics"} # type: ignore 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 c52b44121728..d76de2a383a6 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 @@ -6,10 +6,17 @@ # 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 Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,17 @@ 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') +from ...operations._private_endpoint_connections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_database_account_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateEndpointConnectionsOperations: """ .. warning:: @@ -45,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_database_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_database_account_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_database_account.metadata['url'], + template_url=self.list_by_database_account.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +102,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_database_account_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +122,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -130,52 +133,44 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_database_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections"} # type: ignore + 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, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, 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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -183,57 +178,60 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + 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, account_name: str, private_endpoint_connection_name: str, - parameters: _models.PrivateEndpointConnection, + parameters: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any ) -> Optional[_models.PrivateEndpointConnection]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -241,47 +239,52 @@ async def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: 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 - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.cosmosdb.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 @@ -294,20 +297,95 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.cosmosdb.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -316,66 +394,55 @@ async def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -383,37 +450,33 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :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. @@ -425,53 +488,46 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 533b8a425e86..b831a056cfc5 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,9 +28,11 @@ 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') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkResourcesOperations: """ .. warning:: @@ -43,46 +52,41 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_database_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateLinkResourceListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 PrivateLinkResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_database_account_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_database_account.metadata['url'], + template_url=self.list_by_database_account.metadata["url"], headers=_headers, params=_params, ) @@ -90,16 +94,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_database_account_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -115,10 +114,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -128,52 +125,44 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_database_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources"} # type: ignore + 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, - account_name: str, - group_name: str, - **kwargs: Any + self, 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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param group_name: The name of the private link resource. + :param group_name: The name of the private link resource. Required. :type group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResource, or the result of cls(response) + :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, group_name=group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -181,22 +170,20 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResource', pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources/{groupName}"} # type: ignore - + 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 08aac438ba49..ef7fcd513cf0 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +27,16 @@ 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') +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]] + class RestorableDatabaseAccountsOperations: """ .. warning:: @@ -43,44 +56,41 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_location( - self, - location: str, - **kwargs: Any - ) -> AsyncIterable[_models.RestorableDatabaseAccountsListResult]: + self, location: str, **kwargs: Any + ) -> AsyncIterable["_models.RestorableDatabaseAccountGetResult"]: """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. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :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 + :return: An iterator like instance of either RestorableDatabaseAccountGetResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableDatabaseAccountsListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableDatabaseAccountsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -88,15 +98,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -112,10 +118,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,44 +129,38 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.RestorableDatabaseAccountsListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.RestorableDatabaseAccountGetResult"]: """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 + :return: An iterator like instance of either RestorableDatabaseAccountGetResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableDatabaseAccountsListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableDatabaseAccountsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -170,14 +168,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -193,10 +188,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -206,49 +199,42 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/restorableDatabaseAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/restorableDatabaseAccounts"} # type: ignore @distributed_trace_async async def get_by_location( - self, - location: str, - instance_id: str, - **kwargs: Any + self, location: str, instance_id: str, **kwargs: Any ) -> _models.RestorableDatabaseAccountGetResult: """Retrieves the properties of an existing Azure Cosmos DB restorable database account. This call requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/read/*' permission. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :type instance_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RestorableDatabaseAccountGetResult, or the result of cls(response) + :return: RestorableDatabaseAccountGetResult or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountGetResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableDatabaseAccountGetResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableDatabaseAccountGetResult] - request = build_get_by_location_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_by_location.metadata['url'], + template_url=self.get_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -256,22 +242,20 @@ async def get_by_location( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RestorableDatabaseAccountGetResult', pipeline_response) + deserialized = self._deserialize("RestorableDatabaseAccountGetResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}"} # type: ignore - + 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_gremlin_databases_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_gremlin_databases_operations.py index 9fec2870812f..7b30acee9d6e 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_gremlin_databases_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_gremlin_databases_operations.py @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._restorable_gremlin_databases_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class RestorableGremlinDatabasesOperations: """ .. warning:: @@ -42,49 +51,45 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - location: str, - instance_id: str, - **kwargs: Any - ) -> AsyncIterable[_models.RestorableGremlinDatabasesListResult]: + self, location: str, instance_id: str, **kwargs: Any + ) -> AsyncIterable["_models.RestorableGremlinDatabaseGetResult"]: """Show the event feed of all mutations done on all the Azure Cosmos DB Gremlin databases under the restorable account. This helps in scenario where database was accidentally deleted to get the deletion time. This API requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :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 RestorableGremlinDatabasesListResult or the result + :return: An iterator like instance of either RestorableGremlinDatabaseGetResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableGremlinDatabasesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableGremlinDatabaseGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableGremlinDatabasesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableGremlinDatabasesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +97,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +117,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -130,8 +128,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableGremlinDatabases"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableGremlinDatabases"} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_gremlin_graphs_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_gremlin_graphs_operations.py index a6297419532e..eafbcd2f7884 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_gremlin_graphs_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_gremlin_graphs_operations.py @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._restorable_gremlin_graphs_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class RestorableGremlinGraphsOperations: """ .. warning:: @@ -42,7 +51,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -52,14 +60,15 @@ def list( start_time: Optional[str] = None, end_time: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.RestorableGremlinGraphsListResult]: + ) -> AsyncIterable["_models.RestorableGremlinGraphGetResult"]: """Show the event feed of all mutations done on all the Azure Cosmos DB Gremlin graphs under a specific database. This helps in scenario where container was accidentally deleted. This API requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :type instance_id: str :param restorable_gremlin_database_rid: The resource ID of the Gremlin database. Default value is None. @@ -69,34 +78,33 @@ def list( :param end_time: Restorable Gremlin graphs event feed end time. Default value is None. :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 RestorableGremlinGraphsListResult or the result of + :return: An iterator like instance of either RestorableGremlinGraphGetResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableGremlinGraphsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableGremlinGraphGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableGremlinGraphsListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableGremlinGraphsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, - api_version=api_version, + subscription_id=self._config.subscription_id, restorable_gremlin_database_rid=restorable_gremlin_database_rid, start_time=start_time, end_time=end_time, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -104,19 +112,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - restorable_gremlin_database_rid=restorable_gremlin_database_rid, - start_time=start_time, - end_time=end_time, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -132,10 +132,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -145,8 +143,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableGraphs"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableGraphs"} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_gremlin_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_gremlin_resources_operations.py index 7896e1bfc21b..0510038b1e07 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_gremlin_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_gremlin_resources_operations.py @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._restorable_gremlin_resources_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class RestorableGremlinResourcesOperations: """ .. warning:: @@ -42,7 +51,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -51,15 +59,16 @@ def list( restore_location: Optional[str] = None, restore_timestamp_in_utc: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.RestorableGremlinResourcesListResult]: + ) -> AsyncIterable["_models.RestorableGremlinResourcesGetResult"]: """Return a list of gremlin database and graphs 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 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :type instance_id: str :param restore_location: The location where the restorable resources are located. Default value is None. @@ -68,33 +77,32 @@ def list( value is None. :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 RestorableGremlinResourcesListResult or the result + :return: An iterator like instance of either RestorableGremlinResourcesGetResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableGremlinResourcesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableGremlinResourcesGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableGremlinResourcesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableGremlinResourcesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, - api_version=api_version, + subscription_id=self._config.subscription_id, restore_location=restore_location, restore_timestamp_in_utc=restore_timestamp_in_utc, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -102,18 +110,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - restore_location=restore_location, - restore_timestamp_in_utc=restore_timestamp_in_utc, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -129,10 +130,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -142,8 +141,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableGremlinResources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableGremlinResources"} # 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 1baff1421717..520cc8ba2af9 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._restorable_mongodb_collections_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class RestorableMongodbCollectionsOperations: """ .. warning:: @@ -42,7 +51,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -52,14 +60,15 @@ def list( start_time: Optional[str] = None, end_time: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.RestorableMongodbCollectionsListResult]: + ) -> AsyncIterable["_models.RestorableMongodbCollectionGetResult"]: """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. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :type instance_id: str :param restorable_mongodb_database_rid: The resource ID of the MongoDB database. Default value is None. @@ -69,34 +78,33 @@ def list( :param end_time: Restorable MongoDB collections event feed end time. Default value is None. :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 RestorableMongodbCollectionsListResult or the - result of cls(response) + :return: An iterator like instance of either RestorableMongodbCollectionGetResult or the result + of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbCollectionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbCollectionGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableMongodbCollectionsListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableMongodbCollectionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, - api_version=api_version, + subscription_id=self._config.subscription_id, restorable_mongodb_database_rid=restorable_mongodb_database_rid, start_time=start_time, end_time=end_time, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -104,19 +112,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - restorable_mongodb_database_rid=restorable_mongodb_database_rid, - start_time=start_time, - end_time=end_time, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -132,10 +132,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -145,8 +143,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbCollections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbCollections"} # type: ignore 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 392801f95643..bc1ea1cd0205 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._restorable_mongodb_databases_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class RestorableMongodbDatabasesOperations: """ .. warning:: @@ -42,49 +51,45 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - location: str, - instance_id: str, - **kwargs: Any - ) -> AsyncIterable[_models.RestorableMongodbDatabasesListResult]: + self, location: str, instance_id: str, **kwargs: Any + ) -> AsyncIterable["_models.RestorableMongodbDatabaseGetResult"]: """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 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :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 + :return: An iterator like instance of either RestorableMongodbDatabaseGetResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbDatabasesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbDatabaseGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableMongodbDatabasesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableMongodbDatabasesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +97,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +117,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -130,8 +128,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbDatabases"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbDatabases"} # type: ignore 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 6b38457cb690..45305033844c 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._restorable_mongodb_resources_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class RestorableMongodbResourcesOperations: """ .. warning:: @@ -42,7 +51,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -51,15 +59,16 @@ def list( restore_location: Optional[str] = None, restore_timestamp_in_utc: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.RestorableMongodbResourcesListResult]: + ) -> AsyncIterable["_models.RestorableMongodbResourcesGetResult"]: """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 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :type instance_id: str :param restore_location: The location where the restorable resources are located. Default value is None. @@ -68,33 +77,32 @@ def list( value is None. :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 + :return: An iterator like instance of either RestorableMongodbResourcesGetResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbResourcesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbResourcesGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableMongodbResourcesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableMongodbResourcesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, - api_version=api_version, + subscription_id=self._config.subscription_id, restore_location=restore_location, restore_timestamp_in_utc=restore_timestamp_in_utc, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -102,18 +110,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - restore_location=restore_location, - restore_timestamp_in_utc=restore_timestamp_in_utc, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -129,10 +130,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -142,8 +141,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbResources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbResources"} # type: ignore 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 49d158f8a1f6..9a4eb0d852ac 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._restorable_sql_containers_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class RestorableSqlContainersOperations: """ .. warning:: @@ -42,7 +51,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -52,14 +60,15 @@ def list( start_time: Optional[str] = None, end_time: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.RestorableSqlContainersListResult]: + ) -> AsyncIterable["_models.RestorableSqlContainerGetResult"]: """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. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :type instance_id: str :param restorable_sql_database_rid: The resource ID of the SQL database. Default value is None. :type restorable_sql_database_rid: str @@ -68,34 +77,33 @@ def list( :param end_time: Restorable Sql containers event feed end time. Default value is None. :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 + :return: An iterator like instance of either RestorableSqlContainerGetResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlContainersListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlContainerGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableSqlContainersListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableSqlContainersListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, - api_version=api_version, + subscription_id=self._config.subscription_id, restorable_sql_database_rid=restorable_sql_database_rid, start_time=start_time, end_time=end_time, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -103,19 +111,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - restorable_sql_database_rid=restorable_sql_database_rid, - start_time=start_time, - end_time=end_time, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -131,10 +131,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -144,8 +142,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlContainers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlContainers"} # type: ignore 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 f0cce17b575b..0b52bc78cb34 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._restorable_sql_databases_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class RestorableSqlDatabasesOperations: """ .. warning:: @@ -42,49 +51,45 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - location: str, - instance_id: str, - **kwargs: Any - ) -> AsyncIterable[_models.RestorableSqlDatabasesListResult]: + self, location: str, instance_id: str, **kwargs: Any + ) -> AsyncIterable["_models.RestorableSqlDatabaseGetResult"]: """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 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :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 + :return: An iterator like instance of either RestorableSqlDatabaseGetResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlDatabasesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlDatabaseGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableSqlDatabasesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableSqlDatabasesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +97,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +117,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -130,8 +128,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlDatabases"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlDatabases"} # type: ignore 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 d28ae757a5b8..20f7b2950e1b 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 @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._restorable_sql_resources_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class RestorableSqlResourcesOperations: """ .. warning:: @@ -42,7 +51,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -51,15 +59,16 @@ def list( restore_location: Optional[str] = None, restore_timestamp_in_utc: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.RestorableSqlResourcesListResult]: + ) -> AsyncIterable["_models.RestorableSqlResourcesGetResult"]: """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 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :type instance_id: str :param restore_location: The location where the restorable resources are located. Default value is None. @@ -68,33 +77,32 @@ def list( value is None. :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 + :return: An iterator like instance of either RestorableSqlResourcesGetResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlResourcesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlResourcesGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableSqlResourcesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableSqlResourcesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, - api_version=api_version, + subscription_id=self._config.subscription_id, restore_location=restore_location, restore_timestamp_in_utc=restore_timestamp_in_utc, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -102,18 +110,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - restore_location=restore_location, - restore_timestamp_in_utc=restore_timestamp_in_utc, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -129,10 +130,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -142,8 +141,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlResources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlResources"} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_table_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_table_resources_operations.py index 0fb25c3b87ae..50360343ddc8 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_table_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_table_resources_operations.py @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._restorable_table_resources_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class RestorableTableResourcesOperations: """ .. warning:: @@ -42,7 +51,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -51,14 +59,15 @@ def list( restore_location: Optional[str] = None, restore_timestamp_in_utc: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.RestorableTableResourcesListResult]: + ) -> AsyncIterable["_models.RestorableTableResourcesGetResult"]: """Return a list of tables 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 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :type instance_id: str :param restore_location: The location where the restorable resources are located. Default value is None. @@ -67,33 +76,32 @@ def list( value is None. :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 RestorableTableResourcesListResult or the result - of cls(response) + :return: An iterator like instance of either RestorableTableResourcesGetResult or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableTableResourcesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableTableResourcesGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableTableResourcesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableTableResourcesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, - api_version=api_version, + subscription_id=self._config.subscription_id, restore_location=restore_location, restore_timestamp_in_utc=restore_timestamp_in_utc, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -101,18 +109,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - restore_location=restore_location, - restore_timestamp_in_utc=restore_timestamp_in_utc, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -128,10 +129,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -141,8 +140,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableTableResources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableTableResources"} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_tables_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_tables_operations.py index b424439e76f7..e4e90b7089be 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_tables_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_restorable_tables_operations.py @@ -7,9 +7,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +27,11 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._restorable_tables_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class RestorableTablesOperations: """ .. warning:: @@ -42,7 +51,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -51,47 +59,47 @@ def list( start_time: Optional[str] = None, end_time: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.RestorableTablesListResult]: + ) -> AsyncIterable["_models.RestorableTableGetResult"]: """Show the event feed of all mutations done on all the Azure Cosmos DB Tables. This helps in scenario where table was accidentally deleted. This API requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :type instance_id: str :param start_time: Restorable Tables event feed start time. Default value is None. :type start_time: str :param end_time: Restorable Tables event feed end time. Default value is None. :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 RestorableTablesListResult or the result of + :return: An iterator like instance of either RestorableTableGetResult or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableTablesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.RestorableTableGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableTablesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableTablesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, - api_version=api_version, + subscription_id=self._config.subscription_id, start_time=start_time, end_time=end_time, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -99,18 +107,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - start_time=start_time, - end_time=end_time, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -126,10 +127,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -139,8 +138,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableTables"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableTables"} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_service_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_service_operations.py index cb547be235f0..57e3c8b30ffc 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_service_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/aio/operations/_service_operations.py @@ -6,10 +6,17 @@ # 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 Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,17 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._service_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._service_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ServiceOperations: """ .. warning:: @@ -45,46 +59,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ServiceResourceListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ServiceResource"]: """Gets the status of service. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 ServiceResourceListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.ServiceResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ServiceResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +100,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +120,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -130,43 +131,46 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, service_name: str, - create_update_parameters: _models.ServiceResourceCreateUpdateParameters, + create_update_parameters: Union[_models.ServiceResourceCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ServiceResource]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ServiceResource]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ServiceResource]] - _json = self._serialize.body(create_update_parameters, 'ServiceResourceCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_parameters, (IO, bytes)): + _content = create_update_parameters + else: + _json = self._serialize.body(create_update_parameters, "ServiceResourceCreateUpdateParameters") - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -174,10 +178,9 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -186,36 +189,80 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, account_name: str, service_name: str, create_update_parameters: _models.ServiceResourceCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ServiceResource]: """Creates a service. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param service_name: Cosmos DB service name. + :param service_name: Cosmos DB service name. Required. :type service_name: str - :param create_update_parameters: The Service resource parameters. + :param create_update_parameters: The Service resource parameters. Required. :type create_update_parameters: ~azure.mgmt.cosmosdb.models.ServiceResourceCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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 ServiceResource or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + service_name: str, + create_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Creates a service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param service_name: Cosmos DB service name. Required. + :type service_name: str + :param create_update_parameters: The Service resource parameters. Required. + :type create_update_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -227,20 +274,56 @@ async def begin_create( :return: An instance of AsyncLROPoller that returns either ServiceResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + service_name: str, + create_update_parameters: Union[_models.ServiceResourceCreateUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ServiceResource]: + """Creates a service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param service_name: Cosmos DB service name. Required. + :type service_name: str + :param create_update_parameters: The Service resource parameters. Is either a model type or a + IO type. Required. + :type create_update_parameters: + ~azure.mgmt.cosmosdb.models.ServiceResourceCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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 ServiceResource or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceResource] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -249,80 +332,70 @@ async def begin_create( create_update_parameters=create_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, service_name: str, **kwargs: Any ) -> _models.ServiceResource: """Gets the status of service. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param service_name: Cosmos DB service name. + :param service_name: Cosmos DB service name. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceResource, or the result of cls(response) + :return: ServiceResource or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -330,52 +403,43 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, service_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -383,10 +447,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -396,24 +459,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - service_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, account_name: str, service_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes service with the given serviceName. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param service_name: Cosmos DB service name. + :param service_name: Cosmos DB service name. Required. :type service_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. @@ -425,53 +484,46 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, service_name=service_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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}/services/{serviceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}"} # type: ignore 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 daeb847e8a96..4e96f89eda3c 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 @@ -6,10 +6,17 @@ # 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 Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,56 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._sql_resources_operations import build_create_update_client_encryption_key_request_initial, 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_client_encryption_key_request, 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_client_encryption_keys_request, build_list_sql_container_partition_merge_request_initial, 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_sql_container_redistribute_throughput_request_initial, build_sql_container_retrieve_throughput_distribution_request_initial, build_update_sql_container_throughput_request_initial, build_update_sql_database_throughput_request_initial -T = TypeVar('T') +from ...operations._sql_resources_operations import ( + build_create_update_client_encryption_key_request, + build_create_update_sql_container_request, + build_create_update_sql_database_request, + build_create_update_sql_role_assignment_request, + build_create_update_sql_role_definition_request, + build_create_update_sql_stored_procedure_request, + build_create_update_sql_trigger_request, + build_create_update_sql_user_defined_function_request, + build_delete_sql_container_request, + build_delete_sql_database_request, + build_delete_sql_role_assignment_request, + build_delete_sql_role_definition_request, + build_delete_sql_stored_procedure_request, + build_delete_sql_trigger_request, + build_delete_sql_user_defined_function_request, + build_get_client_encryption_key_request, + 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_client_encryption_keys_request, + build_list_sql_container_partition_merge_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, + build_migrate_sql_container_to_manual_throughput_request, + build_migrate_sql_database_to_autoscale_request, + build_migrate_sql_database_to_manual_throughput_request, + build_retrieve_continuous_backup_information_request, + build_sql_container_redistribute_throughput_request, + build_sql_container_retrieve_throughput_distribution_request, + build_update_sql_container_throughput_request, + build_update_sql_database_throughput_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SqlResourcesOperations: # pylint: disable=too-many-public-methods """ .. warning:: @@ -45,46 +98,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_sql_databases( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SqlDatabaseListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SqlDatabaseGetResults"]: """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 + :return: An iterator like instance of either SqlDatabaseGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlDatabaseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlDatabaseGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlDatabaseListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlDatabaseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_sql_databases_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_sql_databases.metadata['url'], + template_url=self.list_sql_databases.metadata["url"], headers=_headers, params=_params, ) @@ -92,16 +141,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_sql_databases_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -117,10 +161,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -130,53 +172,45 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_sql_databases.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases"} # type: ignore + 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, - account_name: str, - database_name: str, - **kwargs: Any + self, 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. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlDatabaseGetResults, or the result of cls(response) + :return: SqlDatabaseGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.SqlDatabaseGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlDatabaseGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlDatabaseGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_sql_database.metadata['url'], + template_url=self.get_sql_database.metadata["url"], headers=_headers, params=_params, ) @@ -184,57 +218,60 @@ async def get_sql_database( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SqlDatabaseGetResults', pipeline_response) + deserialized = self._deserialize("SqlDatabaseGetResults", pipeline_response) if cls: 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 - + 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, account_name: str, database_name: str, - create_update_sql_database_parameters: _models.SqlDatabaseCreateUpdateParameters, + create_update_sql_database_parameters: Union[_models.SqlDatabaseCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.SqlDatabaseGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SqlDatabaseGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SqlDatabaseGetResults]] - _json = self._serialize.body(create_update_sql_database_parameters, 'SqlDatabaseCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_sql_database_parameters, (IO, bytes)): + _content = create_update_sql_database_parameters + else: + _json = self._serialize.body(create_update_sql_database_parameters, "SqlDatabaseCreateUpdateParameters") - request = build_create_update_sql_database_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_sql_database_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_sql_database_initial.metadata['url'], + content=_content, + template_url=self._create_update_sql_database_initial.metadata["url"], headers=_headers, params=_params, ) @@ -242,10 +279,9 @@ async def _create_update_sql_database_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -254,37 +290,121 @@ async def _create_update_sql_database_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SqlDatabaseGetResults', pipeline_response) + deserialized = self._deserialize("SqlDatabaseGetResults", pipeline_response) if cls: 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 - + _create_update_sql_database_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_update_sql_database( self, resource_group_name: str, account_name: str, database_name: str, create_update_sql_database_parameters: _models.SqlDatabaseCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :param create_update_sql_database_parameters: The parameters to provide for the current SQL - database. + database. Required. :type create_update_sql_database_parameters: ~azure.mgmt.cosmosdb.models.SqlDatabaseCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlDatabaseGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_update_sql_database( + self, + resource_group_name: str, + account_name: str, + database_name: str, + create_update_sql_database_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param create_update_sql_database_parameters: The parameters to provide for the current SQL + database. Required. + :type create_update_sql_database_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlDatabaseGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_update_sql_database( + self, + resource_group_name: str, + account_name: str, + database_name: str, + create_update_sql_database_parameters: Union[_models.SqlDatabaseCreateUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param create_update_sql_database_parameters: The parameters to provide for the current SQL + database. Is either a model type or a IO type. Required. + :type create_update_sql_database_parameters: + ~azure.mgmt.cosmosdb.models.SqlDatabaseCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -296,20 +416,17 @@ async def begin_create_update_sql_database( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlDatabaseGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlDatabaseGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_update_sql_database_initial( # type: ignore resource_group_name=resource_group_name, @@ -318,66 +435,55 @@ async def begin_create_update_sql_database( create_update_sql_database_parameters=create_update_sql_database_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SqlDatabaseGetResults', pipeline_response) + deserialized = self._deserialize("SqlDatabaseGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_sql_database_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_sql_database_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_sql_database_initial.metadata['url'], + template_url=self._delete_sql_database_initial.metadata["url"], headers=_headers, params=_params, ) @@ -385,10 +491,9 @@ async def _delete_sql_database_initial( # pylint: disable=inconsistent-return-s request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -398,24 +503,20 @@ async def _delete_sql_database_initial( # pylint: disable=inconsistent-return-s if cls: return cls(pipeline_response, None, {}) - _delete_sql_database_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + async def begin_delete_sql_database( + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Azure Cosmos DB SQL database. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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. @@ -427,98 +528,85 @@ async def begin_delete_sql_database( # pylint: disable=inconsistent-return-stat 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_sql_database_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: """Gets the RUs per second of the SQL database under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ThroughputSettingsGetResults, or the result of cls(response) + :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_sql_database_throughput.metadata['url'], + template_url=self.get_sql_database_throughput.metadata["url"], headers=_headers, params=_params, ) @@ -526,57 +614,60 @@ async def get_sql_database_throughput( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + 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, account_name: str, database_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IO, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - request = build_update_sql_database_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_sql_database_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_sql_database_throughput_initial.metadata['url'], + content=_content, + template_url=self._update_sql_database_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -584,10 +675,9 @@ async def _update_sql_database_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -596,37 +686,123 @@ async def _update_sql_database_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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 + @overload async def begin_update_sql_database_throughput( self, resource_group_name: str, account_name: str, database_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Update RUs per second of an Azure Cosmos DB SQL database. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current SQL database. + current SQL database. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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: + """ + + @overload + async def begin_update_sql_database_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + update_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB SQL database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current SQL database. Required. + :type update_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_update_sql_database_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB SQL database. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current SQL database. Is either a model type or a IO type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -639,20 +815,17 @@ async def begin_update_sql_database_throughput( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._update_sql_database_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -661,66 +834,55 @@ async def begin_update_sql_database_throughput( update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_sql_database_to_autoscale_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_sql_database_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_sql_database_to_autoscale_initial.metadata['url'], + template_url=self._migrate_sql_database_to_autoscale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -728,10 +890,9 @@ async def _migrate_sql_database_to_autoscale_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -740,31 +901,27 @@ async def _migrate_sql_database_to_autoscale_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB SQL database from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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. @@ -778,85 +935,71 @@ async def begin_migrate_sql_database_to_autoscale( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._migrate_sql_database_to_autoscale_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_sql_database_to_manual_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_sql_database_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_sql_database_to_manual_throughput_initial.metadata['url'], + template_url=self._migrate_sql_database_to_manual_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -864,10 +1007,9 @@ async def _migrate_sql_database_to_manual_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -876,31 +1018,27 @@ async def _migrate_sql_database_to_manual_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB SQL database from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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. @@ -914,102 +1052,91 @@ async def begin_migrate_sql_database_to_manual_throughput( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._migrate_sql_database_to_manual_throughput_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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_client_encryption_keys( - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ClientEncryptionKeysListResult]: + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ClientEncryptionKeyGetResults"]: """Lists the ClientEncryptionKeys under an existing Azure Cosmos DB SQL database. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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 ClientEncryptionKeysListResult or the result of + :return: An iterator like instance of either ClientEncryptionKeyGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.ClientEncryptionKeysListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ClientEncryptionKeysListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClientEncryptionKeysListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_client_encryption_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_client_encryption_keys.metadata['url'], + template_url=self.list_client_encryption_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1017,17 +1144,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_client_encryption_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1043,10 +1164,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1056,11 +1175,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_client_encryption_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys"} # type: ignore + list_client_encryption_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys"} # type: ignore @distributed_trace_async async def get_client_encryption_key( @@ -1074,38 +1191,36 @@ async def get_client_encryption_key( """Gets the ClientEncryptionKey under an existing Azure Cosmos DB SQL database. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. + :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. :type client_encryption_key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ClientEncryptionKeyGetResults, or the result of cls(response) + :return: ClientEncryptionKeyGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ClientEncryptionKeyGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClientEncryptionKeyGetResults] - request = build_get_client_encryption_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, client_encryption_key_name=client_encryption_key_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_client_encryption_key.metadata['url'], + template_url=self.get_client_encryption_key.metadata["url"], headers=_headers, params=_params, ) @@ -1113,25 +1228,23 @@ async def get_client_encryption_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ClientEncryptionKeyGetResults', pipeline_response) + deserialized = self._deserialize("ClientEncryptionKeyGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_client_encryption_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys/{clientEncryptionKeyName}"} # type: ignore - + get_client_encryption_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys/{clientEncryptionKeyName}"} # type: ignore async def _create_update_client_encryption_key_initial( self, @@ -1139,33 +1252,40 @@ async def _create_update_client_encryption_key_initial( account_name: str, database_name: str, client_encryption_key_name: str, - create_update_client_encryption_key_parameters: _models.ClientEncryptionKeyCreateUpdateParameters, + create_update_client_encryption_key_parameters: Union[_models.ClientEncryptionKeyCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ClientEncryptionKeyGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ClientEncryptionKeyGetResults]] - - _json = self._serialize.body(create_update_client_encryption_key_parameters, 'ClientEncryptionKeyCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ClientEncryptionKeyGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_client_encryption_key_parameters, (IO, bytes)): + _content = create_update_client_encryption_key_parameters + else: + _json = self._serialize.body( + create_update_client_encryption_key_parameters, "ClientEncryptionKeyCreateUpdateParameters" + ) - request = build_create_update_client_encryption_key_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_client_encryption_key_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, client_encryption_key_name=client_encryption_key_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_client_encryption_key_initial.metadata['url'], + content=_content, + template_url=self._create_update_client_encryption_key_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1173,10 +1293,9 @@ async def _create_update_client_encryption_key_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1185,17 +1304,16 @@ async def _create_update_client_encryption_key_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ClientEncryptionKeyGetResults', pipeline_response) + deserialized = self._deserialize("ClientEncryptionKeyGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_update_client_encryption_key_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys/{clientEncryptionKeyName}"} # type: ignore + _create_update_client_encryption_key_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys/{clientEncryptionKeyName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_update_client_encryption_key( self, resource_group_name: str, @@ -1203,23 +1321,29 @@ async def begin_create_update_client_encryption_key( database_name: str, client_encryption_key_name: str, create_update_client_encryption_key_parameters: _models.ClientEncryptionKeyCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ClientEncryptionKeyGetResults]: """Create or update a ClientEncryptionKey. This API is meant to be invoked via tools such as the Azure Powershell (instead of directly). :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. + :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. :type client_encryption_key_name: str :param create_update_client_encryption_key_parameters: The parameters to provide for the client - encryption key. + encryption key. Required. :type create_update_client_encryption_key_parameters: ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :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 @@ -1232,20 +1356,106 @@ async def begin_create_update_client_encryption_key( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ClientEncryptionKeyGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + @overload + async def begin_create_update_client_encryption_key( + self, + resource_group_name: str, + account_name: str, + database_name: str, + client_encryption_key_name: str, + create_update_client_encryption_key_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ClientEncryptionKeyGetResults]: + """Create or update a ClientEncryptionKey. This API is meant to be invoked via tools such as the + Azure Powershell (instead of directly). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. + :type client_encryption_key_name: str + :param create_update_client_encryption_key_parameters: The parameters to provide for the client + encryption key. Required. + :type create_update_client_encryption_key_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 ClientEncryptionKeyGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_update_client_encryption_key( + self, + resource_group_name: str, + account_name: str, + database_name: str, + client_encryption_key_name: str, + create_update_client_encryption_key_parameters: Union[_models.ClientEncryptionKeyCreateUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ClientEncryptionKeyGetResults]: + """Create or update a ClientEncryptionKey. This API is meant to be invoked via tools such as the + Azure Powershell (instead of directly). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. + :type client_encryption_key_name: str + :param create_update_client_encryption_key_parameters: The parameters to provide for the client + encryption key. Is either a model type or a IO type. Required. + :type create_update_client_encryption_key_parameters: + ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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 ClientEncryptionKeyGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClientEncryptionKeyGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_update_client_encryption_key_initial( # type: ignore resource_group_name=resource_group_name, @@ -1255,83 +1465,75 @@ async def begin_create_update_client_encryption_key( create_update_client_encryption_key_parameters=create_update_client_encryption_key_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ClientEncryptionKeyGetResults', pipeline_response) + deserialized = self._deserialize("ClientEncryptionKeyGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_update_client_encryption_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys/{clientEncryptionKeyName}"} # type: ignore + begin_create_update_client_encryption_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys/{clientEncryptionKeyName}"} # type: ignore @distributed_trace def list_sql_containers( - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SqlContainerListResult]: + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SqlContainerGetResults"]: """Lists the SQL container under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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 + :return: An iterator like instance of either SqlContainerGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlContainerListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlContainerGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlContainerListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlContainerListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_sql_containers.metadata['url'], + template_url=self.list_sql_containers.metadata["url"], headers=_headers, params=_params, ) @@ -1339,17 +1541,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1365,10 +1561,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1378,56 +1572,47 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + 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, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any + self, 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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlContainerGetResults, or the result of cls(response) + :return: SqlContainerGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.SqlContainerGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlContainerGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlContainerGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_sql_container.metadata['url'], + template_url=self.get_sql_container.metadata["url"], headers=_headers, params=_params, ) @@ -1435,25 +1620,23 @@ async def get_sql_container( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SqlContainerGetResults', pipeline_response) + deserialized = self._deserialize("SqlContainerGetResults", pipeline_response) if cls: 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 - + 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, @@ -1461,33 +1644,38 @@ async def _create_update_sql_container_initial( account_name: str, database_name: str, container_name: str, - create_update_sql_container_parameters: _models.SqlContainerCreateUpdateParameters, + create_update_sql_container_parameters: Union[_models.SqlContainerCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.SqlContainerGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SqlContainerGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SqlContainerGetResults]] - _json = self._serialize.body(create_update_sql_container_parameters, 'SqlContainerCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_sql_container_parameters, (IO, bytes)): + _content = create_update_sql_container_parameters + else: + _json = self._serialize.body(create_update_sql_container_parameters, "SqlContainerCreateUpdateParameters") - request = build_create_update_sql_container_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_sql_container_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_sql_container_initial.metadata['url'], + content=_content, + template_url=self._create_update_sql_container_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1495,10 +1683,9 @@ async def _create_update_sql_container_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1507,17 +1694,16 @@ async def _create_update_sql_container_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SqlContainerGetResults', pipeline_response) + deserialized = self._deserialize("SqlContainerGetResults", pipeline_response) if cls: 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 + _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 + @overload async def begin_create_update_sql_container( self, resource_group_name: str, @@ -1525,22 +1711,28 @@ async def begin_create_update_sql_container( database_name: str, container_name: str, create_update_sql_container_parameters: _models.SqlContainerCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str :param create_update_sql_container_parameters: The parameters to provide for the current SQL - container. + container. Required. :type create_update_sql_container_parameters: ~azure.mgmt.cosmosdb.models.SqlContainerCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 @@ -1552,20 +1744,102 @@ async def begin_create_update_sql_container( :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: + """ + + @overload + async def begin_create_update_sql_container( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + create_update_sql_container_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param create_update_sql_container_parameters: The parameters to provide for the current SQL + container. Required. + :type create_update_sql_container_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlContainerGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_update_sql_container( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + create_update_sql_container_parameters: Union[_models.SqlContainerCreateUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param create_update_sql_container_parameters: The parameters to provide for the current SQL + container. Is either a model type or a IO type. Required. + :type create_update_sql_container_parameters: + ~azure.mgmt.cosmosdb.models.SqlContainerCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlContainerGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlContainerGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlContainerGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_update_sql_container_initial( # type: ignore resource_group_name=resource_group_name, @@ -1575,68 +1849,56 @@ async def begin_create_update_sql_container( create_update_sql_container_parameters=create_update_sql_container_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SqlContainerGetResults', pipeline_response) + deserialized = self._deserialize("SqlContainerGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_sql_container_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_sql_container_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_sql_container_initial.metadata['url'], + template_url=self._delete_sql_container_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1644,10 +1906,9 @@ async def _delete_sql_container_initial( # pylint: disable=inconsistent-return- request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1657,27 +1918,22 @@ async def _delete_sql_container_initial( # pylint: disable=inconsistent-return- if cls: return cls(pipeline_response, None, {}) - _delete_sql_container_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any + async def begin_delete_sql_container( + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :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. @@ -1689,19 +1945,16 @@ async def begin_delete_sql_container( # pylint: disable=inconsistent-return-sta 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_sql_container_initial( # type: ignore resource_group_name=resource_group_name, @@ -1709,37 +1962,33 @@ async def begin_delete_sql_container( # pylint: disable=inconsistent-return-sta database_name=database_name, container_name=container_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_delete_sql_container.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}"} # type: ignore async def _list_sql_container_partition_merge_initial( self, @@ -1747,33 +1996,38 @@ async def _list_sql_container_partition_merge_initial( account_name: str, database_name: str, container_name: str, - merge_parameters: _models.MergeParameters, + merge_parameters: Union[_models.MergeParameters, IO], **kwargs: Any ) -> Optional[_models.PhysicalPartitionStorageInfoCollection]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PhysicalPartitionStorageInfoCollection]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PhysicalPartitionStorageInfoCollection]] - _json = self._serialize.body(merge_parameters, 'MergeParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(merge_parameters, (IO, bytes)): + _content = merge_parameters + else: + _json = self._serialize.body(merge_parameters, "MergeParameters") - request = build_list_sql_container_partition_merge_request_initial( - subscription_id=self._config.subscription_id, + request = build_list_sql_container_partition_merge_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._list_sql_container_partition_merge_initial.metadata['url'], + content=_content, + template_url=self._list_sql_container_partition_merge_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1781,10 +2035,9 @@ async def _list_sql_container_partition_merge_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1793,17 +2046,16 @@ async def _list_sql_container_partition_merge_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PhysicalPartitionStorageInfoCollection', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionStorageInfoCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _list_sql_container_partition_merge_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/partitionMerge"} # type: ignore - + _list_sql_container_partition_merge_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/partitionMerge"} # type: ignore - @distributed_trace_async + @overload async def begin_list_sql_container_partition_merge( self, resource_group_name: str, @@ -1811,20 +2063,111 @@ async def begin_list_sql_container_partition_merge( database_name: str, container_name: str, merge_parameters: _models.MergeParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: """Merges the partitions of a SQL Container. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param merge_parameters: The parameters for the merge operation. + :param merge_parameters: The parameters for the merge operation. Required. :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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 + PhysicalPartitionStorageInfoCollection or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_list_sql_container_partition_merge( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + merge_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: + """Merges the partitions of a SQL Container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param merge_parameters: The parameters for the merge operation. Required. + :type merge_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 + PhysicalPartitionStorageInfoCollection or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_list_sql_container_partition_merge( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + merge_parameters: Union[_models.MergeParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionStorageInfoCollection]: + """Merges the partitions of a SQL Container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param merge_parameters: The parameters for the merge operation. Is either a model type or a IO + type. Required. + :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -1837,20 +2180,17 @@ async def begin_list_sql_container_partition_merge( PhysicalPartitionStorageInfoCollection or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PhysicalPartitionStorageInfoCollection] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhysicalPartitionStorageInfoCollection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._list_sql_container_partition_merge_initial( # type: ignore resource_group_name=resource_group_name, @@ -1860,85 +2200,76 @@ async def begin_list_sql_container_partition_merge( merge_parameters=merge_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PhysicalPartitionStorageInfoCollection', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionStorageInfoCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_list_sql_container_partition_merge.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/partitionMerge"} # type: ignore + begin_list_sql_container_partition_merge.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/partitionMerge"} # type: ignore @distributed_trace_async async def get_sql_container_throughput( - self, - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: """Gets the RUs per second of the SQL container under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ThroughputSettingsGetResults, or the result of cls(response) + :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_sql_container_throughput.metadata['url'], + template_url=self.get_sql_container_throughput.metadata["url"], headers=_headers, params=_params, ) @@ -1946,25 +2277,23 @@ async def get_sql_container_throughput( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + 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, @@ -1972,33 +2301,38 @@ async def _update_sql_container_throughput_initial( account_name: str, database_name: str, container_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IO, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - request = build_update_sql_container_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_sql_container_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_sql_container_throughput_initial.metadata['url'], + content=_content, + template_url=self._update_sql_container_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2006,10 +2340,9 @@ async def _update_sql_container_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2018,17 +2351,16 @@ async def _update_sql_container_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 + _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 + @overload async def begin_update_sql_container_throughput( self, resource_group_name: str, @@ -2036,22 +2368,28 @@ async def begin_update_sql_container_throughput( database_name: str, container_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Update RUs per second of an Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current SQL container. + current SQL container. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :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 @@ -2064,20 +2402,104 @@ async def begin_update_sql_container_throughput( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_sql_container_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + update_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB SQL container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current SQL container. Required. + :type update_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_update_sql_container_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB SQL container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current SQL container. Is either a model type or a IO type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._update_sql_container_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -2087,68 +2509,56 @@ async def begin_update_sql_container_throughput( update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( - self, - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_sql_container_to_autoscale_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_sql_container_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_sql_container_to_autoscale_initial.metadata['url'], + template_url=self._migrate_sql_container_to_autoscale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2156,10 +2566,9 @@ async def _migrate_sql_container_to_autoscale_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2168,34 +2577,29 @@ async def _migrate_sql_container_to_autoscale_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB SQL container from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :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. @@ -2209,19 +2613,16 @@ async def begin_migrate_sql_container_to_autoscale( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._migrate_sql_container_to_autoscale_initial( # type: ignore resource_group_name=resource_group_name, @@ -2229,68 +2630,56 @@ async def begin_migrate_sql_container_to_autoscale( database_name=database_name, container_name=container_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( - self, - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_sql_container_to_manual_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_sql_container_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_sql_container_to_manual_throughput_initial.metadata['url'], + template_url=self._migrate_sql_container_to_manual_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2298,10 +2687,9 @@ async def _migrate_sql_container_to_manual_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2310,34 +2698,29 @@ async def _migrate_sql_container_to_manual_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any + @distributed_trace_async + async def begin_migrate_sql_container_to_manual_throughput( + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB SQL container from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :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. @@ -2351,19 +2734,16 @@ async def begin_migrate_sql_container_to_manual_throughput( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._migrate_sql_container_to_manual_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -2371,39 +2751,35 @@ async def begin_migrate_sql_container_to_manual_throughput( database_name=database_name, container_name=container_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 async def _sql_container_retrieve_throughput_distribution_initial( self, @@ -2411,33 +2787,38 @@ async def _sql_container_retrieve_throughput_distribution_initial( account_name: str, database_name: str, container_name: str, - retrieve_throughput_parameters: _models.RetrieveThroughputParameters, + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO], **kwargs: Any ) -> Optional[_models.PhysicalPartitionThroughputInfoResult]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PhysicalPartitionThroughputInfoResult]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PhysicalPartitionThroughputInfoResult]] - _json = self._serialize.body(retrieve_throughput_parameters, 'RetrieveThroughputParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(retrieve_throughput_parameters, (IO, bytes)): + _content = retrieve_throughput_parameters + else: + _json = self._serialize.body(retrieve_throughput_parameters, "RetrieveThroughputParameters") - request = build_sql_container_retrieve_throughput_distribution_request_initial( - subscription_id=self._config.subscription_id, + request = build_sql_container_retrieve_throughput_distribution_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._sql_container_retrieve_throughput_distribution_initial.metadata['url'], + content=_content, + template_url=self._sql_container_retrieve_throughput_distribution_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2445,10 +2826,9 @@ async def _sql_container_retrieve_throughput_distribution_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2457,15 +2837,102 @@ async def _sql_container_retrieve_throughput_distribution_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PhysicalPartitionThroughputInfoResult', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _sql_container_retrieve_throughput_distribution_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/retrieveThroughputDistribution"} # type: ignore + _sql_container_retrieve_throughput_distribution_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/retrieveThroughputDistribution"} # type: ignore + + @overload + async def begin_sql_container_retrieve_throughput_distribution( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + retrieve_throughput_parameters: _models.RetrieveThroughputParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB SQL container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current SQL container. Required. + :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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 + PhysicalPartitionThroughputInfoResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_sql_container_retrieve_throughput_distribution( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + retrieve_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB SQL container. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current SQL container. Required. + :type retrieve_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 + PhysicalPartitionThroughputInfoResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_sql_container_retrieve_throughput_distribution( @@ -2474,22 +2941,27 @@ async def begin_sql_container_retrieve_throughput_distribution( account_name: str, database_name: str, container_name: str, - retrieve_throughput_parameters: _models.RetrieveThroughputParameters, + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO], **kwargs: Any ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: """Retrieve throughput distribution for an Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current SQL container. + distribution for the current SQL container. Is either a model type or a IO type. Required. :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -2502,20 +2974,17 @@ async def begin_sql_container_retrieve_throughput_distribution( PhysicalPartitionThroughputInfoResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PhysicalPartitionThroughputInfoResult] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhysicalPartitionThroughputInfoResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._sql_container_retrieve_throughput_distribution_initial( # type: ignore resource_group_name=resource_group_name, @@ -2525,39 +2994,37 @@ async def begin_sql_container_retrieve_throughput_distribution( retrieve_throughput_parameters=retrieve_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PhysicalPartitionThroughputInfoResult', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_sql_container_retrieve_throughput_distribution.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/retrieveThroughputDistribution"} # type: ignore + begin_sql_container_retrieve_throughput_distribution.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/retrieveThroughputDistribution"} # type: ignore async def _sql_container_redistribute_throughput_initial( self, @@ -2565,33 +3032,38 @@ async def _sql_container_redistribute_throughput_initial( account_name: str, database_name: str, container_name: str, - redistribute_throughput_parameters: _models.RedistributeThroughputParameters, + redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO], **kwargs: Any ) -> Optional[_models.PhysicalPartitionThroughputInfoResult]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PhysicalPartitionThroughputInfoResult]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PhysicalPartitionThroughputInfoResult]] - _json = self._serialize.body(redistribute_throughput_parameters, 'RedistributeThroughputParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(redistribute_throughput_parameters, (IO, bytes)): + _content = redistribute_throughput_parameters + else: + _json = self._serialize.body(redistribute_throughput_parameters, "RedistributeThroughputParameters") - request = build_sql_container_redistribute_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_sql_container_redistribute_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._sql_container_redistribute_throughput_initial.metadata['url'], + content=_content, + template_url=self._sql_container_redistribute_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2599,10 +3071,9 @@ async def _sql_container_redistribute_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2611,17 +3082,16 @@ async def _sql_container_redistribute_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PhysicalPartitionThroughputInfoResult', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _sql_container_redistribute_throughput_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/redistributeThroughput"} # type: ignore + _sql_container_redistribute_throughput_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/redistributeThroughput"} # type: ignore - - @distributed_trace_async + @overload async def begin_sql_container_redistribute_throughput( self, resource_group_name: str, @@ -2629,22 +3099,115 @@ async def begin_sql_container_redistribute_throughput( database_name: str, container_name: str, redistribute_throughput_parameters: _models.RedistributeThroughputParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: """Redistribute throughput for an Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current SQL container. + throughput for the current SQL container. Required. :type redistribute_throughput_parameters: ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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 + PhysicalPartitionThroughputInfoResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_sql_container_redistribute_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + redistribute_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Redistribute throughput for an Azure Cosmos DB SQL container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current SQL container. Required. + :type redistribute_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 + PhysicalPartitionThroughputInfoResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_sql_container_redistribute_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Redistribute throughput for an Azure Cosmos DB SQL container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current SQL container. Is either a model type or a IO type. Required. + :type redistribute_throughput_parameters: + ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -2657,20 +3220,17 @@ async def begin_sql_container_redistribute_throughput( PhysicalPartitionThroughputInfoResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PhysicalPartitionThroughputInfoResult] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhysicalPartitionThroughputInfoResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._sql_container_redistribute_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -2680,87 +3240,80 @@ async def begin_sql_container_redistribute_throughput( redistribute_throughput_parameters=redistribute_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PhysicalPartitionThroughputInfoResult', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_sql_container_redistribute_throughput.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/redistributeThroughput"} # type: ignore + begin_sql_container_redistribute_throughput.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/redistributeThroughput"} # type: ignore @distributed_trace def list_sql_stored_procedures( - self, - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SqlStoredProcedureListResult]: + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SqlStoredProcedureGetResults"]: """Lists the SQL storedProcedure under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :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 + :return: An iterator like instance of either SqlStoredProcedureGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlStoredProcedureListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlStoredProcedureListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlStoredProcedureListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_sql_stored_procedures_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_sql_stored_procedures.metadata['url'], + template_url=self.list_sql_stored_procedures.metadata["url"], headers=_headers, params=_params, ) @@ -2768,18 +3321,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -2795,10 +3341,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2808,11 +3352,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + 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( @@ -2827,41 +3369,39 @@ async def get_sql_stored_procedure( """Gets the SQL storedProcedure under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param stored_procedure_name: Cosmos DB storedProcedure name. + :param stored_procedure_name: Cosmos DB storedProcedure name. Required. :type stored_procedure_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlStoredProcedureGetResults, or the result of cls(response) + :return: SqlStoredProcedureGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlStoredProcedureGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlStoredProcedureGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_sql_stored_procedure.metadata['url'], + template_url=self.get_sql_stored_procedure.metadata["url"], headers=_headers, params=_params, ) @@ -2869,25 +3409,23 @@ async def get_sql_stored_procedure( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SqlStoredProcedureGetResults', pipeline_response) + deserialized = self._deserialize("SqlStoredProcedureGetResults", pipeline_response) if cls: 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 - + 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, @@ -2896,34 +3434,41 @@ async def _create_update_sql_stored_procedure_initial( database_name: str, container_name: str, stored_procedure_name: str, - create_update_sql_stored_procedure_parameters: _models.SqlStoredProcedureCreateUpdateParameters, + create_update_sql_stored_procedure_parameters: Union[_models.SqlStoredProcedureCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.SqlStoredProcedureGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SqlStoredProcedureGetResults]] - - _json = self._serialize.body(create_update_sql_stored_procedure_parameters, 'SqlStoredProcedureCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SqlStoredProcedureGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_sql_stored_procedure_parameters, (IO, bytes)): + _content = create_update_sql_stored_procedure_parameters + else: + _json = self._serialize.body( + create_update_sql_stored_procedure_parameters, "SqlStoredProcedureCreateUpdateParameters" + ) - request = build_create_update_sql_stored_procedure_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_sql_stored_procedure_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, stored_procedure_name=stored_procedure_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_sql_stored_procedure_initial.metadata['url'], + content=_content, + template_url=self._create_update_sql_stored_procedure_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2931,10 +3476,9 @@ async def _create_update_sql_stored_procedure_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2943,17 +3487,16 @@ async def _create_update_sql_stored_procedure_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SqlStoredProcedureGetResults', pipeline_response) + deserialized = self._deserialize("SqlStoredProcedureGetResults", pipeline_response) if cls: 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 - + _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 + @overload async def begin_create_update_sql_stored_procedure( self, resource_group_name: str, @@ -2962,24 +3505,123 @@ async def begin_create_update_sql_stored_procedure( container_name: str, stored_procedure_name: str, create_update_sql_stored_procedure_parameters: _models.SqlStoredProcedureCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.SqlStoredProcedureGetResults]: """Create or update an Azure Cosmos DB SQL storedProcedure. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param stored_procedure_name: Cosmos DB storedProcedure name. + :param stored_procedure_name: Cosmos DB storedProcedure name. Required. :type stored_procedure_name: str :param create_update_sql_stored_procedure_parameters: The parameters to provide for the current - SQL storedProcedure. + SQL storedProcedure. Required. :type create_update_sql_stored_procedure_parameters: ~azure.mgmt.cosmosdb.models.SqlStoredProcedureCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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: + """ + + @overload + async def begin_create_update_sql_stored_procedure( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + stored_procedure_name: str, + create_update_sql_stored_procedure_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SqlStoredProcedureGetResults]: + """Create or update an Azure Cosmos DB SQL storedProcedure. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param stored_procedure_name: Cosmos DB storedProcedure name. Required. + :type stored_procedure_name: str + :param create_update_sql_stored_procedure_parameters: The parameters to provide for the current + SQL storedProcedure. Required. + :type create_update_sql_stored_procedure_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_create_update_sql_stored_procedure( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + stored_procedure_name: str, + create_update_sql_stored_procedure_parameters: Union[_models.SqlStoredProcedureCreateUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.SqlStoredProcedureGetResults]: + """Create or update an Azure Cosmos DB SQL storedProcedure. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param stored_procedure_name: Cosmos DB storedProcedure name. Required. + :type stored_procedure_name: str + :param create_update_sql_stored_procedure_parameters: The parameters to provide for the current + SQL storedProcedure. Is either a model type or a IO type. Required. + :type create_update_sql_stored_procedure_parameters: + ~azure.mgmt.cosmosdb.models.SqlStoredProcedureCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -2992,20 +3634,17 @@ async def begin_create_update_sql_stored_procedure( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlStoredProcedureGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlStoredProcedureGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_update_sql_stored_procedure_initial( # type: ignore resource_group_name=resource_group_name, @@ -3016,39 +3655,35 @@ async def begin_create_update_sql_stored_procedure( create_update_sql_stored_procedure_parameters=create_update_sql_stored_procedure_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SqlStoredProcedureGetResults', pipeline_response) + deserialized = self._deserialize("SqlStoredProcedureGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements self, @@ -3059,27 +3694,24 @@ async def _delete_sql_stored_procedure_initial( # pylint: disable=inconsistent- stored_procedure_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_sql_stored_procedure_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_sql_stored_procedure_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, stored_procedure_name=stored_procedure_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_sql_stored_procedure_initial.metadata['url'], + template_url=self._delete_sql_stored_procedure_initial.metadata["url"], headers=_headers, params=_params, ) @@ -3087,10 +3719,9 @@ async def _delete_sql_stored_procedure_initial( # pylint: disable=inconsistent- request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3100,11 +3731,10 @@ async def _delete_sql_stored_procedure_initial( # pylint: disable=inconsistent- if cls: return cls(pipeline_response, None, {}) - _delete_sql_stored_procedure_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements + async def begin_delete_sql_stored_procedure( self, resource_group_name: str, account_name: str, @@ -3116,14 +3746,15 @@ async def begin_delete_sql_stored_procedure( # pylint: disable=inconsistent-ret """Deletes an existing Azure Cosmos DB SQL storedProcedure. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param stored_procedure_name: Cosmos DB storedProcedure name. + :param stored_procedure_name: Cosmos DB storedProcedure name. Required. :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. @@ -3135,19 +3766,16 @@ async def begin_delete_sql_stored_procedure( # pylint: disable=inconsistent-ret 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_sql_stored_procedure_initial( # type: ignore resource_group_name=resource_group_name, @@ -3156,85 +3784,76 @@ async def begin_delete_sql_stored_procedure( # pylint: disable=inconsistent-ret container_name=container_name, stored_procedure_name=stored_procedure_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SqlUserDefinedFunctionListResult]: + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SqlUserDefinedFunctionGetResults"]: """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :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 + :return: An iterator like instance of either SqlUserDefinedFunctionGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlUserDefinedFunctionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlUserDefinedFunctionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_sql_user_defined_functions.metadata['url'], + template_url=self.list_sql_user_defined_functions.metadata["url"], headers=_headers, params=_params, ) @@ -3242,18 +3861,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -3269,10 +3881,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3282,11 +3892,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + 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( @@ -3301,41 +3909,39 @@ async def get_sql_user_defined_function( """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param user_defined_function_name: Cosmos DB userDefinedFunction name. + :param user_defined_function_name: Cosmos DB userDefinedFunction name. Required. :type user_defined_function_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlUserDefinedFunctionGetResults, or the result of cls(response) + :return: SqlUserDefinedFunctionGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlUserDefinedFunctionGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlUserDefinedFunctionGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_sql_user_defined_function.metadata['url'], + template_url=self.get_sql_user_defined_function.metadata["url"], headers=_headers, params=_params, ) @@ -3343,25 +3949,23 @@ async def get_sql_user_defined_function( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SqlUserDefinedFunctionGetResults', pipeline_response) + deserialized = self._deserialize("SqlUserDefinedFunctionGetResults", pipeline_response) if cls: 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 - + 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, @@ -3370,34 +3974,43 @@ async def _create_update_sql_user_defined_function_initial( database_name: str, container_name: str, user_defined_function_name: str, - create_update_sql_user_defined_function_parameters: _models.SqlUserDefinedFunctionCreateUpdateParameters, + create_update_sql_user_defined_function_parameters: Union[ + _models.SqlUserDefinedFunctionCreateUpdateParameters, IO + ], **kwargs: Any ) -> Optional[_models.SqlUserDefinedFunctionGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SqlUserDefinedFunctionGetResults]] - - _json = self._serialize.body(create_update_sql_user_defined_function_parameters, 'SqlUserDefinedFunctionCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SqlUserDefinedFunctionGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_sql_user_defined_function_parameters, (IO, bytes)): + _content = create_update_sql_user_defined_function_parameters + else: + _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, + request = build_create_update_sql_user_defined_function_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, user_defined_function_name=user_defined_function_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_sql_user_defined_function_initial.metadata['url'], + content=_content, + template_url=self._create_update_sql_user_defined_function_initial.metadata["url"], headers=_headers, params=_params, ) @@ -3405,10 +4018,9 @@ async def _create_update_sql_user_defined_function_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3417,17 +4029,16 @@ async def _create_update_sql_user_defined_function_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SqlUserDefinedFunctionGetResults', pipeline_response) + deserialized = self._deserialize("SqlUserDefinedFunctionGetResults", pipeline_response) if cls: 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 + _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 + @overload async def begin_create_update_sql_user_defined_function( self, resource_group_name: str, @@ -3436,24 +4047,125 @@ async def begin_create_update_sql_user_defined_function( container_name: str, user_defined_function_name: str, create_update_sql_user_defined_function_parameters: _models.SqlUserDefinedFunctionCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param user_defined_function_name: Cosmos DB userDefinedFunction name. + :param user_defined_function_name: Cosmos DB userDefinedFunction name. Required. :type user_defined_function_name: str :param create_update_sql_user_defined_function_parameters: The parameters to provide for the - current SQL userDefinedFunction. + current SQL userDefinedFunction. Required. :type create_update_sql_user_defined_function_parameters: ~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + async def begin_create_update_sql_user_defined_function( + self, + 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: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param user_defined_function_name: Cosmos DB userDefinedFunction name. Required. + :type user_defined_function_name: str + :param create_update_sql_user_defined_function_parameters: The parameters to provide for the + current SQL userDefinedFunction. Required. + :type create_update_sql_user_defined_function_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_create_update_sql_user_defined_function( + self, + 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: Union[ + _models.SqlUserDefinedFunctionCreateUpdateParameters, IO + ], + **kwargs: Any + ) -> AsyncLROPoller[_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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param user_defined_function_name: Cosmos DB userDefinedFunction name. Required. + :type user_defined_function_name: str + :param create_update_sql_user_defined_function_parameters: The parameters to provide for the + current SQL userDefinedFunction. Is either a model type or a IO type. Required. + :type create_update_sql_user_defined_function_parameters: + ~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -3466,20 +4178,17 @@ async def begin_create_update_sql_user_defined_function( the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlUserDefinedFunctionGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlUserDefinedFunctionGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_update_sql_user_defined_function_initial( # type: ignore resource_group_name=resource_group_name, @@ -3490,39 +4199,35 @@ async def begin_create_update_sql_user_defined_function( create_update_sql_user_defined_function_parameters=create_update_sql_user_defined_function_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SqlUserDefinedFunctionGetResults', pipeline_response) + deserialized = self._deserialize("SqlUserDefinedFunctionGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements self, @@ -3533,27 +4238,24 @@ async def _delete_sql_user_defined_function_initial( # pylint: disable=inconsis user_defined_function_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_sql_user_defined_function_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_sql_user_defined_function_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, user_defined_function_name=user_defined_function_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_sql_user_defined_function_initial.metadata['url'], + template_url=self._delete_sql_user_defined_function_initial.metadata["url"], headers=_headers, params=_params, ) @@ -3561,10 +4263,9 @@ async def _delete_sql_user_defined_function_initial( # pylint: disable=inconsis request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3574,11 +4275,10 @@ async def _delete_sql_user_defined_function_initial( # pylint: disable=inconsis if cls: return cls(pipeline_response, None, {}) - _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 - + _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( # pylint: disable=inconsistent-return-statements + async def begin_delete_sql_user_defined_function( self, resource_group_name: str, account_name: str, @@ -3590,14 +4290,15 @@ async def begin_delete_sql_user_defined_function( # pylint: disable=inconsisten """Deletes an existing Azure Cosmos DB SQL userDefinedFunction. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param user_defined_function_name: Cosmos DB userDefinedFunction name. + :param user_defined_function_name: Cosmos DB userDefinedFunction name. Required. :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. @@ -3609,19 +4310,16 @@ async def begin_delete_sql_user_defined_function( # pylint: disable=inconsisten 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_sql_user_defined_function_initial( # type: ignore resource_group_name=resource_group_name, @@ -3630,85 +4328,76 @@ async def begin_delete_sql_user_defined_function( # pylint: disable=inconsisten container_name=container_name, user_defined_function_name=user_defined_function_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SqlTriggerListResult]: + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SqlTriggerGetResults"]: """Lists the SQL trigger under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :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 + :return: An iterator like instance of either SqlTriggerGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlTriggerListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlTriggerListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlTriggerListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_sql_triggers.metadata['url'], + template_url=self.list_sql_triggers.metadata["url"], headers=_headers, params=_params, ) @@ -3716,18 +4405,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -3743,10 +4425,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3756,11 +4436,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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 + 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( @@ -3775,41 +4453,39 @@ async def get_sql_trigger( """Gets the SQL trigger under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param trigger_name: Cosmos DB trigger name. + :param trigger_name: Cosmos DB trigger name. Required. :type trigger_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlTriggerGetResults, or the result of cls(response) + :return: SqlTriggerGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.SqlTriggerGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlTriggerGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlTriggerGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_sql_trigger.metadata['url'], + template_url=self.get_sql_trigger.metadata["url"], headers=_headers, params=_params, ) @@ -3817,25 +4493,23 @@ async def get_sql_trigger( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SqlTriggerGetResults', pipeline_response) + deserialized = self._deserialize("SqlTriggerGetResults", pipeline_response) if cls: 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 - + 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, @@ -3844,34 +4518,39 @@ async def _create_update_sql_trigger_initial( database_name: str, container_name: str, trigger_name: str, - create_update_sql_trigger_parameters: _models.SqlTriggerCreateUpdateParameters, + create_update_sql_trigger_parameters: Union[_models.SqlTriggerCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.SqlTriggerGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SqlTriggerGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SqlTriggerGetResults]] - _json = self._serialize.body(create_update_sql_trigger_parameters, 'SqlTriggerCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_sql_trigger_parameters, (IO, bytes)): + _content = create_update_sql_trigger_parameters + else: + _json = self._serialize.body(create_update_sql_trigger_parameters, "SqlTriggerCreateUpdateParameters") - request = build_create_update_sql_trigger_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_sql_trigger_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, trigger_name=trigger_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_sql_trigger_initial.metadata['url'], + content=_content, + template_url=self._create_update_sql_trigger_initial.metadata["url"], headers=_headers, params=_params, ) @@ -3879,10 +4558,9 @@ async def _create_update_sql_trigger_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3891,17 +4569,16 @@ async def _create_update_sql_trigger_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SqlTriggerGetResults', pipeline_response) + deserialized = self._deserialize("SqlTriggerGetResults", pipeline_response) if cls: 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 - + _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 + @overload async def begin_create_update_sql_trigger( self, resource_group_name: str, @@ -3910,24 +4587,121 @@ async def begin_create_update_sql_trigger( container_name: str, trigger_name: str, create_update_sql_trigger_parameters: _models.SqlTriggerCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.SqlTriggerGetResults]: """Create or update an Azure Cosmos DB SQL trigger. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param trigger_name: Cosmos DB trigger name. + :param trigger_name: Cosmos DB trigger name. Required. :type trigger_name: str :param create_update_sql_trigger_parameters: The parameters to provide for the current SQL - trigger. + trigger. Required. :type create_update_sql_trigger_parameters: ~azure.mgmt.cosmosdb.models.SqlTriggerCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_update_sql_trigger( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + trigger_name: str, + create_update_sql_trigger_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SqlTriggerGetResults]: + """Create or update an Azure Cosmos DB SQL trigger. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param trigger_name: Cosmos DB trigger name. Required. + :type trigger_name: str + :param create_update_sql_trigger_parameters: The parameters to provide for the current SQL + trigger. Required. + :type create_update_sql_trigger_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_update_sql_trigger( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + trigger_name: str, + create_update_sql_trigger_parameters: Union[_models.SqlTriggerCreateUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.SqlTriggerGetResults]: + """Create or update an Azure Cosmos DB SQL trigger. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param trigger_name: Cosmos DB trigger name. Required. + :type trigger_name: str + :param create_update_sql_trigger_parameters: The parameters to provide for the current SQL + trigger. Is either a model type or a IO type. Required. + :type create_update_sql_trigger_parameters: + ~azure.mgmt.cosmosdb.models.SqlTriggerCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -3939,20 +4713,17 @@ async def begin_create_update_sql_trigger( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlTriggerGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlTriggerGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_update_sql_trigger_initial( # type: ignore resource_group_name=resource_group_name, @@ -3963,39 +4734,35 @@ async def begin_create_update_sql_trigger( create_update_sql_trigger_parameters=create_update_sql_trigger_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SqlTriggerGetResults', pipeline_response) + deserialized = self._deserialize("SqlTriggerGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements self, @@ -4006,27 +4773,24 @@ async def _delete_sql_trigger_initial( # pylint: disable=inconsistent-return-st trigger_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_sql_trigger_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_sql_trigger_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, trigger_name=trigger_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_sql_trigger_initial.metadata['url'], + template_url=self._delete_sql_trigger_initial.metadata["url"], headers=_headers, params=_params, ) @@ -4034,10 +4798,9 @@ async def _delete_sql_trigger_initial( # pylint: disable=inconsistent-return-st request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4047,11 +4810,10 @@ async def _delete_sql_trigger_initial( # pylint: disable=inconsistent-return-st if cls: return cls(pipeline_response, None, {}) - _delete_sql_trigger_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements + async def begin_delete_sql_trigger( self, resource_group_name: str, account_name: str, @@ -4063,14 +4825,15 @@ async def begin_delete_sql_trigger( # pylint: disable=inconsistent-return-state """Deletes an existing Azure Cosmos DB SQL trigger. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param trigger_name: Cosmos DB trigger name. + :param trigger_name: Cosmos DB trigger name. Required. :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. @@ -4082,19 +4845,16 @@ async def begin_delete_sql_trigger( # pylint: disable=inconsistent-return-state 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_sql_trigger_initial( # type: ignore resource_group_name=resource_group_name, @@ -4103,78 +4863,68 @@ async def begin_delete_sql_trigger( # pylint: disable=inconsistent-return-state container_name=container_name, trigger_name=trigger_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.SqlRoleDefinitionGetResults: """Retrieves the properties of an existing Azure Cosmos DB SQL Role Definition with the given Id. - :param role_definition_id: The GUID for the Role Definition. + :param role_definition_id: The GUID for the Role Definition. Required. :type role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlRoleDefinitionGetResults, or the result of cls(response) + :return: SqlRoleDefinitionGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlRoleDefinitionGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlRoleDefinitionGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_sql_role_definition.metadata['url'], + template_url=self.get_sql_role_definition.metadata["url"], headers=_headers, params=_params, ) @@ -4182,57 +4932,62 @@ async def get_sql_role_definition( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SqlRoleDefinitionGetResults', pipeline_response) + deserialized = self._deserialize("SqlRoleDefinitionGetResults", pipeline_response) if cls: 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 - + 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, resource_group_name: str, account_name: str, - create_update_sql_role_definition_parameters: _models.SqlRoleDefinitionCreateUpdateParameters, + create_update_sql_role_definition_parameters: Union[_models.SqlRoleDefinitionCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.SqlRoleDefinitionGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SqlRoleDefinitionGetResults]] - - _json = self._serialize.body(create_update_sql_role_definition_parameters, 'SqlRoleDefinitionCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SqlRoleDefinitionGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_sql_role_definition_parameters, (IO, bytes)): + _content = create_update_sql_role_definition_parameters + else: + _json = self._serialize.body( + create_update_sql_role_definition_parameters, "SqlRoleDefinitionCreateUpdateParameters" + ) - request = build_create_update_sql_role_definition_request_initial( + request = build_create_update_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, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_sql_role_definition_initial.metadata['url'], + content=_content, + template_url=self._create_update_sql_role_definition_initial.metadata["url"], headers=_headers, params=_params, ) @@ -4240,10 +4995,9 @@ async def _create_update_sql_role_definition_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4252,15 +5006,97 @@ async def _create_update_sql_role_definition_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SqlRoleDefinitionGetResults', pipeline_response) + deserialized = self._deserialize("SqlRoleDefinitionGetResults", pipeline_response) if cls: 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 + _create_update_sql_role_definition_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}"} # type: ignore + + @overload + async def begin_create_update_sql_role_definition( + self, + role_definition_id: str, + resource_group_name: str, + account_name: str, + create_update_sql_role_definition_parameters: _models.SqlRoleDefinitionCreateUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SqlRoleDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB SQL Role Definition. + + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param create_update_sql_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_sql_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + async def begin_create_update_sql_role_definition( + self, + role_definition_id: str, + resource_group_name: str, + account_name: str, + create_update_sql_role_definition_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SqlRoleDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB SQL Role Definition. + :param role_definition_id: The GUID for the Role Definition. Required. + :type role_definition_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param create_update_sql_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_sql_role_definition_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ @distributed_trace_async async def begin_create_update_sql_role_definition( @@ -4268,21 +5104,25 @@ async def begin_create_update_sql_role_definition( role_definition_id: str, resource_group_name: str, account_name: str, - create_update_sql_role_definition_parameters: _models.SqlRoleDefinitionCreateUpdateParameters, + create_update_sql_role_definition_parameters: Union[_models.SqlRoleDefinitionCreateUpdateParameters, IO], **kwargs: Any ) -> AsyncLROPoller[_models.SqlRoleDefinitionGetResults]: """Creates or updates an Azure Cosmos DB SQL Role Definition. - :param role_definition_id: The GUID for the Role Definition. + :param role_definition_id: The GUID for the Role Definition. Required. :type role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param create_update_sql_role_definition_parameters: The properties required to create or - update a Role Definition. + update a Role Definition. Is either a model type or a IO type. Required. :type create_update_sql_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionCreateUpdateParameters + ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -4295,20 +5135,17 @@ async def begin_create_update_sql_role_definition( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlRoleDefinitionGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlRoleDefinitionGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_update_sql_role_definition_initial( # type: ignore role_definition_id=role_definition_id, @@ -4317,66 +5154,55 @@ async def begin_create_update_sql_role_definition( create_update_sql_role_definition_parameters=create_update_sql_role_definition_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SqlRoleDefinitionGetResults', pipeline_response) + deserialized = self._deserialize("SqlRoleDefinitionGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements - self, - role_definition_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_sql_role_definition_request_initial( + request = build_delete_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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_sql_role_definition_initial.metadata['url'], + template_url=self._delete_sql_role_definition_initial.metadata["url"], headers=_headers, params=_params, ) @@ -4384,10 +5210,9 @@ async def _delete_sql_role_definition_initial( # pylint: disable=inconsistent-r request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -4397,24 +5222,20 @@ async def _delete_sql_role_definition_initial( # pylint: disable=inconsistent-r if cls: return cls(pipeline_response, None, {}) - _delete_sql_role_definition_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements - self, - role_definition_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + async def begin_delete_sql_role_definition( + self, role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Azure Cosmos DB SQL Role Definition. - :param role_definition_id: The GUID for the Role Definition. + :param role_definition_id: The GUID for the Role Definition. Required. :type role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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. @@ -4426,96 +5247,86 @@ async def begin_delete_sql_role_definition( # pylint: disable=inconsistent-retu 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_sql_role_definition_initial( # type: ignore role_definition_id=role_definition_id, resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SqlRoleDefinitionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SqlRoleDefinitionGetResults"]: """Retrieves the list of all Azure Cosmos DB SQL Role Definitions. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 + :return: An iterator like instance of either SqlRoleDefinitionGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlRoleDefinitionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlRoleDefinitionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_sql_role_definitions_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_sql_role_definitions.metadata['url'], + template_url=self.list_sql_role_definitions.metadata["url"], headers=_headers, params=_params, ) @@ -4523,16 +5334,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_sql_role_definitions_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -4548,10 +5354,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4561,52 +5365,44 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_sql_role_definitions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions"} # type: ignore + 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, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, 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. + :param role_assignment_id: The GUID for the Role Assignment. Required. :type role_assignment_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlRoleAssignmentGetResults, or the result of cls(response) + :return: SqlRoleAssignmentGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.SqlRoleAssignmentGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlRoleAssignmentGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlRoleAssignmentGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_sql_role_assignment.metadata['url'], + template_url=self.get_sql_role_assignment.metadata["url"], headers=_headers, params=_params, ) @@ -4614,57 +5410,62 @@ async def get_sql_role_assignment( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SqlRoleAssignmentGetResults', pipeline_response) + deserialized = self._deserialize("SqlRoleAssignmentGetResults", pipeline_response) if cls: 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 - + 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, resource_group_name: str, account_name: str, - create_update_sql_role_assignment_parameters: _models.SqlRoleAssignmentCreateUpdateParameters, + create_update_sql_role_assignment_parameters: Union[_models.SqlRoleAssignmentCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.SqlRoleAssignmentGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SqlRoleAssignmentGetResults]] - - _json = self._serialize.body(create_update_sql_role_assignment_parameters, 'SqlRoleAssignmentCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SqlRoleAssignmentGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_sql_role_assignment_parameters, (IO, bytes)): + _content = create_update_sql_role_assignment_parameters + else: + _json = self._serialize.body( + create_update_sql_role_assignment_parameters, "SqlRoleAssignmentCreateUpdateParameters" + ) - request = build_create_update_sql_role_assignment_request_initial( + request = build_create_update_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, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_sql_role_assignment_initial.metadata['url'], + content=_content, + template_url=self._create_update_sql_role_assignment_initial.metadata["url"], headers=_headers, params=_params, ) @@ -4672,10 +5473,9 @@ async def _create_update_sql_role_assignment_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4684,37 +5484,123 @@ async def _create_update_sql_role_assignment_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SqlRoleAssignmentGetResults', pipeline_response) + deserialized = self._deserialize("SqlRoleAssignmentGetResults", pipeline_response) if cls: 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 - + _create_update_sql_role_assignment_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_update_sql_role_assignment( self, role_assignment_id: str, resource_group_name: str, account_name: str, create_update_sql_role_assignment_parameters: _models.SqlRoleAssignmentCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.SqlRoleAssignmentGetResults]: """Creates or updates an Azure Cosmos DB SQL Role Assignment. - :param role_assignment_id: The GUID for the Role Assignment. + :param role_assignment_id: The GUID for the Role Assignment. Required. :type role_assignment_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param create_update_sql_role_assignment_parameters: The properties required to create or - update a Role Assignment. + update a Role Assignment. Required. :type create_update_sql_role_assignment_parameters: ~azure.mgmt.cosmosdb.models.SqlRoleAssignmentCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + async def begin_create_update_sql_role_assignment( + self, + role_assignment_id: str, + resource_group_name: str, + account_name: str, + create_update_sql_role_assignment_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SqlRoleAssignmentGetResults]: + """Creates or updates an Azure Cosmos DB SQL Role Assignment. + + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param create_update_sql_role_assignment_parameters: The properties required to create or + update a Role Assignment. Required. + :type create_update_sql_role_assignment_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_create_update_sql_role_assignment( + self, + role_assignment_id: str, + resource_group_name: str, + account_name: str, + create_update_sql_role_assignment_parameters: Union[_models.SqlRoleAssignmentCreateUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.SqlRoleAssignmentGetResults]: + """Creates or updates an Azure Cosmos DB SQL Role Assignment. + + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param create_update_sql_role_assignment_parameters: The properties required to create or + update a Role Assignment. Is either a model type or a IO type. Required. + :type create_update_sql_role_assignment_parameters: + ~azure.mgmt.cosmosdb.models.SqlRoleAssignmentCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -4727,20 +5613,17 @@ async def begin_create_update_sql_role_assignment( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.SqlRoleAssignmentGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlRoleAssignmentGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlRoleAssignmentGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_update_sql_role_assignment_initial( # type: ignore role_assignment_id=role_assignment_id, @@ -4749,66 +5632,55 @@ async def begin_create_update_sql_role_assignment( create_update_sql_role_assignment_parameters=create_update_sql_role_assignment_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SqlRoleAssignmentGetResults', pipeline_response) + deserialized = self._deserialize("SqlRoleAssignmentGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements - self, - role_assignment_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, role_assignment_id: str, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_sql_role_assignment_request_initial( + request = build_delete_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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_sql_role_assignment_initial.metadata['url'], + template_url=self._delete_sql_role_assignment_initial.metadata["url"], headers=_headers, params=_params, ) @@ -4816,10 +5688,9 @@ async def _delete_sql_role_assignment_initial( # pylint: disable=inconsistent-r request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -4829,24 +5700,20 @@ async def _delete_sql_role_assignment_initial( # pylint: disable=inconsistent-r if cls: return cls(pipeline_response, None, {}) - _delete_sql_role_assignment_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements - self, - role_assignment_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + async def begin_delete_sql_role_assignment( + self, role_assignment_id: str, resource_group_name: str, account_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Azure Cosmos DB SQL Role Assignment. - :param role_assignment_id: The GUID for the Role Assignment. + :param role_assignment_id: The GUID for the Role Assignment. Required. :type role_assignment_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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. @@ -4858,96 +5725,86 @@ async def begin_delete_sql_role_assignment( # pylint: disable=inconsistent-retu 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_sql_role_assignment_initial( # type: ignore role_assignment_id=role_assignment_id, resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.SqlRoleAssignmentListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SqlRoleAssignmentGetResults"]: """Retrieves the list of all Azure Cosmos DB SQL Role Assignments. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 + :return: An iterator like instance of either SqlRoleAssignmentGetResults or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleAssignmentGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlRoleAssignmentListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlRoleAssignmentListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_sql_role_assignments_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_sql_role_assignments.metadata['url'], + template_url=self.list_sql_role_assignments.metadata["url"], headers=_headers, params=_params, ) @@ -4955,16 +5812,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_sql_role_assignments_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -4980,10 +5832,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4993,11 +5843,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_sql_role_assignments.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments"} # type: ignore + list_sql_role_assignments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments"} # type: ignore async def _retrieve_continuous_backup_information_initial( self, @@ -5005,33 +5853,38 @@ async def _retrieve_continuous_backup_information_initial( account_name: str, database_name: str, container_name: str, - location: _models.ContinuousBackupRestoreLocation, + location: Union[_models.ContinuousBackupRestoreLocation, IO], **kwargs: Any ) -> Optional[_models.BackupInformation]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.BackupInformation]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.BackupInformation]] - _json = self._serialize.body(location, 'ContinuousBackupRestoreLocation') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(location, (IO, bytes)): + _content = location + else: + _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") - request = build_retrieve_continuous_backup_information_request_initial( - subscription_id=self._config.subscription_id, + request = build_retrieve_continuous_backup_information_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._retrieve_continuous_backup_information_initial.metadata['url'], + content=_content, + template_url=self._retrieve_continuous_backup_information_initial.metadata["url"], headers=_headers, params=_params, ) @@ -5039,10 +5892,9 @@ async def _retrieve_continuous_backup_information_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5051,17 +5903,16 @@ async def _retrieve_continuous_backup_information_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BackupInformation', pipeline_response) + deserialized = self._deserialize("BackupInformation", pipeline_response) if cls: 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 + _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 + @overload async def begin_retrieve_continuous_backup_information( self, resource_group_name: str, @@ -5069,20 +5920,68 @@ async def begin_retrieve_continuous_backup_information( database_name: str, container_name: str, location: _models.ContinuousBackupRestoreLocation, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.BackupInformation]: """Retrieves continuous backup information for a container resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param location: The name of the continuous backup restore location. + :param location: The name of the continuous backup restore location. Required. :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_retrieve_continuous_backup_information( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + location: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a container resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param location: The name of the continuous backup restore location. Required. + :type location: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -5094,20 +5993,58 @@ async def begin_retrieve_continuous_backup_information( :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: + """ + + @distributed_trace_async + async def begin_retrieve_continuous_backup_information( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + location: Union[_models.ContinuousBackupRestoreLocation, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a container resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param location: The name of the continuous backup restore location. Is either a model type or + a IO type. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BackupInformation] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupInformation] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._retrieve_continuous_backup_information_initial( # type: ignore resource_group_name=resource_group_name, @@ -5117,36 +6054,34 @@ async def begin_retrieve_continuous_backup_information( location=location, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BackupInformation', pipeline_response) + deserialized = self._deserialize("BackupInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 89443e79e2f5..cec11884395d 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 @@ -6,10 +6,17 @@ # 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 Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +29,22 @@ 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_retrieve_continuous_backup_information_request_initial, build_update_table_throughput_request_initial -T = TypeVar('T') +from ...operations._table_resources_operations import ( + build_create_update_table_request, + build_delete_table_request, + build_get_table_request, + build_get_table_throughput_request, + build_list_tables_request, + build_migrate_table_to_autoscale_request, + build_migrate_table_to_manual_throughput_request, + build_retrieve_continuous_backup_information_request, + build_update_table_throughput_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TableResourcesOperations: """ .. warning:: @@ -45,44 +64,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_tables( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.TableListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.TableGetResults"]: """Lists the Tables under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 TableListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.TableListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either TableGetResults or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cosmosdb.models.TableGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_tables_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_tables.metadata['url'], + template_url=self.list_tables.metadata["url"], headers=_headers, params=_params, ) @@ -90,16 +105,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_tables_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -115,10 +125,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -128,52 +136,44 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_tables.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables"} # type: ignore + 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, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> _models.TableGetResults: """Gets the Tables under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableGetResults, or the result of cls(response) + :return: TableGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.TableGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_table.metadata['url'], + template_url=self.get_table.metadata["url"], headers=_headers, params=_params, ) @@ -181,57 +181,60 @@ async def get_table( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableGetResults', pipeline_response) + deserialized = self._deserialize("TableGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_table.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}"} # type: ignore - + 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, account_name: str, table_name: str, - create_update_table_parameters: _models.TableCreateUpdateParameters, + create_update_table_parameters: Union[_models.TableCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.TableGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TableGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TableGetResults]] - _json = self._serialize.body(create_update_table_parameters, 'TableCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_table_parameters, (IO, bytes)): + _content = create_update_table_parameters + else: + _json = self._serialize.body(create_update_table_parameters, "TableCreateUpdateParameters") - request = build_create_update_table_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_table_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_table_initial.metadata['url'], + content=_content, + template_url=self._create_update_table_initial.metadata["url"], headers=_headers, params=_params, ) @@ -239,10 +242,9 @@ async def _create_update_table_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -251,35 +253,120 @@ async def _create_update_table_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TableGetResults', pipeline_response) + deserialized = self._deserialize("TableGetResults", pipeline_response) if cls: 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 - + _create_update_table_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_update_table( self, resource_group_name: str, account_name: str, table_name: str, create_update_table_parameters: _models.TableCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.TableGetResults]: """Create or update an Azure Cosmos DB Table. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :type table_name: str :param create_update_table_parameters: The parameters to provide for the current Table. + Required. + :type create_update_table_parameters: ~azure.mgmt.cosmosdb.models.TableCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.TableGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_update_table( + self, + resource_group_name: str, + account_name: str, + table_name: str, + create_update_table_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.TableGetResults]: + """Create or update an Azure Cosmos DB Table. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param create_update_table_parameters: The parameters to provide for the current Table. + Required. + :type create_update_table_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.TableGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_update_table( + self, + resource_group_name: str, + account_name: str, + table_name: str, + create_update_table_parameters: Union[_models.TableCreateUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.TableGetResults]: + """Create or update an Azure Cosmos DB Table. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param create_update_table_parameters: The parameters to provide for the current Table. Is + either a model type or a IO type. Required. :type create_update_table_parameters: ~azure.mgmt.cosmosdb.models.TableCreateUpdateParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -291,20 +378,17 @@ async def begin_create_update_table( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_update_table_initial( # type: ignore resource_group_name=resource_group_name, @@ -313,66 +397,55 @@ async def begin_create_update_table( create_update_table_parameters=create_update_table_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('TableGetResults', pipeline_response) + deserialized = self._deserialize("TableGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_create_update_table.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}"} # type: ignore async def _delete_table_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_table_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_table_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_table_initial.metadata['url'], + template_url=self._delete_table_initial.metadata["url"], headers=_headers, params=_params, ) @@ -380,10 +453,9 @@ async def _delete_table_initial( # pylint: disable=inconsistent-return-statemen request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -393,24 +465,20 @@ async def _delete_table_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _delete_table_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + async def begin_delete_table( + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an existing Azure Cosmos DB Table. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :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. @@ -422,98 +490,85 @@ async def begin_delete_table( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_table_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: """Gets the RUs per second of the Table under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ThroughputSettingsGetResults, or the result of cls(response) + :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_table_throughput.metadata['url'], + template_url=self.get_table_throughput.metadata["url"], headers=_headers, params=_params, ) @@ -521,57 +576,60 @@ async def get_table_throughput( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + 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, account_name: str, table_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IO, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - request = build_update_table_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_table_throughput_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_table_throughput_initial.metadata['url'], + content=_content, + template_url=self._update_table_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -579,10 +637,9 @@ async def _update_table_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -591,37 +648,42 @@ async def _update_table_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _update_table_throughput_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default"} # type: ignore - @distributed_trace_async + @overload async def begin_update_table_throughput( self, resource_group_name: str, account_name: str, table_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Update RUs per second of an Azure Cosmos DB Table. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :type table_name: str :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current Table. + current Table. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :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 @@ -634,20 +696,98 @@ async def begin_update_table_throughput( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_table_throughput( + self, + resource_group_name: str, + account_name: str, + table_name: str, + update_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Table. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current Table. Required. + :type update_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_update_table_throughput( + self, + resource_group_name: str, + account_name: str, + table_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Table. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current Table. Is either a model type or a IO type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._update_table_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -656,66 +796,55 @@ async def begin_update_table_throughput( update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_table_to_autoscale_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_table_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_table_to_autoscale_initial.metadata['url'], + template_url=self._migrate_table_to_autoscale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -723,10 +852,9 @@ async def _migrate_table_to_autoscale_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -735,31 +863,27 @@ async def _migrate_table_to_autoscale_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB Table from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :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. @@ -773,85 +897,71 @@ async def begin_migrate_table_to_autoscale( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._migrate_table_to_autoscale_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_table_to_manual_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_table_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_table_to_manual_throughput_initial.metadata['url'], + template_url=self._migrate_table_to_manual_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -859,10 +969,9 @@ async def _migrate_table_to_manual_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -871,31 +980,27 @@ async def _migrate_table_to_manual_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> AsyncLROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB Table from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :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. @@ -909,90 +1014,88 @@ async def begin_migrate_table_to_manual_throughput( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._migrate_table_to_manual_throughput_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_migrate_table_to_manual_throughput.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput"} # type: ignore async def _retrieve_continuous_backup_information_initial( self, resource_group_name: str, account_name: str, table_name: str, - location: _models.ContinuousBackupRestoreLocation, + location: Union[_models.ContinuousBackupRestoreLocation, IO], **kwargs: Any ) -> Optional[_models.BackupInformation]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.BackupInformation]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.BackupInformation]] - _json = self._serialize.body(location, 'ContinuousBackupRestoreLocation') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(location, (IO, bytes)): + _content = location + else: + _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") - request = build_retrieve_continuous_backup_information_request_initial( - subscription_id=self._config.subscription_id, + request = build_retrieve_continuous_backup_information_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._retrieve_continuous_backup_information_initial.metadata['url'], + content=_content, + template_url=self._retrieve_continuous_backup_information_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1000,10 +1103,9 @@ async def _retrieve_continuous_backup_information_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1012,35 +1114,79 @@ async def _retrieve_continuous_backup_information_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BackupInformation', pipeline_response) + deserialized = self._deserialize("BackupInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _retrieve_continuous_backup_information_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/retrieveContinuousBackupInformation"} # type: ignore + _retrieve_continuous_backup_information_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/retrieveContinuousBackupInformation"} # type: ignore - - @distributed_trace_async + @overload async def begin_retrieve_continuous_backup_information( self, resource_group_name: str, account_name: str, table_name: str, location: _models.ContinuousBackupRestoreLocation, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.BackupInformation]: """Retrieves continuous backup information for a table. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :type table_name: str - :param location: The name of the continuous backup restore location. + :param location: The name of the continuous backup restore location. Required. :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_retrieve_continuous_backup_information( + self, + resource_group_name: str, + account_name: str, + table_name: str, + location: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a table. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param location: The name of the continuous backup restore location. Required. + :type location: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -1052,20 +1198,55 @@ async def begin_retrieve_continuous_backup_information( :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: + """ + + @distributed_trace_async + async def begin_retrieve_continuous_backup_information( + self, + resource_group_name: str, + account_name: str, + table_name: str, + location: Union[_models.ContinuousBackupRestoreLocation, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a table. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param location: The name of the continuous backup restore location. Is either a model type or + a IO type. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BackupInformation] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupInformation] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._retrieve_continuous_backup_information_initial( # type: ignore resource_group_name=resource_group_name, @@ -1074,36 +1255,34 @@ async def begin_retrieve_continuous_backup_information( location=location, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BackupInformation', pipeline_response) + deserialized = self._deserialize("BackupInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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}/tables/{tableName}/retrieveContinuousBackupInformation"} # type: ignore + begin_retrieve_continuous_backup_information.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/retrieveContinuousBackupInformation"} # 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 ecb9096c562f..45655e831fbe 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 @@ -23,6 +23,7 @@ from ._models_py3 import BackupResourceProperties from ._models_py3 import Capability from ._models_py3 import Capacity +from ._models_py3 import CassandraClusterDataCenterNodeItem from ._models_py3 import CassandraClusterPublicStatus from ._models_py3 import CassandraClusterPublicStatusDataCentersItem from ._models_py3 import CassandraKeyspaceCreateUpdateParameters @@ -59,8 +60,6 @@ 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 @@ -139,6 +138,7 @@ from ._models_py3 import ManagedCassandraManagedServiceIdentity from ._models_py3 import ManagedCassandraReaperStatus from ._models_py3 import ManagedServiceIdentity +from ._models_py3 import ManagedServiceIdentityUserAssignedIdentity from ._models_py3 import MaterializedViewsBuilderRegionalServiceResource from ._models_py3 import MaterializedViewsBuilderServiceResource from ._models_py3 import MaterializedViewsBuilderServiceResourceProperties @@ -308,402 +308,400 @@ from ._models_py3 import UsagesResult from ._models_py3 import VirtualNetworkRule - -from ._cosmos_db_management_client_enums import ( - AnalyticalStorageSchemaType, - ApiType, - AuthenticationMethod, - BackupPolicyMigrationStatus, - BackupPolicyType, - BackupStorageRedundancy, - CompositePathSortOrder, - ConflictResolutionMode, - ConnectionState, - ConnectorOffer, - ContinuousTier, - CreateMode, - CreatedByType, - DataTransferComponent, - DataType, - DatabaseAccountKind, - DefaultConsistencyLevel, - EnableFullTextQuery, - IndexKind, - IndexingMode, - KeyKind, - ManagedCassandraProvisioningState, - ManagedCassandraResourceIdentityType, - MongoRoleDefinitionType, - NetworkAclBypass, - NodeState, - NodeStatus, - NotebookWorkspaceName, - OperationType, - PartitionKind, - PrimaryAggregationType, - PublicNetworkAccess, - ResourceIdentityType, - RestoreMode, - RoleDefinitionType, - ServerVersion, - ServiceSize, - ServiceStatus, - ServiceType, - SpatialType, - ThroughputPolicyType, - TriggerOperation, - TriggerType, - UnitType, -) +from ._cosmos_db_management_client_enums import AnalyticalStorageSchemaType +from ._cosmos_db_management_client_enums import ApiType +from ._cosmos_db_management_client_enums import AuthenticationMethod +from ._cosmos_db_management_client_enums import BackupPolicyMigrationStatus +from ._cosmos_db_management_client_enums import BackupPolicyType +from ._cosmos_db_management_client_enums import BackupStorageRedundancy +from ._cosmos_db_management_client_enums import CompositePathSortOrder +from ._cosmos_db_management_client_enums import ConflictResolutionMode +from ._cosmos_db_management_client_enums import ConnectionState +from ._cosmos_db_management_client_enums import ConnectorOffer +from ._cosmos_db_management_client_enums import ContinuousTier +from ._cosmos_db_management_client_enums import CreateMode +from ._cosmos_db_management_client_enums import CreatedByType +from ._cosmos_db_management_client_enums import DataTransferComponent +from ._cosmos_db_management_client_enums import DataType +from ._cosmos_db_management_client_enums import DatabaseAccountKind +from ._cosmos_db_management_client_enums import DefaultConsistencyLevel +from ._cosmos_db_management_client_enums import EnableFullTextQuery +from ._cosmos_db_management_client_enums import IndexKind +from ._cosmos_db_management_client_enums import IndexingMode +from ._cosmos_db_management_client_enums import KeyKind +from ._cosmos_db_management_client_enums import ManagedCassandraProvisioningState +from ._cosmos_db_management_client_enums import ManagedCassandraResourceIdentityType +from ._cosmos_db_management_client_enums import MongoRoleDefinitionType +from ._cosmos_db_management_client_enums import NetworkAclBypass +from ._cosmos_db_management_client_enums import NodeState +from ._cosmos_db_management_client_enums import NodeStatus +from ._cosmos_db_management_client_enums import NotebookWorkspaceName +from ._cosmos_db_management_client_enums import OperationType +from ._cosmos_db_management_client_enums import PartitionKind +from ._cosmos_db_management_client_enums import PrimaryAggregationType +from ._cosmos_db_management_client_enums import PublicNetworkAccess +from ._cosmos_db_management_client_enums import ResourceIdentityType +from ._cosmos_db_management_client_enums import RestoreMode +from ._cosmos_db_management_client_enums import RoleDefinitionType +from ._cosmos_db_management_client_enums import ServerVersion +from ._cosmos_db_management_client_enums import ServiceSize +from ._cosmos_db_management_client_enums import ServiceStatus +from ._cosmos_db_management_client_enums import ServiceType +from ._cosmos_db_management_client_enums import SpatialType +from ._cosmos_db_management_client_enums import ThroughputPolicyType +from ._cosmos_db_management_client_enums import TriggerOperation +from ._cosmos_db_management_client_enums import TriggerType +from ._cosmos_db_management_client_enums import UnitType from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ARMProxyResource', - 'ARMResourceProperties', - 'AccountKeyMetadata', - 'AnalyticalStorageConfiguration', - 'ApiProperties', - 'AuthenticationMethodLdapProperties', - 'AutoUpgradePolicyResource', - 'AutoscaleSettings', - 'AutoscaleSettingsResource', - 'AzureBlobDataTransferDataSourceSink', - 'BackupInformation', - 'BackupPolicy', - 'BackupPolicyMigrationState', - 'BackupResource', - 'BackupResourceProperties', - 'Capability', - 'Capacity', - 'CassandraClusterPublicStatus', - 'CassandraClusterPublicStatusDataCentersItem', - 'CassandraKeyspaceCreateUpdateParameters', - 'CassandraKeyspaceGetPropertiesOptions', - 'CassandraKeyspaceGetPropertiesResource', - 'CassandraKeyspaceGetResults', - 'CassandraKeyspaceListResult', - 'CassandraKeyspaceResource', - 'CassandraPartitionKey', - 'CassandraSchema', - 'CassandraTableCreateUpdateParameters', - 'CassandraTableGetPropertiesOptions', - 'CassandraTableGetPropertiesResource', - 'CassandraTableGetResults', - 'CassandraTableListResult', - 'CassandraTableResource', - 'CassandraViewCreateUpdateParameters', - 'CassandraViewGetPropertiesOptions', - 'CassandraViewGetPropertiesResource', - 'CassandraViewGetResults', - 'CassandraViewListResult', - 'CassandraViewResource', - 'Certificate', - 'ClientEncryptionIncludedPath', - 'ClientEncryptionKeyCreateUpdateParameters', - 'ClientEncryptionKeyGetPropertiesResource', - 'ClientEncryptionKeyGetResults', - 'ClientEncryptionKeyResource', - 'ClientEncryptionKeysListResult', - 'ClientEncryptionPolicy', - 'ClusterKey', - 'ClusterResource', - 'ClusterResourceProperties', - 'Column', - 'CommandOutput', - 'CommandPostBody', - 'Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties', - 'ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems', - 'CompositePath', - 'ConflictResolutionPolicy', - 'ConnectionError', - 'ConsistencyPolicy', - 'ContainerPartitionKey', - 'ContinuousBackupInformation', - 'ContinuousBackupRestoreLocation', - 'ContinuousModeBackupPolicy', - 'ContinuousModeProperties', - 'CorsPolicy', - 'CosmosCassandraDataTransferDataSourceSink', - 'CosmosSqlDataTransferDataSourceSink', - 'CreateJobRequest', - 'CreateUpdateOptions', - 'DataCenterResource', - 'DataCenterResourceProperties', - 'DataTransferDataSourceSink', - 'DataTransferJobFeedResults', - 'DataTransferJobGetResults', - 'DataTransferJobProperties', - 'DataTransferRegionalServiceResource', - 'DataTransferServiceResource', - 'DataTransferServiceResourceProperties', - 'DatabaseAccountConnectionString', - 'DatabaseAccountCreateUpdateParameters', - 'DatabaseAccountGetResults', - 'DatabaseAccountKeysMetadata', - 'DatabaseAccountListConnectionStringsResult', - 'DatabaseAccountListKeysResult', - 'DatabaseAccountListReadOnlyKeysResult', - 'DatabaseAccountRegenerateKeyParameters', - 'DatabaseAccountUpdateParameters', - 'DatabaseAccountsListResult', - 'DatabaseRestoreResource', - 'DiagnosticLogSettings', - 'ErrorResponse', - 'ExcludedPath', - 'ExtendedResourceProperties', - 'FailoverPolicies', - 'FailoverPolicy', - 'GraphAPIComputeRegionalServiceResource', - 'GraphAPIComputeServiceResource', - 'GraphAPIComputeServiceResourceProperties', - 'GraphResource', - 'GraphResourceCreateUpdateParameters', - 'GraphResourceGetPropertiesOptions', - 'GraphResourceGetPropertiesResource', - 'GraphResourceGetResults', - 'GraphResourcesListResult', - 'GremlinDatabaseCreateUpdateParameters', - 'GremlinDatabaseGetPropertiesOptions', - 'GremlinDatabaseGetPropertiesResource', - 'GremlinDatabaseGetResults', - 'GremlinDatabaseListResult', - 'GremlinDatabaseResource', - 'GremlinDatabaseRestoreResource', - 'GremlinGraphCreateUpdateParameters', - 'GremlinGraphGetPropertiesOptions', - 'GremlinGraphGetPropertiesResource', - 'GremlinGraphGetResults', - 'GremlinGraphListResult', - 'GremlinGraphResource', - 'IncludedPath', - 'Indexes', - 'IndexingPolicy', - 'IpAddressOrRange', - 'KeyWrapMetadata', - 'ListBackups', - 'ListClusters', - 'ListDataCenters', - 'Location', - 'LocationGetResult', - 'LocationListResult', - 'LocationProperties', - 'ManagedCassandraARMResourceProperties', - 'ManagedCassandraManagedServiceIdentity', - 'ManagedCassandraReaperStatus', - 'ManagedServiceIdentity', - 'MaterializedViewsBuilderRegionalServiceResource', - 'MaterializedViewsBuilderServiceResource', - 'MaterializedViewsBuilderServiceResourceProperties', - 'MergeParameters', - 'Metric', - 'MetricAvailability', - 'MetricDefinition', - 'MetricDefinitionsListResult', - 'MetricListResult', - 'MetricName', - 'MetricValue', - 'MongoDBCollectionCreateUpdateParameters', - 'MongoDBCollectionGetPropertiesOptions', - 'MongoDBCollectionGetPropertiesResource', - 'MongoDBCollectionGetResults', - 'MongoDBCollectionListResult', - 'MongoDBCollectionResource', - 'MongoDBDatabaseCreateUpdateParameters', - 'MongoDBDatabaseGetPropertiesOptions', - 'MongoDBDatabaseGetPropertiesResource', - 'MongoDBDatabaseGetResults', - 'MongoDBDatabaseListResult', - 'MongoDBDatabaseResource', - 'MongoIndex', - 'MongoIndexKeys', - 'MongoIndexOptions', - 'MongoRoleDefinitionCreateUpdateParameters', - 'MongoRoleDefinitionGetResults', - 'MongoRoleDefinitionListResult', - 'MongoUserDefinitionCreateUpdateParameters', - 'MongoUserDefinitionGetResults', - 'MongoUserDefinitionListResult', - 'NotebookWorkspace', - 'NotebookWorkspaceConnectionInfoResult', - 'NotebookWorkspaceCreateUpdateParameters', - 'NotebookWorkspaceListResult', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'OptionsResource', - 'PartitionMetric', - 'PartitionMetricListResult', - 'PartitionUsage', - 'PartitionUsagesResult', - 'PercentileMetric', - 'PercentileMetricListResult', - 'PercentileMetricValue', - 'PeriodicModeBackupPolicy', - 'PeriodicModeProperties', - 'Permission', - 'PhysicalPartitionId', - 'PhysicalPartitionStorageInfo', - 'PhysicalPartitionStorageInfoCollection', - 'PhysicalPartitionThroughputInfoProperties', - 'PhysicalPartitionThroughputInfoResource', - 'PhysicalPartitionThroughputInfoResult', - 'PhysicalPartitionThroughputInfoResultPropertiesResource', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateEndpointProperty', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionStateProperty', - 'Privilege', - 'PrivilegeResource', - 'ProxyResource', - 'RedistributeThroughputParameters', - 'RedistributeThroughputPropertiesResource', - 'RegionForOnlineOffline', - 'RegionalServiceResource', - 'Resource', - 'RestorableDatabaseAccountGetResult', - 'RestorableDatabaseAccountsListResult', - 'RestorableGremlinDatabaseGetResult', - 'RestorableGremlinDatabasePropertiesResource', - 'RestorableGremlinDatabasesListResult', - 'RestorableGremlinGraphGetResult', - 'RestorableGremlinGraphPropertiesResource', - 'RestorableGremlinGraphsListResult', - 'RestorableGremlinResourcesGetResult', - 'RestorableGremlinResourcesListResult', - 'RestorableLocationResource', - 'RestorableMongodbCollectionGetResult', - 'RestorableMongodbCollectionPropertiesResource', - 'RestorableMongodbCollectionsListResult', - 'RestorableMongodbDatabaseGetResult', - 'RestorableMongodbDatabasePropertiesResource', - 'RestorableMongodbDatabasesListResult', - 'RestorableMongodbResourcesGetResult', - 'RestorableMongodbResourcesListResult', - 'RestorableSqlContainerGetResult', - 'RestorableSqlContainerPropertiesResource', - 'RestorableSqlContainerPropertiesResourceContainer', - 'RestorableSqlContainersListResult', - 'RestorableSqlDatabaseGetResult', - 'RestorableSqlDatabasePropertiesResource', - 'RestorableSqlDatabasePropertiesResourceDatabase', - 'RestorableSqlDatabasesListResult', - 'RestorableSqlResourcesGetResult', - 'RestorableSqlResourcesListResult', - 'RestorableTableGetResult', - 'RestorableTablePropertiesResource', - 'RestorableTableResourcesGetResult', - 'RestorableTableResourcesListResult', - 'RestorableTablesListResult', - 'RestoreParameters', - 'RetrieveThroughputParameters', - 'RetrieveThroughputPropertiesResource', - 'Role', - 'SeedNode', - 'ServiceResource', - 'ServiceResourceCreateUpdateParameters', - 'ServiceResourceListResult', - 'ServiceResourceProperties', - 'SpatialSpec', - 'SqlContainerCreateUpdateParameters', - 'SqlContainerGetPropertiesOptions', - 'SqlContainerGetPropertiesResource', - 'SqlContainerGetResults', - 'SqlContainerListResult', - 'SqlContainerResource', - 'SqlDatabaseCreateUpdateParameters', - 'SqlDatabaseGetPropertiesOptions', - 'SqlDatabaseGetPropertiesResource', - 'SqlDatabaseGetResults', - 'SqlDatabaseListResult', - 'SqlDatabaseResource', - 'SqlDedicatedGatewayRegionalServiceResource', - 'SqlDedicatedGatewayServiceResource', - 'SqlDedicatedGatewayServiceResourceProperties', - 'SqlRoleAssignmentCreateUpdateParameters', - 'SqlRoleAssignmentGetResults', - 'SqlRoleAssignmentListResult', - 'SqlRoleDefinitionCreateUpdateParameters', - 'SqlRoleDefinitionGetResults', - 'SqlRoleDefinitionListResult', - 'SqlStoredProcedureCreateUpdateParameters', - 'SqlStoredProcedureGetPropertiesResource', - 'SqlStoredProcedureGetResults', - 'SqlStoredProcedureListResult', - 'SqlStoredProcedureResource', - 'SqlTriggerCreateUpdateParameters', - 'SqlTriggerGetPropertiesResource', - 'SqlTriggerGetResults', - 'SqlTriggerListResult', - 'SqlTriggerResource', - 'SqlUserDefinedFunctionCreateUpdateParameters', - 'SqlUserDefinedFunctionGetPropertiesResource', - 'SqlUserDefinedFunctionGetResults', - 'SqlUserDefinedFunctionListResult', - 'SqlUserDefinedFunctionResource', - 'SystemData', - 'TableCreateUpdateParameters', - 'TableGetPropertiesOptions', - 'TableGetPropertiesResource', - 'TableGetResults', - 'TableListResult', - 'TableResource', - 'ThroughputPolicyResource', - 'ThroughputSettingsGetPropertiesResource', - 'ThroughputSettingsGetResults', - 'ThroughputSettingsResource', - 'ThroughputSettingsUpdateParameters', - 'UniqueKey', - 'UniqueKeyPolicy', - 'Usage', - 'UsagesResult', - 'VirtualNetworkRule', - 'AnalyticalStorageSchemaType', - 'ApiType', - 'AuthenticationMethod', - 'BackupPolicyMigrationStatus', - 'BackupPolicyType', - 'BackupStorageRedundancy', - 'CompositePathSortOrder', - 'ConflictResolutionMode', - 'ConnectionState', - 'ConnectorOffer', - 'ContinuousTier', - 'CreateMode', - 'CreatedByType', - 'DataTransferComponent', - 'DataType', - 'DatabaseAccountKind', - 'DefaultConsistencyLevel', - 'EnableFullTextQuery', - 'IndexKind', - 'IndexingMode', - 'KeyKind', - 'ManagedCassandraProvisioningState', - 'ManagedCassandraResourceIdentityType', - 'MongoRoleDefinitionType', - 'NetworkAclBypass', - 'NodeState', - 'NodeStatus', - 'NotebookWorkspaceName', - 'OperationType', - 'PartitionKind', - 'PrimaryAggregationType', - 'PublicNetworkAccess', - 'ResourceIdentityType', - 'RestoreMode', - 'RoleDefinitionType', - 'ServerVersion', - 'ServiceSize', - 'ServiceStatus', - 'ServiceType', - 'SpatialType', - 'ThroughputPolicyType', - 'TriggerOperation', - 'TriggerType', - 'UnitType', + "ARMProxyResource", + "ARMResourceProperties", + "AccountKeyMetadata", + "AnalyticalStorageConfiguration", + "ApiProperties", + "AuthenticationMethodLdapProperties", + "AutoUpgradePolicyResource", + "AutoscaleSettings", + "AutoscaleSettingsResource", + "AzureBlobDataTransferDataSourceSink", + "BackupInformation", + "BackupPolicy", + "BackupPolicyMigrationState", + "BackupResource", + "BackupResourceProperties", + "Capability", + "Capacity", + "CassandraClusterDataCenterNodeItem", + "CassandraClusterPublicStatus", + "CassandraClusterPublicStatusDataCentersItem", + "CassandraKeyspaceCreateUpdateParameters", + "CassandraKeyspaceGetPropertiesOptions", + "CassandraKeyspaceGetPropertiesResource", + "CassandraKeyspaceGetResults", + "CassandraKeyspaceListResult", + "CassandraKeyspaceResource", + "CassandraPartitionKey", + "CassandraSchema", + "CassandraTableCreateUpdateParameters", + "CassandraTableGetPropertiesOptions", + "CassandraTableGetPropertiesResource", + "CassandraTableGetResults", + "CassandraTableListResult", + "CassandraTableResource", + "CassandraViewCreateUpdateParameters", + "CassandraViewGetPropertiesOptions", + "CassandraViewGetPropertiesResource", + "CassandraViewGetResults", + "CassandraViewListResult", + "CassandraViewResource", + "Certificate", + "ClientEncryptionIncludedPath", + "ClientEncryptionKeyCreateUpdateParameters", + "ClientEncryptionKeyGetPropertiesResource", + "ClientEncryptionKeyGetResults", + "ClientEncryptionKeyResource", + "ClientEncryptionKeysListResult", + "ClientEncryptionPolicy", + "ClusterKey", + "ClusterResource", + "ClusterResourceProperties", + "Column", + "CommandOutput", + "CommandPostBody", + "CompositePath", + "ConflictResolutionPolicy", + "ConnectionError", + "ConsistencyPolicy", + "ContainerPartitionKey", + "ContinuousBackupInformation", + "ContinuousBackupRestoreLocation", + "ContinuousModeBackupPolicy", + "ContinuousModeProperties", + "CorsPolicy", + "CosmosCassandraDataTransferDataSourceSink", + "CosmosSqlDataTransferDataSourceSink", + "CreateJobRequest", + "CreateUpdateOptions", + "DataCenterResource", + "DataCenterResourceProperties", + "DataTransferDataSourceSink", + "DataTransferJobFeedResults", + "DataTransferJobGetResults", + "DataTransferJobProperties", + "DataTransferRegionalServiceResource", + "DataTransferServiceResource", + "DataTransferServiceResourceProperties", + "DatabaseAccountConnectionString", + "DatabaseAccountCreateUpdateParameters", + "DatabaseAccountGetResults", + "DatabaseAccountKeysMetadata", + "DatabaseAccountListConnectionStringsResult", + "DatabaseAccountListKeysResult", + "DatabaseAccountListReadOnlyKeysResult", + "DatabaseAccountRegenerateKeyParameters", + "DatabaseAccountUpdateParameters", + "DatabaseAccountsListResult", + "DatabaseRestoreResource", + "DiagnosticLogSettings", + "ErrorResponse", + "ExcludedPath", + "ExtendedResourceProperties", + "FailoverPolicies", + "FailoverPolicy", + "GraphAPIComputeRegionalServiceResource", + "GraphAPIComputeServiceResource", + "GraphAPIComputeServiceResourceProperties", + "GraphResource", + "GraphResourceCreateUpdateParameters", + "GraphResourceGetPropertiesOptions", + "GraphResourceGetPropertiesResource", + "GraphResourceGetResults", + "GraphResourcesListResult", + "GremlinDatabaseCreateUpdateParameters", + "GremlinDatabaseGetPropertiesOptions", + "GremlinDatabaseGetPropertiesResource", + "GremlinDatabaseGetResults", + "GremlinDatabaseListResult", + "GremlinDatabaseResource", + "GremlinDatabaseRestoreResource", + "GremlinGraphCreateUpdateParameters", + "GremlinGraphGetPropertiesOptions", + "GremlinGraphGetPropertiesResource", + "GremlinGraphGetResults", + "GremlinGraphListResult", + "GremlinGraphResource", + "IncludedPath", + "Indexes", + "IndexingPolicy", + "IpAddressOrRange", + "KeyWrapMetadata", + "ListBackups", + "ListClusters", + "ListDataCenters", + "Location", + "LocationGetResult", + "LocationListResult", + "LocationProperties", + "ManagedCassandraARMResourceProperties", + "ManagedCassandraManagedServiceIdentity", + "ManagedCassandraReaperStatus", + "ManagedServiceIdentity", + "ManagedServiceIdentityUserAssignedIdentity", + "MaterializedViewsBuilderRegionalServiceResource", + "MaterializedViewsBuilderServiceResource", + "MaterializedViewsBuilderServiceResourceProperties", + "MergeParameters", + "Metric", + "MetricAvailability", + "MetricDefinition", + "MetricDefinitionsListResult", + "MetricListResult", + "MetricName", + "MetricValue", + "MongoDBCollectionCreateUpdateParameters", + "MongoDBCollectionGetPropertiesOptions", + "MongoDBCollectionGetPropertiesResource", + "MongoDBCollectionGetResults", + "MongoDBCollectionListResult", + "MongoDBCollectionResource", + "MongoDBDatabaseCreateUpdateParameters", + "MongoDBDatabaseGetPropertiesOptions", + "MongoDBDatabaseGetPropertiesResource", + "MongoDBDatabaseGetResults", + "MongoDBDatabaseListResult", + "MongoDBDatabaseResource", + "MongoIndex", + "MongoIndexKeys", + "MongoIndexOptions", + "MongoRoleDefinitionCreateUpdateParameters", + "MongoRoleDefinitionGetResults", + "MongoRoleDefinitionListResult", + "MongoUserDefinitionCreateUpdateParameters", + "MongoUserDefinitionGetResults", + "MongoUserDefinitionListResult", + "NotebookWorkspace", + "NotebookWorkspaceConnectionInfoResult", + "NotebookWorkspaceCreateUpdateParameters", + "NotebookWorkspaceListResult", + "Operation", + "OperationDisplay", + "OperationListResult", + "OptionsResource", + "PartitionMetric", + "PartitionMetricListResult", + "PartitionUsage", + "PartitionUsagesResult", + "PercentileMetric", + "PercentileMetricListResult", + "PercentileMetricValue", + "PeriodicModeBackupPolicy", + "PeriodicModeProperties", + "Permission", + "PhysicalPartitionId", + "PhysicalPartitionStorageInfo", + "PhysicalPartitionStorageInfoCollection", + "PhysicalPartitionThroughputInfoProperties", + "PhysicalPartitionThroughputInfoResource", + "PhysicalPartitionThroughputInfoResult", + "PhysicalPartitionThroughputInfoResultPropertiesResource", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateEndpointProperty", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionStateProperty", + "Privilege", + "PrivilegeResource", + "ProxyResource", + "RedistributeThroughputParameters", + "RedistributeThroughputPropertiesResource", + "RegionForOnlineOffline", + "RegionalServiceResource", + "Resource", + "RestorableDatabaseAccountGetResult", + "RestorableDatabaseAccountsListResult", + "RestorableGremlinDatabaseGetResult", + "RestorableGremlinDatabasePropertiesResource", + "RestorableGremlinDatabasesListResult", + "RestorableGremlinGraphGetResult", + "RestorableGremlinGraphPropertiesResource", + "RestorableGremlinGraphsListResult", + "RestorableGremlinResourcesGetResult", + "RestorableGremlinResourcesListResult", + "RestorableLocationResource", + "RestorableMongodbCollectionGetResult", + "RestorableMongodbCollectionPropertiesResource", + "RestorableMongodbCollectionsListResult", + "RestorableMongodbDatabaseGetResult", + "RestorableMongodbDatabasePropertiesResource", + "RestorableMongodbDatabasesListResult", + "RestorableMongodbResourcesGetResult", + "RestorableMongodbResourcesListResult", + "RestorableSqlContainerGetResult", + "RestorableSqlContainerPropertiesResource", + "RestorableSqlContainerPropertiesResourceContainer", + "RestorableSqlContainersListResult", + "RestorableSqlDatabaseGetResult", + "RestorableSqlDatabasePropertiesResource", + "RestorableSqlDatabasePropertiesResourceDatabase", + "RestorableSqlDatabasesListResult", + "RestorableSqlResourcesGetResult", + "RestorableSqlResourcesListResult", + "RestorableTableGetResult", + "RestorableTablePropertiesResource", + "RestorableTableResourcesGetResult", + "RestorableTableResourcesListResult", + "RestorableTablesListResult", + "RestoreParameters", + "RetrieveThroughputParameters", + "RetrieveThroughputPropertiesResource", + "Role", + "SeedNode", + "ServiceResource", + "ServiceResourceCreateUpdateParameters", + "ServiceResourceListResult", + "ServiceResourceProperties", + "SpatialSpec", + "SqlContainerCreateUpdateParameters", + "SqlContainerGetPropertiesOptions", + "SqlContainerGetPropertiesResource", + "SqlContainerGetResults", + "SqlContainerListResult", + "SqlContainerResource", + "SqlDatabaseCreateUpdateParameters", + "SqlDatabaseGetPropertiesOptions", + "SqlDatabaseGetPropertiesResource", + "SqlDatabaseGetResults", + "SqlDatabaseListResult", + "SqlDatabaseResource", + "SqlDedicatedGatewayRegionalServiceResource", + "SqlDedicatedGatewayServiceResource", + "SqlDedicatedGatewayServiceResourceProperties", + "SqlRoleAssignmentCreateUpdateParameters", + "SqlRoleAssignmentGetResults", + "SqlRoleAssignmentListResult", + "SqlRoleDefinitionCreateUpdateParameters", + "SqlRoleDefinitionGetResults", + "SqlRoleDefinitionListResult", + "SqlStoredProcedureCreateUpdateParameters", + "SqlStoredProcedureGetPropertiesResource", + "SqlStoredProcedureGetResults", + "SqlStoredProcedureListResult", + "SqlStoredProcedureResource", + "SqlTriggerCreateUpdateParameters", + "SqlTriggerGetPropertiesResource", + "SqlTriggerGetResults", + "SqlTriggerListResult", + "SqlTriggerResource", + "SqlUserDefinedFunctionCreateUpdateParameters", + "SqlUserDefinedFunctionGetPropertiesResource", + "SqlUserDefinedFunctionGetResults", + "SqlUserDefinedFunctionListResult", + "SqlUserDefinedFunctionResource", + "SystemData", + "TableCreateUpdateParameters", + "TableGetPropertiesOptions", + "TableGetPropertiesResource", + "TableGetResults", + "TableListResult", + "TableResource", + "ThroughputPolicyResource", + "ThroughputSettingsGetPropertiesResource", + "ThroughputSettingsGetResults", + "ThroughputSettingsResource", + "ThroughputSettingsUpdateParameters", + "UniqueKey", + "UniqueKeyPolicy", + "Usage", + "UsagesResult", + "VirtualNetworkRule", + "AnalyticalStorageSchemaType", + "ApiType", + "AuthenticationMethod", + "BackupPolicyMigrationStatus", + "BackupPolicyType", + "BackupStorageRedundancy", + "CompositePathSortOrder", + "ConflictResolutionMode", + "ConnectionState", + "ConnectorOffer", + "ContinuousTier", + "CreateMode", + "CreatedByType", + "DataTransferComponent", + "DataType", + "DatabaseAccountKind", + "DefaultConsistencyLevel", + "EnableFullTextQuery", + "IndexKind", + "IndexingMode", + "KeyKind", + "ManagedCassandraProvisioningState", + "ManagedCassandraResourceIdentityType", + "MongoRoleDefinitionType", + "NetworkAclBypass", + "NodeState", + "NodeStatus", + "NotebookWorkspaceName", + "OperationType", + "PartitionKind", + "PrimaryAggregationType", + "PublicNetworkAccess", + "ResourceIdentityType", + "RestoreMode", + "RoleDefinitionType", + "ServerVersion", + "ServiceSize", + "ServiceStatus", + "ServiceType", + "SpatialType", + "ThroughputPolicyType", + "TriggerOperation", + "TriggerType", + "UnitType", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() 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 0eeb268ea72e..0054221cfaa2 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 @@ -11,15 +11,14 @@ class AnalyticalStorageSchemaType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Describes the types of schema for analytical storage. - """ + """Describes the types of schema for analytical storage.""" WELL_DEFINED = "WellDefined" FULL_FIDELITY = "FullFidelity" + class ApiType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enum to indicate the API type of the restorable database account. - """ + """Enum to indicate the API type of the restorable database account.""" MONGO_DB = "MongoDB" GREMLIN = "Gremlin" @@ -28,6 +27,7 @@ class ApiType(str, Enum, metaclass=CaseInsensitiveEnumMeta): SQL = "Sql" GREMLIN_V2 = "GremlinV2" + class AuthenticationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): """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 @@ -38,47 +38,47 @@ class AuthenticationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): CASSANDRA = "Cassandra" LDAP = "Ldap" + class BackupPolicyMigrationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Describes the status of migration between backup policy types. - """ + """Describes the status of migration between backup policy types.""" INVALID = "Invalid" IN_PROGRESS = "InProgress" COMPLETED = "Completed" FAILED = "Failed" + class BackupPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Describes the mode of backups. - """ + """Describes the mode of backups.""" PERIODIC = "Periodic" CONTINUOUS = "Continuous" + class BackupStorageRedundancy(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enum to indicate type of backup storage redundancy. - """ + """Enum to indicate type of backup storage redundancy.""" GEO = "Geo" LOCAL = "Local" ZONE = "Zone" + class CompositePathSortOrder(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Sort order for composite paths. - """ + """Sort order for composite paths.""" ASCENDING = "ascending" DESCENDING = "descending" + class ConflictResolutionMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the conflict resolution mode. - """ + """Indicates the conflict resolution mode.""" LAST_WRITER_WINS = "LastWriterWins" CUSTOM = "Custom" + class ConnectionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The kind of connection error that occurred. - """ + """The kind of connection error that occurred.""" UNKNOWN = "Unknown" OK = "OK" @@ -87,52 +87,54 @@ class ConnectionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): INTERNAL_OPERATOR_TO_DATA_CENTER_CERTIFICATE_ERROR = "InternalOperatorToDataCenterCertificateError" INTERNAL_ERROR = "InternalError" + class ConnectorOffer(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The cassandra connector offer type for the Cosmos DB C* database account. - """ + """The cassandra connector offer type for the Cosmos DB C* database account.""" SMALL = "Small" + class ContinuousTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enum to indicate type of Continuous backup tier. - """ + """Enum to indicate type of Continuous backup tier.""" CONTINUOUS7_DAYS = "Continuous7Days" CONTINUOUS30_DAYS = "Continuous30Days" + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" + class CreateMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enum to indicate the mode of account creation. - """ + """Enum to indicate the mode of account creation.""" DEFAULT = "Default" RESTORE = "Restore" + class DatabaseAccountKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the type of database account. This can only be set at database account creation. - """ + """Indicates the type of database account. This can only be set at database account creation.""" GLOBAL_DOCUMENT_DB = "GlobalDocumentDB" MONGO_DB = "MongoDB" PARSE = "Parse" + class DataTransferComponent(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DataTransferComponent.""" COSMOS_DB_CASSANDRA = "CosmosDBCassandra" COSMOS_DB_SQL = "CosmosDBSql" AZURE_BLOB_STORAGE = "AzureBlobStorage" + class DataType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The datatype for which the indexing behavior is applied to. - """ + """The datatype for which the indexing behavior is applied to.""" STRING = "String" NUMBER = "Number" @@ -141,9 +143,9 @@ class DataType(str, Enum, metaclass=CaseInsensitiveEnumMeta): LINE_STRING = "LineString" MULTI_POLYGON = "MultiPolygon" + class DefaultConsistencyLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The default consistency level and configuration settings of the Cosmos DB account. - """ + """The default consistency level and configuration settings of the Cosmos DB account.""" EVENTUAL = "Eventual" SESSION = "Session" @@ -151,42 +153,42 @@ class DefaultConsistencyLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): STRONG = "Strong" CONSISTENT_PREFIX = "ConsistentPrefix" + class EnableFullTextQuery(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Describe the level of detail with which queries are to be logged. - """ + """Describe the level of detail with which queries are to be logged.""" NONE = "None" TRUE = "True" FALSE = "False" + class IndexingMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the indexing mode. - """ + """Indicates the indexing mode.""" CONSISTENT = "consistent" LAZY = "lazy" NONE = "none" + class IndexKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the type of index. - """ + """Indicates the type of index.""" HASH = "Hash" RANGE = "Range" SPATIAL = "Spatial" + class KeyKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The access key to regenerate. - """ + """The access key to regenerate.""" PRIMARY = "primary" SECONDARY = "secondary" PRIMARY_READONLY = "primaryReadonly" SECONDARY_READONLY = "secondaryReadonly" + class ManagedCassandraProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The status of the resource at the time the operation was called. - """ + """The status of the resource at the time the operation was called.""" CREATING = "Creating" UPDATING = "Updating" @@ -195,30 +197,30 @@ class ManagedCassandraProvisioningState(str, Enum, metaclass=CaseInsensitiveEnum FAILED = "Failed" CANCELED = "Canceled" + class ManagedCassandraResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the resource. - """ + """The type of the resource.""" SYSTEM_ASSIGNED = "SystemAssigned" NONE = "None" + class MongoRoleDefinitionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates whether the Role Definition was built-in or user created. - """ + """Indicates whether the Role Definition was built-in or user created.""" BUILT_IN_ROLE = "BuiltInRole" CUSTOM_ROLE = "CustomRole" + class NetworkAclBypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates what services are allowed to bypass firewall checks. - """ + """Indicates what services are allowed to bypass firewall checks.""" NONE = "None" AZURE_SERVICES = "AzureServices" + class NodeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The state of the node in Cassandra ring. - """ + """The state of the node in Cassandra ring.""" NORMAL = "Normal" LEAVING = "Leaving" @@ -226,38 +228,41 @@ class NodeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): MOVING = "Moving" STOPPED = "Stopped" + class NodeStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates whether the node is functioning or not. - """ + """Indicates whether the node is functioning or not.""" UP = "Up" DOWN = "Down" + class NotebookWorkspaceName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """NotebookWorkspaceName.""" DEFAULT = "default" + class OperationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Enum to indicate the operation type of the event. - """ + """Enum to indicate the operation type of the event.""" CREATE = "Create" REPLACE = "Replace" DELETE = "Delete" SYSTEM_OPERATION = "SystemOperation" + class PartitionKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the kind of algorithm used for partitioning. For MultiHash, multiple partition keys - (upto three maximum) are supported for container create + (upto three maximum) are supported for container create. """ HASH = "Hash" RANGE = "Range" MULTI_HASH = "MultiHash" + class PrimaryAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The primary aggregation type of the metric. - """ + """The primary aggregation type of the metric.""" NONE = "None" AVERAGE = "Average" @@ -266,13 +271,14 @@ class PrimaryAggregationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): MAXIMUM = "Maximum" LAST = "Last" + class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Whether requests from Public Network are allowed - """ + """Whether requests from Public Network are allowed.""" ENABLED = "Enabled" DISABLED = "Disabled" + class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """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 @@ -284,39 +290,39 @@ class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" NONE = "None" + class RestoreMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Describes the mode of the restore. - """ + """Describes the mode of the restore.""" POINT_IN_TIME = "PointInTime" + class RoleDefinitionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates whether the Role Definition was built-in or user created. - """ + """Indicates whether the Role Definition was built-in or user created.""" BUILT_IN_ROLE = "BuiltInRole" CUSTOM_ROLE = "CustomRole" + class ServerVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Describes the ServerVersion of an a MongoDB account. - """ + """Describes the ServerVersion of an a MongoDB account.""" THREE2 = "3.2" THREE6 = "3.6" FOUR0 = "4.0" FOUR2 = "4.2" + class ServiceSize(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Instance type for the service. - """ + """Instance type for the service.""" COSMOS_D4_S = "Cosmos.D4s" COSMOS_D8_S = "Cosmos.D8s" COSMOS_D16_S = "Cosmos.D16s" + class ServiceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Describes the status of a service. - """ + """Describes the status of a service.""" CREATING = "Creating" RUNNING = "Running" @@ -325,35 +331,35 @@ class ServiceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): ERROR = "Error" STOPPED = "Stopped" + class ServiceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ServiceType for the service. - """ + """ServiceType for the service.""" SQL_DEDICATED_GATEWAY = "SqlDedicatedGateway" DATA_TRANSFER = "DataTransfer" GRAPH_API_COMPUTE = "GraphAPICompute" MATERIALIZED_VIEWS_BUILDER = "MaterializedViewsBuilder" + class SpatialType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the spatial type of index. - """ + """Indicates the spatial type of index.""" POINT = "Point" LINE_STRING = "LineString" POLYGON = "Polygon" MULTI_POLYGON = "MultiPolygon" + class ThroughputPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ThroughputPolicy to apply for throughput redistribution - """ + """ThroughputPolicy to apply for throughput redistribution.""" NONE = "none" EQUAL = "equal" CUSTOM = "custom" + class TriggerOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The operation the trigger is associated with - """ + """The operation the trigger is associated with.""" ALL = "All" CREATE = "Create" @@ -361,16 +367,16 @@ class TriggerOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETE = "Delete" REPLACE = "Replace" + class TriggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of the Trigger - """ + """Type of the Trigger.""" PRE = "Pre" POST = "Post" + class UnitType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The unit of the metric. - """ + """The unit of the metric.""" COUNT = "Count" BYTES = "Bytes" 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 29302bb11e3e..3897bc549ac3 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 @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,17 +8,22 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from .. import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AccountKeyMetadata(msrest.serialization.Model): +class AccountKeyMetadata(_serialization.Model): """The metadata related to an access key for a given database account. Variables are only populated by the server, and will be ignored when sending a request. @@ -29,78 +35,64 @@ class AccountKeyMetadata(msrest.serialization.Model): """ _validation = { - 'generation_time': {'readonly': True}, + "generation_time": {"readonly": True}, } _attribute_map = { - 'generation_time': {'key': 'generationTime', 'type': 'iso-8601'}, + "generation_time": {"key": "generationTime", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AccountKeyMetadata, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.generation_time = None -class AnalyticalStorageConfiguration(msrest.serialization.Model): +class AnalyticalStorageConfiguration(_serialization.Model): """Analytical storage specific properties. :ivar schema_type: Describes the types of schema for analytical storage. Known values are: - "WellDefined", "FullFidelity". + "WellDefined" and "FullFidelity". :vartype schema_type: str or ~azure.mgmt.cosmosdb.models.AnalyticalStorageSchemaType """ _attribute_map = { - 'schema_type': {'key': 'schemaType', 'type': 'str'}, + "schema_type": {"key": "schemaType", "type": "str"}, } - def __init__( - self, - *, - schema_type: Optional[Union[str, "_models.AnalyticalStorageSchemaType"]] = None, - **kwargs - ): + def __init__(self, *, schema_type: Optional[Union[str, "_models.AnalyticalStorageSchemaType"]] = None, **kwargs): """ :keyword schema_type: Describes the types of schema for analytical storage. Known values are: - "WellDefined", "FullFidelity". + "WellDefined" and "FullFidelity". :paramtype schema_type: str or ~azure.mgmt.cosmosdb.models.AnalyticalStorageSchemaType """ - super(AnalyticalStorageConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.schema_type = schema_type -class ApiProperties(msrest.serialization.Model): +class ApiProperties(_serialization.Model): """ApiProperties. :ivar server_version: Describes the ServerVersion of an a MongoDB account. Known values are: - "3.2", "3.6", "4.0", "4.2". + "3.2", "3.6", "4.0", and "4.2". :vartype server_version: str or ~azure.mgmt.cosmosdb.models.ServerVersion """ _attribute_map = { - 'server_version': {'key': 'serverVersion', 'type': 'str'}, + "server_version": {"key": "serverVersion", "type": "str"}, } - def __init__( - self, - *, - server_version: Optional[Union[str, "_models.ServerVersion"]] = None, - **kwargs - ): + def __init__(self, *, server_version: Optional[Union[str, "_models.ServerVersion"]] = None, **kwargs): """ :keyword server_version: Describes the ServerVersion of an a MongoDB account. Known values are: - "3.2", "3.6", "4.0", "4.2". + "3.2", "3.6", "4.0", and "4.2". :paramtype server_version: str or ~azure.mgmt.cosmosdb.models.ServerVersion """ - super(ApiProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.server_version = server_version -class ARMProxyResource(msrest.serialization.Model): +class ARMProxyResource(_serialization.Model): """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. Variables are only populated by the server, and will be ignored when sending a request. @@ -114,30 +106,26 @@ class ARMProxyResource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ARMProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None -class ARMResourceProperties(msrest.serialization.Model): +class ARMResourceProperties(_serialization.Model): """The core properties of ARM resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -150,30 +138,30 @@ class ARMResourceProperties(msrest.serialization.Model): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, } def __init__( @@ -187,17 +175,17 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity """ - super(ARMResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -206,7 +194,7 @@ def __init__( self.identity = identity -class AuthenticationMethodLdapProperties(msrest.serialization.Model): +class AuthenticationMethodLdapProperties(_serialization.Model): """Ldap authentication method properties. This feature is in preview. :ivar server_hostname: Hostname of the LDAP server. @@ -229,13 +217,13 @@ class AuthenticationMethodLdapProperties(msrest.serialization.Model): """ _attribute_map = { - 'server_hostname': {'key': 'serverHostname', 'type': 'str'}, - 'server_port': {'key': 'serverPort', 'type': 'int'}, - 'service_user_distinguished_name': {'key': 'serviceUserDistinguishedName', 'type': 'str'}, - 'service_user_password': {'key': 'serviceUserPassword', 'type': 'str'}, - 'search_base_distinguished_name': {'key': 'searchBaseDistinguishedName', 'type': 'str'}, - 'search_filter_template': {'key': 'searchFilterTemplate', 'type': 'str'}, - 'server_certificates': {'key': 'serverCertificates', 'type': '[Certificate]'}, + "server_hostname": {"key": "serverHostname", "type": "str"}, + "server_port": {"key": "serverPort", "type": "int"}, + "service_user_distinguished_name": {"key": "serviceUserDistinguishedName", "type": "str"}, + "service_user_password": {"key": "serviceUserPassword", "type": "str"}, + "search_base_distinguished_name": {"key": "searchBaseDistinguishedName", "type": "str"}, + "search_filter_template": {"key": "searchFilterTemplate", "type": "str"}, + "server_certificates": {"key": "serverCertificates", "type": "[Certificate]"}, } def __init__( @@ -269,7 +257,7 @@ def __init__( :keyword server_certificates: :paramtype server_certificates: list[~azure.mgmt.cosmosdb.models.Certificate] """ - super(AuthenticationMethodLdapProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.server_hostname = server_hostname self.server_port = server_port self.service_user_distinguished_name = service_user_distinguished_name @@ -279,7 +267,7 @@ def __init__( self.server_certificates = server_certificates -class AutoscaleSettings(msrest.serialization.Model): +class AutoscaleSettings(_serialization.Model): """AutoscaleSettings. :ivar max_throughput: Represents maximum throughput, the resource can scale up to. @@ -287,31 +275,26 @@ class AutoscaleSettings(msrest.serialization.Model): """ _attribute_map = { - 'max_throughput': {'key': 'maxThroughput', 'type': 'int'}, + "max_throughput": {"key": "maxThroughput", "type": "int"}, } - def __init__( - self, - *, - max_throughput: Optional[int] = None, - **kwargs - ): + def __init__(self, *, 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) + super().__init__(**kwargs) self.max_throughput = max_throughput -class AutoscaleSettingsResource(msrest.serialization.Model): +class AutoscaleSettingsResource(_serialization.Model): """Cosmos DB provisioned throughput settings object. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar max_throughput: Required. Represents maximum throughput container can scale up to. + :ivar max_throughput: Represents maximum throughput container can scale up to. Required. :vartype max_throughput: int :ivar auto_upgrade_policy: Cosmos DB resource auto-upgrade policy. :vartype auto_upgrade_policy: ~azure.mgmt.cosmosdb.models.AutoUpgradePolicyResource @@ -321,14 +304,14 @@ class AutoscaleSettingsResource(msrest.serialization.Model): """ _validation = { - 'max_throughput': {'required': True}, - 'target_max_throughput': {'readonly': True}, + "max_throughput": {"required": True}, + "target_max_throughput": {"readonly": True}, } _attribute_map = { - 'max_throughput': {'key': 'maxThroughput', 'type': 'int'}, - 'auto_upgrade_policy': {'key': 'autoUpgradePolicy', 'type': 'AutoUpgradePolicyResource'}, - 'target_max_throughput': {'key': 'targetMaxThroughput', 'type': 'int'}, + "max_throughput": {"key": "maxThroughput", "type": "int"}, + "auto_upgrade_policy": {"key": "autoUpgradePolicy", "type": "AutoUpgradePolicyResource"}, + "target_max_throughput": {"key": "targetMaxThroughput", "type": "int"}, } def __init__( @@ -339,18 +322,18 @@ def __init__( **kwargs ): """ - :keyword max_throughput: Required. Represents maximum throughput container can scale up to. + :keyword max_throughput: Represents maximum throughput container can scale up to. Required. :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) + super().__init__(**kwargs) self.max_throughput = max_throughput self.auto_upgrade_policy = auto_upgrade_policy self.target_max_throughput = None -class AutoUpgradePolicyResource(msrest.serialization.Model): +class AutoUpgradePolicyResource(_serialization.Model): """Cosmos DB resource auto-upgrade policy. :ivar throughput_policy: Represents throughput policy which service must adhere to for @@ -359,56 +342,51 @@ class AutoUpgradePolicyResource(msrest.serialization.Model): """ _attribute_map = { - 'throughput_policy': {'key': 'throughputPolicy', 'type': 'ThroughputPolicyResource'}, + "throughput_policy": {"key": "throughputPolicy", "type": "ThroughputPolicyResource"}, } - def __init__( - self, - *, - throughput_policy: Optional["_models.ThroughputPolicyResource"] = None, - **kwargs - ): + def __init__(self, *, throughput_policy: Optional["_models.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) + super().__init__(**kwargs) self.throughput_policy = throughput_policy -class DataTransferDataSourceSink(msrest.serialization.Model): +class DataTransferDataSourceSink(_serialization.Model): """Base class for all DataTransfer source/sink. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzureBlobDataTransferDataSourceSink, CosmosCassandraDataTransferDataSourceSink, CosmosSqlDataTransferDataSourceSink. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureBlobDataTransferDataSourceSink, CosmosCassandraDataTransferDataSourceSink, + CosmosSqlDataTransferDataSourceSink All required parameters must be populated in order to send to Azure. - :ivar component: Required. Constant filled by server. Known values are: "CosmosDBCassandra", - "CosmosDBSql", "AzureBlobStorage". Default value: "CosmosDBCassandra". + :ivar component: Known values are: "CosmosDBCassandra", "CosmosDBSql", and "AzureBlobStorage". :vartype component: str or ~azure.mgmt.cosmosdb.models.DataTransferComponent """ _validation = { - 'component': {'required': True}, + "component": {"required": True}, } _attribute_map = { - 'component': {'key': 'component', 'type': 'str'}, + "component": {"key": "component", "type": "str"}, } _subtype_map = { - 'component': {'AzureBlobStorage': 'AzureBlobDataTransferDataSourceSink', 'CosmosDBCassandra': 'CosmosCassandraDataTransferDataSourceSink', 'CosmosDBSql': 'CosmosSqlDataTransferDataSourceSink'} + "component": { + "AzureBlobStorage": "AzureBlobDataTransferDataSourceSink", + "CosmosDBCassandra": "CosmosCassandraDataTransferDataSourceSink", + "CosmosDBSql": "CosmosSqlDataTransferDataSourceSink", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(DataTransferDataSourceSink, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.component = None # type: Optional[str] @@ -417,8 +395,7 @@ class AzureBlobDataTransferDataSourceSink(DataTransferDataSourceSink): All required parameters must be populated in order to send to Azure. - :ivar component: Required. Constant filled by server. Known values are: "CosmosDBCassandra", - "CosmosDBSql", "AzureBlobStorage". Default value: "CosmosDBCassandra". + :ivar component: Known values are: "CosmosDBCassandra", "CosmosDBSql", and "AzureBlobStorage". :vartype component: str or ~azure.mgmt.cosmosdb.models.DataTransferComponent :ivar container_name: Required. :vartype container_name: str @@ -427,36 +404,30 @@ class AzureBlobDataTransferDataSourceSink(DataTransferDataSourceSink): """ _validation = { - 'component': {'required': True}, - 'container_name': {'required': True}, + "component": {"required": True}, + "container_name": {"required": True}, } _attribute_map = { - 'component': {'key': 'component', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'endpoint_url': {'key': 'endpointUrl', 'type': 'str'}, + "component": {"key": "component", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "endpoint_url": {"key": "endpointUrl", "type": "str"}, } - def __init__( - self, - *, - container_name: str, - endpoint_url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, container_name: str, endpoint_url: Optional[str] = None, **kwargs): """ :keyword container_name: Required. :paramtype container_name: str :keyword endpoint_url: :paramtype endpoint_url: str """ - super(AzureBlobDataTransferDataSourceSink, self).__init__(**kwargs) - self.component = 'AzureBlobStorage' # type: str + super().__init__(**kwargs) + self.component = "AzureBlobStorage" # type: str self.container_name = container_name self.endpoint_url = endpoint_url -class BackupInformation(msrest.serialization.Model): +class BackupInformation(_serialization.Model): """Backup information of a resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -466,33 +437,29 @@ class BackupInformation(msrest.serialization.Model): """ _validation = { - 'continuous_backup_information': {'readonly': True}, + "continuous_backup_information": {"readonly": True}, } _attribute_map = { - 'continuous_backup_information': {'key': 'continuousBackupInformation', 'type': 'ContinuousBackupInformation'}, + "continuous_backup_information": {"key": "continuousBackupInformation", "type": "ContinuousBackupInformation"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BackupInformation, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.continuous_backup_information = None -class BackupPolicy(msrest.serialization.Model): +class BackupPolicy(_serialization.Model): """The object representing the policy for taking backups on an account. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ContinuousModeBackupPolicy, PeriodicModeBackupPolicy. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ContinuousModeBackupPolicy, PeriodicModeBackupPolicy All required parameters must be populated in order to send to Azure. - :ivar type: Required. Describes the mode of backups.Constant filled by server. Known values - are: "Periodic", "Continuous". + :ivar type: Describes the mode of backups. Required. Known values are: "Periodic" and + "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. @@ -500,51 +467,44 @@ class BackupPolicy(msrest.serialization.Model): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'migration_state': {'key': 'migrationState', 'type': 'BackupPolicyMigrationState'}, + "type": {"key": "type", "type": "str"}, + "migration_state": {"key": "migrationState", "type": "BackupPolicyMigrationState"}, } - _subtype_map = { - 'type': {'Continuous': 'ContinuousModeBackupPolicy', 'Periodic': 'PeriodicModeBackupPolicy'} - } + _subtype_map = {"type": {"Continuous": "ContinuousModeBackupPolicy", "Periodic": "PeriodicModeBackupPolicy"}} - def __init__( - self, - *, - migration_state: Optional["_models.BackupPolicyMigrationState"] = None, - **kwargs - ): + def __init__(self, *, migration_state: Optional["_models.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) + super().__init__(**kwargs) self.type = None # type: Optional[str] self.migration_state = migration_state -class BackupPolicyMigrationState(msrest.serialization.Model): +class BackupPolicyMigrationState(_serialization.Model): """The object representing the state of the migration between the backup policies. :ivar status: Describes the status of migration between backup policy types. Known values are: - "Invalid", "InProgress", "Completed", "Failed". + "Invalid", "InProgress", "Completed", and "Failed". :vartype status: str or ~azure.mgmt.cosmosdb.models.BackupPolicyMigrationStatus :ivar target_type: Describes the target backup policy type of the backup policy migration. - Known values are: "Periodic", "Continuous". + Known values are: "Periodic" and "Continuous". :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 = { - 'status': {'key': 'status', 'type': 'str'}, - 'target_type': {'key': 'targetType', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + "status": {"key": "status", "type": "str"}, + "target_type": {"key": "targetType", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, } def __init__( @@ -557,15 +517,15 @@ def __init__( ): """ :keyword status: Describes the status of migration between backup policy types. Known values - are: "Invalid", "InProgress", "Completed", "Failed". + are: "Invalid", "InProgress", "Completed", and "Failed". :paramtype status: str or ~azure.mgmt.cosmosdb.models.BackupPolicyMigrationStatus :keyword target_type: Describes the target backup policy type of the backup policy migration. - Known values are: "Periodic", "Continuous". + Known values are: "Periodic" and "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) + super().__init__(**kwargs) self.status = status self.target_type = target_type self.start_time = start_time @@ -587,33 +547,28 @@ class BackupResource(ARMProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'BackupResourceProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "BackupResourceProperties"}, } - def __init__( - self, - *, - properties: Optional["_models.BackupResourceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.BackupResourceProperties"] = None, **kwargs): """ :keyword properties: :paramtype properties: ~azure.mgmt.cosmosdb.models.BackupResourceProperties """ - super(BackupResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class BackupResourceProperties(msrest.serialization.Model): +class BackupResourceProperties(_serialization.Model): """BackupResourceProperties. :ivar timestamp: The time this backup was taken, formatted like 2021-01-21T17:35:21. @@ -621,24 +576,19 @@ class BackupResourceProperties(msrest.serialization.Model): """ _attribute_map = { - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - timestamp: Optional[datetime.datetime] = None, - **kwargs - ): + def __init__(self, *, timestamp: Optional[datetime.datetime] = None, **kwargs): """ :keyword timestamp: The time this backup was taken, formatted like 2021-01-21T17:35:21. :paramtype timestamp: ~datetime.datetime """ - super(BackupResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.timestamp = timestamp -class Capability(msrest.serialization.Model): +class Capability(_serialization.Model): """Cosmos DB capability object. :ivar name: Name of the Cosmos DB capability. For example, "name": "EnableCassandra". Current @@ -647,25 +597,20 @@ class Capability(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, 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) + super().__init__(**kwargs) self.name = name -class Capacity(msrest.serialization.Model): +class Capacity(_serialization.Model): """The object that represents all properties related to capacity enforcement on an account. :ivar total_throughput_limit: The total throughput limit imposed on the account. A @@ -676,19 +621,14 @@ class Capacity(msrest.serialization.Model): """ _validation = { - 'total_throughput_limit': {'minimum': -1}, + "total_throughput_limit": {"minimum": -1}, } _attribute_map = { - 'total_throughput_limit': {'key': 'totalThroughputLimit', 'type': 'int'}, + "total_throughput_limit": {"key": "totalThroughputLimit", "type": "int"}, } - def __init__( - self, - *, - total_throughput_limit: Optional[int] = None, - **kwargs - ): + def __init__(self, *, 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 @@ -696,11 +636,151 @@ def __init__( throughput. :paramtype total_throughput_limit: int """ - super(Capacity, self).__init__(**kwargs) + super().__init__(**kwargs) self.total_throughput_limit = total_throughput_limit -class CassandraClusterPublicStatus(msrest.serialization.Model): +class CassandraClusterDataCenterNodeItem(_serialization.Model): # pylint: disable=too-many-instance-attributes + """CassandraClusterDataCenterNodeItem. + + :ivar address: The node's IP address. + :vartype address: str + :ivar state: The state of the node in Cassandra ring. Known values are: "Normal", "Leaving", + "Joining", "Moving", and "Stopped". + :vartype state: str or ~azure.mgmt.cosmosdb.models.NodeState + :ivar status: + :vartype status: str + :ivar load: The amount of file system data in the data directory (e.g., 47.66 kB), excluding + all content in the snapshots subdirectories. Because all SSTable data files are included, any + data that is not cleaned up (such as TTL-expired cells or tombstones) is counted. + :vartype load: str + :ivar tokens: List of tokens this node covers. + :vartype tokens: list[str] + :ivar size: + :vartype size: int + :ivar host_id: The network ID of the node. + :vartype host_id: str + :ivar rack: The rack this node is part of. + :vartype rack: str + :ivar timestamp: The timestamp at which that snapshot of these usage statistics were taken. + :vartype timestamp: str + :ivar disk_used_kb: The amount of disk used, in kB, of the directory /var/lib/cassandra. + :vartype disk_used_kb: int + :ivar disk_free_kb: The amount of disk free, in kB, of the directory /var/lib/cassandra. + :vartype disk_free_kb: int + :ivar memory_used_kb: Used memory (calculated as total - free - buffers - cache), in kB. + :vartype memory_used_kb: int + :ivar memory_buffers_and_cached_kb: Memory used by kernel buffers (Buffers in /proc/meminfo) + and page cache and slabs (Cached and SReclaimable in /proc/meminfo), in kB. + :vartype memory_buffers_and_cached_kb: int + :ivar memory_free_kb: Unused memory (MemFree and SwapFree in /proc/meminfo), in kB. + :vartype memory_free_kb: int + :ivar memory_total_kb: Total installed memory (MemTotal and SwapTotal in /proc/meminfo), in kB. + :vartype memory_total_kb: int + :ivar cpu_usage: A float representing the current system-wide CPU utilization as a percentage. + :vartype cpu_usage: float + """ + + _attribute_map = { + "address": {"key": "address", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "load": {"key": "load", "type": "str"}, + "tokens": {"key": "tokens", "type": "[str]"}, + "size": {"key": "size", "type": "int"}, + "host_id": {"key": "hostID", "type": "str"}, + "rack": {"key": "rack", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "str"}, + "disk_used_kb": {"key": "diskUsedKB", "type": "int"}, + "disk_free_kb": {"key": "diskFreeKB", "type": "int"}, + "memory_used_kb": {"key": "memoryUsedKB", "type": "int"}, + "memory_buffers_and_cached_kb": {"key": "memoryBuffersAndCachedKB", "type": "int"}, + "memory_free_kb": {"key": "memoryFreeKB", "type": "int"}, + "memory_total_kb": {"key": "memoryTotalKB", "type": "int"}, + "cpu_usage": {"key": "cpuUsage", "type": "float"}, + } + + def __init__( + self, + *, + address: Optional[str] = None, + state: Optional[Union[str, "_models.NodeState"]] = None, + status: Optional[str] = None, + load: Optional[str] = None, + tokens: Optional[List[str]] = None, + size: Optional[int] = None, + host_id: Optional[str] = None, + rack: Optional[str] = None, + timestamp: Optional[str] = None, + disk_used_kb: Optional[int] = None, + disk_free_kb: Optional[int] = None, + memory_used_kb: Optional[int] = None, + memory_buffers_and_cached_kb: Optional[int] = None, + memory_free_kb: Optional[int] = None, + memory_total_kb: Optional[int] = None, + cpu_usage: Optional[float] = None, + **kwargs + ): + """ + :keyword address: The node's IP address. + :paramtype address: str + :keyword state: The state of the node in Cassandra ring. Known values are: "Normal", "Leaving", + "Joining", "Moving", and "Stopped". + :paramtype state: str or ~azure.mgmt.cosmosdb.models.NodeState + :keyword status: + :paramtype status: str + :keyword 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 at which that snapshot of these usage statistics were taken. + :paramtype timestamp: str + :keyword disk_used_kb: The amount of disk used, in kB, of the directory /var/lib/cassandra. + :paramtype disk_used_kb: int + :keyword disk_free_kb: The amount of disk free, in kB, of the directory /var/lib/cassandra. + :paramtype disk_free_kb: int + :keyword memory_used_kb: Used memory (calculated as total - free - buffers - cache), in kB. + :paramtype memory_used_kb: int + :keyword memory_buffers_and_cached_kb: Memory used by kernel buffers (Buffers in /proc/meminfo) + and page cache and slabs (Cached and SReclaimable in /proc/meminfo), in kB. + :paramtype memory_buffers_and_cached_kb: int + :keyword memory_free_kb: Unused memory (MemFree and SwapFree in /proc/meminfo), in kB. + :paramtype memory_free_kb: int + :keyword memory_total_kb: Total installed memory (MemTotal and SwapTotal in /proc/meminfo), in + kB. + :paramtype memory_total_kb: int + :keyword cpu_usage: A float representing the current system-wide CPU utilization as a + percentage. + :paramtype cpu_usage: float + """ + super().__init__(**kwargs) + self.address = address + self.state = state + self.status = status + self.load = load + self.tokens = tokens + self.size = size + self.host_id = host_id + self.rack = rack + self.timestamp = timestamp + self.disk_used_kb = disk_used_kb + self.disk_free_kb = disk_free_kb + self.memory_used_kb = memory_used_kb + self.memory_buffers_and_cached_kb = memory_buffers_and_cached_kb + self.memory_free_kb = memory_free_kb + self.memory_total_kb = memory_total_kb + self.cpu_usage = cpu_usage + + +class CassandraClusterPublicStatus(_serialization.Model): """Properties of a managed Cassandra cluster public status. :ivar e_tag: @@ -716,10 +796,10 @@ class CassandraClusterPublicStatus(msrest.serialization.Model): """ _attribute_map = { - 'e_tag': {'key': 'eTag', 'type': 'str'}, - 'reaper_status': {'key': 'reaperStatus', 'type': 'ManagedCassandraReaperStatus'}, - 'connection_errors': {'key': 'connectionErrors', 'type': '[ConnectionError]'}, - 'data_centers': {'key': 'dataCenters', 'type': '[CassandraClusterPublicStatusDataCentersItem]'}, + "e_tag": {"key": "eTag", "type": "str"}, + "reaper_status": {"key": "reaperStatus", "type": "ManagedCassandraReaperStatus"}, + "connection_errors": {"key": "connectionErrors", "type": "[ConnectionError]"}, + "data_centers": {"key": "dataCenters", "type": "[CassandraClusterPublicStatusDataCentersItem]"}, } def __init__( @@ -743,14 +823,14 @@ def __init__( :paramtype data_centers: list[~azure.mgmt.cosmosdb.models.CassandraClusterPublicStatusDataCentersItem] """ - super(CassandraClusterPublicStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.e_tag = e_tag self.reaper_status = reaper_status self.connection_errors = connection_errors self.data_centers = data_centers -class CassandraClusterPublicStatusDataCentersItem(msrest.serialization.Model): +class CassandraClusterPublicStatusDataCentersItem(_serialization.Model): """CassandraClusterPublicStatusDataCentersItem. :ivar name: The name of this Datacenter. @@ -758,14 +838,13 @@ class CassandraClusterPublicStatusDataCentersItem(msrest.serialization.Model): :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] + :vartype nodes: list[~azure.mgmt.cosmosdb.models.CassandraClusterDataCenterNodeItem] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'seed_nodes': {'key': 'seedNodes', 'type': '[str]'}, - 'nodes': {'key': 'nodes', 'type': '[ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems]'}, + "name": {"key": "name", "type": "str"}, + "seed_nodes": {"key": "seedNodes", "type": "[str]"}, + "nodes": {"key": "nodes", "type": "[CassandraClusterDataCenterNodeItem]"}, } def __init__( @@ -773,7 +852,7 @@ def __init__( *, name: Optional[str] = None, seed_nodes: Optional[List[str]] = None, - nodes: Optional[List["_models.ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems"]] = None, + nodes: Optional[List["_models.CassandraClusterDataCenterNodeItem"]] = None, **kwargs ): """ @@ -782,10 +861,9 @@ def __init__( :keyword seed_nodes: A list of all seed nodes in the cluster, managed and unmanaged. :paramtype seed_nodes: list[str] :keyword nodes: - :paramtype nodes: - list[~azure.mgmt.cosmosdb.models.ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems] + :paramtype nodes: list[~azure.mgmt.cosmosdb.models.CassandraClusterDataCenterNodeItem] """ - super(CassandraClusterPublicStatusDataCentersItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.seed_nodes = seed_nodes self.nodes = nodes @@ -806,16 +884,16 @@ class CassandraKeyspaceCreateUpdateParameters(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :ivar resource: Required. The standard JSON format of a Cassandra keyspace. + :ivar resource: The standard JSON format of a Cassandra keyspace. Required. :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. @@ -823,21 +901,21 @@ class CassandraKeyspaceCreateUpdateParameters(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'CassandraKeyspaceResource'}, - 'options': {'key': 'properties.options', 'type': 'CreateUpdateOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "CassandraKeyspaceResource"}, + "options": {"key": "properties.options", "type": "CreateUpdateOptions"}, } def __init__( @@ -853,27 +931,27 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :keyword resource: Required. The standard JSON format of a Cassandra keyspace. + :keyword resource: The standard JSON format of a Cassandra keyspace. Required. :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, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options -class OptionsResource(msrest.serialization.Model): +class OptionsResource(_serialization.Model): """Cosmos DB options resource object. :ivar throughput: Value of the Cosmos DB resource throughput or autoscaleSettings. Use the @@ -884,8 +962,8 @@ class OptionsResource(msrest.serialization.Model): """ _attribute_map = { - 'throughput': {'key': 'throughput', 'type': 'int'}, - 'autoscale_settings': {'key': 'autoscaleSettings', 'type': 'AutoscaleSettings'}, + "throughput": {"key": "throughput", "type": "int"}, + "autoscale_settings": {"key": "autoscaleSettings", "type": "AutoscaleSettings"}, } def __init__( @@ -902,7 +980,7 @@ def __init__( :keyword autoscale_settings: Specifies the Autoscale settings. :paramtype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings """ - super(OptionsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.throughput = throughput self.autoscale_settings = autoscale_settings @@ -918,8 +996,8 @@ class CassandraKeyspaceGetPropertiesOptions(OptionsResource): """ _attribute_map = { - 'throughput': {'key': 'throughput', 'type': 'int'}, - 'autoscale_settings': {'key': 'autoscaleSettings', 'type': 'AutoscaleSettings'}, + "throughput": {"key": "throughput", "type": "int"}, + "autoscale_settings": {"key": "autoscaleSettings", "type": "AutoscaleSettings"}, } def __init__( @@ -936,87 +1014,76 @@ def __init__( :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) + super().__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) -class CassandraKeyspaceResource(msrest.serialization.Model): - """Cosmos DB Cassandra keyspace resource object. +class ExtendedResourceProperties(_serialization.Model): + """The system generated resource properties associated with SQL databases, SQL containers, Gremlin databases and Gremlin graphs. - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :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. + :vartype ts: float + :ivar etag: A system generated property representing the resource etag required for optimistic + concurrency control. + :vartype etag: str """ _validation = { - 'id': {'required': True}, + "rid": {"readonly": True}, + "ts": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): - """ - :keyword id: Required. Name of the Cosmos DB Cassandra keyspace. - :paramtype id: str - """ - super(CassandraKeyspaceResource, self).__init__(**kwargs) - self.id = id + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.rid = None + self.ts = None + self.etag = None -class ExtendedResourceProperties(msrest.serialization.Model): - """The system generated resource properties associated with SQL databases, SQL containers, Gremlin databases and Gremlin graphs. +class CassandraKeyspaceResource(_serialization.Model): + """Cosmos DB Cassandra keyspace resource object. - Variables are only populated by the server, and will be ignored when sending a request. + All required parameters must be populated in order to send to Azure. - :ivar rid: A system generated property. A unique identifier. - :vartype rid: str - :ivar ts: A system generated property that denotes the last updated timestamp of the resource. - :vartype ts: float - :ivar etag: A system generated property representing the resource etag required for optimistic - concurrency control. - :vartype etag: str + :ivar id: Name of the Cosmos DB Cassandra keyspace. Required. + :vartype id: str """ _validation = { - 'rid': {'readonly': True}, - 'ts': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"required": True}, } _attribute_map = { - 'rid': {'key': '_rid', 'type': 'str'}, - 'ts': {'key': '_ts', 'type': 'float'}, - 'etag': {'key': '_etag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ + :keyword id: Name of the Cosmos DB Cassandra keyspace. Required. + :paramtype id: str """ - super(ExtendedResourceProperties, self).__init__(**kwargs) - self.rid = None - self.ts = None - self.etag = None + super().__init__(**kwargs) + self.id = id -class CassandraKeyspaceGetPropertiesResource(ExtendedResourceProperties, CassandraKeyspaceResource): +class CassandraKeyspaceGetPropertiesResource(CassandraKeyspaceResource, ExtendedResourceProperties): """CassandraKeyspaceGetPropertiesResource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :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. @@ -1024,37 +1091,34 @@ class CassandraKeyspaceGetPropertiesResource(ExtendedResourceProperties, Cassand :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str + :ivar id: Name of the Cosmos DB Cassandra keyspace. Required. + :vartype id: str """ _validation = { - 'id': {'required': True}, - 'rid': {'readonly': True}, - 'ts': {'readonly': True}, - 'etag': {'readonly': True}, + "rid": {"readonly": True}, + "ts": {"readonly": True}, + "etag": {"readonly": True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'rid': {'key': '_rid', 'type': 'str'}, - 'ts': {'key': '_ts', 'type': 'float'}, - 'etag': {'key': '_etag', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Name of the Cosmos DB Cassandra keyspace. + :keyword id: Name of the Cosmos DB Cassandra keyspace. Required. :paramtype id: str """ - super(CassandraKeyspaceGetPropertiesResource, self).__init__(id=id, **kwargs) - self.id = id + super().__init__(id=id, **kwargs) self.rid = None self.ts = None self.etag = None + self.id = id class CassandraKeyspaceGetResults(ARMResourceProperties): @@ -1070,12 +1134,12 @@ class CassandraKeyspaceGetResults(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -1086,20 +1150,20 @@ class CassandraKeyspaceGetResults(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'CassandraKeyspaceGetPropertiesResource'}, - 'options': {'key': 'properties.options', 'type': 'CassandraKeyspaceGetPropertiesOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "CassandraKeyspaceGetPropertiesResource"}, + "options": {"key": "properties.options", "type": "CassandraKeyspaceGetPropertiesOptions"}, } def __init__( @@ -1115,12 +1179,12 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -1129,12 +1193,12 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetPropertiesOptions """ - super(CassandraKeyspaceGetResults, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options -class CassandraKeyspaceListResult(msrest.serialization.Model): +class CassandraKeyspaceListResult(_serialization.Model): """The List operation response, that contains the Cassandra keyspaces and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1144,24 +1208,20 @@ class CassandraKeyspaceListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[CassandraKeyspaceGetResults]'}, + "value": {"key": "value", "type": "[CassandraKeyspaceGetResults]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CassandraKeyspaceListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class CassandraPartitionKey(msrest.serialization.Model): +class CassandraPartitionKey(_serialization.Model): """Cosmos DB Cassandra table partition key. :ivar name: Name of the Cosmos DB Cassandra table partition key. @@ -1169,24 +1229,19 @@ class CassandraPartitionKey(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: Name of the Cosmos DB Cassandra table partition key. :paramtype name: str """ - super(CassandraPartitionKey, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class CassandraSchema(msrest.serialization.Model): +class CassandraSchema(_serialization.Model): """Cosmos DB Cassandra table schema. :ivar columns: List of Cassandra table columns. @@ -1198,9 +1253,9 @@ class CassandraSchema(msrest.serialization.Model): """ _attribute_map = { - 'columns': {'key': 'columns', 'type': '[Column]'}, - 'partition_keys': {'key': 'partitionKeys', 'type': '[CassandraPartitionKey]'}, - 'cluster_keys': {'key': 'clusterKeys', 'type': '[ClusterKey]'}, + "columns": {"key": "columns", "type": "[Column]"}, + "partition_keys": {"key": "partitionKeys", "type": "[CassandraPartitionKey]"}, + "cluster_keys": {"key": "clusterKeys", "type": "[ClusterKey]"}, } def __init__( @@ -1219,7 +1274,7 @@ def __init__( :keyword cluster_keys: List of cluster key. :paramtype cluster_keys: list[~azure.mgmt.cosmosdb.models.ClusterKey] """ - super(CassandraSchema, self).__init__(**kwargs) + super().__init__(**kwargs) self.columns = columns self.partition_keys = partition_keys self.cluster_keys = cluster_keys @@ -1240,16 +1295,16 @@ class CassandraTableCreateUpdateParameters(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :ivar resource: Required. The standard JSON format of a Cassandra table. + :ivar resource: The standard JSON format of a Cassandra table. Required. :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. @@ -1257,21 +1312,21 @@ class CassandraTableCreateUpdateParameters(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'CassandraTableResource'}, - 'options': {'key': 'properties.options', 'type': 'CreateUpdateOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "CassandraTableResource"}, + "options": {"key": "properties.options", "type": "CreateUpdateOptions"}, } def __init__( @@ -1287,22 +1342,22 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :keyword resource: Required. The standard JSON format of a Cassandra table. + :keyword resource: The standard JSON format of a Cassandra table. Required. :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, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options @@ -1318,8 +1373,8 @@ class CassandraTableGetPropertiesOptions(OptionsResource): """ _attribute_map = { - 'throughput': {'key': 'throughput', 'type': 'int'}, - 'autoscale_settings': {'key': 'autoscaleSettings', 'type': 'AutoscaleSettings'}, + "throughput": {"key": "throughput", "type": "int"}, + "autoscale_settings": {"key": "autoscaleSettings", "type": "AutoscaleSettings"}, } def __init__( @@ -1336,15 +1391,15 @@ def __init__( :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) + super().__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) -class CassandraTableResource(msrest.serialization.Model): +class CassandraTableResource(_serialization.Model): """Cosmos DB Cassandra table resource object. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Name of the Cosmos DB Cassandra table. + :ivar id: Name of the Cosmos DB Cassandra table. Required. :vartype id: str :ivar default_ttl: Time to live of the Cosmos DB Cassandra table. :vartype default_ttl: int @@ -1355,27 +1410,27 @@ class CassandraTableResource(msrest.serialization.Model): """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'default_ttl': {'key': 'defaultTtl', 'type': 'int'}, - 'schema': {'key': 'schema', 'type': 'CassandraSchema'}, - 'analytical_storage_ttl': {'key': 'analyticalStorageTtl', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "default_ttl": {"key": "defaultTtl", "type": "int"}, + "schema": {"key": "schema", "type": "CassandraSchema"}, + "analytical_storage_ttl": {"key": "analyticalStorageTtl", "type": "int"}, } def __init__( self, *, - id: str, + id: str, # pylint: disable=redefined-builtin default_ttl: Optional[int] = None, schema: Optional["_models.CassandraSchema"] = None, analytical_storage_ttl: Optional[int] = None, **kwargs ): """ - :keyword id: Required. Name of the Cosmos DB Cassandra table. + :keyword id: Name of the Cosmos DB Cassandra table. Required. :paramtype id: str :keyword default_ttl: Time to live of the Cosmos DB Cassandra table. :paramtype default_ttl: int @@ -1384,28 +1439,20 @@ def __init__( :keyword analytical_storage_ttl: Analytical TTL. :paramtype analytical_storage_ttl: int """ - super(CassandraTableResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.default_ttl = default_ttl self.schema = schema self.analytical_storage_ttl = analytical_storage_ttl -class CassandraTableGetPropertiesResource(ExtendedResourceProperties, CassandraTableResource): +class CassandraTableGetPropertiesResource(CassandraTableResource, ExtendedResourceProperties): """CassandraTableGetPropertiesResource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :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. @@ -1413,36 +1460,44 @@ class CassandraTableGetPropertiesResource(ExtendedResourceProperties, CassandraT :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str + :ivar id: Name of the Cosmos DB Cassandra table. Required. + :vartype id: str + :ivar default_ttl: Time to live of the Cosmos DB Cassandra table. + :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 = { - 'id': {'required': True}, - 'rid': {'readonly': True}, - 'ts': {'readonly': True}, - 'etag': {'readonly': True}, + "rid": {"readonly": True}, + "ts": {"readonly": True}, + "etag": {"readonly": True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'default_ttl': {'key': 'defaultTtl', 'type': 'int'}, - 'schema': {'key': 'schema', 'type': 'CassandraSchema'}, - 'analytical_storage_ttl': {'key': 'analyticalStorageTtl', 'type': 'int'}, - 'rid': {'key': '_rid', 'type': 'str'}, - 'ts': {'key': '_ts', 'type': 'float'}, - 'etag': {'key': '_etag', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "default_ttl": {"key": "defaultTtl", "type": "int"}, + "schema": {"key": "schema", "type": "CassandraSchema"}, + "analytical_storage_ttl": {"key": "analyticalStorageTtl", "type": "int"}, } def __init__( self, *, - id: str, + id: str, # pylint: disable=redefined-builtin default_ttl: Optional[int] = None, schema: Optional["_models.CassandraSchema"] = None, analytical_storage_ttl: Optional[int] = None, **kwargs ): """ - :keyword id: Required. Name of the Cosmos DB Cassandra table. + :keyword id: Name of the Cosmos DB Cassandra table. Required. :paramtype id: str :keyword default_ttl: Time to live of the Cosmos DB Cassandra table. :paramtype default_ttl: int @@ -1451,14 +1506,16 @@ def __init__( :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) + super().__init__( + id=id, default_ttl=default_ttl, schema=schema, analytical_storage_ttl=analytical_storage_ttl, **kwargs + ) + self.rid = None + self.ts = None + self.etag = None self.id = id self.default_ttl = default_ttl self.schema = schema self.analytical_storage_ttl = analytical_storage_ttl - self.rid = None - self.ts = None - self.etag = None class CassandraTableGetResults(ARMResourceProperties): @@ -1474,12 +1531,12 @@ class CassandraTableGetResults(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -1490,20 +1547,20 @@ class CassandraTableGetResults(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'CassandraTableGetPropertiesResource'}, - 'options': {'key': 'properties.options', 'type': 'CassandraTableGetPropertiesOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "CassandraTableGetPropertiesResource"}, + "options": {"key": "properties.options", "type": "CassandraTableGetPropertiesOptions"}, } def __init__( @@ -1519,12 +1576,12 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -1533,12 +1590,12 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.CassandraTableGetPropertiesOptions """ - super(CassandraTableGetResults, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options -class CassandraTableListResult(msrest.serialization.Model): +class CassandraTableListResult(_serialization.Model): """The List operation response, that contains the Cassandra tables and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1548,20 +1605,16 @@ class CassandraTableListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[CassandraTableGetResults]'}, + "value": {"key": "value", "type": "[CassandraTableGetResults]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CassandraTableListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -1580,16 +1633,16 @@ class CassandraViewCreateUpdateParameters(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :ivar resource: Required. The standard JSON format of a Cassandra view. + :ivar resource: The standard JSON format of a Cassandra view. Required. :vartype resource: ~azure.mgmt.cosmosdb.models.CassandraViewResource :ivar options: A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. @@ -1597,21 +1650,21 @@ class CassandraViewCreateUpdateParameters(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'CassandraViewResource'}, - 'options': {'key': 'properties.options', 'type': 'CreateUpdateOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "CassandraViewResource"}, + "options": {"key": "properties.options", "type": "CreateUpdateOptions"}, } def __init__( @@ -1627,22 +1680,22 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :keyword resource: Required. The standard JSON format of a Cassandra view. + :keyword resource: The standard JSON format of a Cassandra view. Required. :paramtype resource: ~azure.mgmt.cosmosdb.models.CassandraViewResource :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(CassandraViewCreateUpdateParameters, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options @@ -1658,8 +1711,8 @@ class CassandraViewGetPropertiesOptions(OptionsResource): """ _attribute_map = { - 'throughput': {'key': 'throughput', 'type': 'int'}, - 'autoscale_settings': {'key': 'autoscaleSettings', 'type': 'AutoscaleSettings'}, + "throughput": {"key": "throughput", "type": "int"}, + "autoscale_settings": {"key": "autoscaleSettings", "type": "AutoscaleSettings"}, } def __init__( @@ -1676,59 +1729,49 @@ def __init__( :keyword autoscale_settings: Specifies the Autoscale settings. :paramtype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings """ - super(CassandraViewGetPropertiesOptions, self).__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) + super().__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) -class CassandraViewResource(msrest.serialization.Model): +class CassandraViewResource(_serialization.Model): """Cosmos DB Cassandra view resource object. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Name of the Cosmos DB Cassandra view. + :ivar id: Name of the Cosmos DB Cassandra view. Required. :vartype id: str - :ivar view_definition: Required. View Definition of the Cosmos DB Cassandra view. + :ivar view_definition: View Definition of the Cosmos DB Cassandra view. Required. :vartype view_definition: str """ _validation = { - 'id': {'required': True}, - 'view_definition': {'required': True}, + "id": {"required": True}, + "view_definition": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'view_definition': {'key': 'viewDefinition', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "view_definition": {"key": "viewDefinition", "type": "str"}, } - def __init__( - self, - *, - id: str, - view_definition: str, - **kwargs - ): + def __init__(self, *, id: str, view_definition: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Name of the Cosmos DB Cassandra view. + :keyword id: Name of the Cosmos DB Cassandra view. Required. :paramtype id: str - :keyword view_definition: Required. View Definition of the Cosmos DB Cassandra view. + :keyword view_definition: View Definition of the Cosmos DB Cassandra view. Required. :paramtype view_definition: str """ - super(CassandraViewResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.view_definition = view_definition -class CassandraViewGetPropertiesResource(ExtendedResourceProperties, CassandraViewResource): +class CassandraViewGetPropertiesResource(CassandraViewResource, ExtendedResourceProperties): """CassandraViewGetPropertiesResource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Name of the Cosmos DB Cassandra view. - :vartype id: str - :ivar view_definition: Required. View Definition of the Cosmos DB Cassandra view. - :vartype view_definition: str :ivar rid: A system generated property. A unique identifier. :vartype rid: str :ivar ts: A system generated property that denotes the last updated timestamp of the resource. @@ -1736,43 +1779,41 @@ class CassandraViewGetPropertiesResource(ExtendedResourceProperties, CassandraVi :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str + :ivar id: Name of the Cosmos DB Cassandra view. Required. + :vartype id: str + :ivar view_definition: View Definition of the Cosmos DB Cassandra view. Required. + :vartype view_definition: str """ _validation = { - 'id': {'required': True}, - 'view_definition': {'required': True}, - 'rid': {'readonly': True}, - 'ts': {'readonly': True}, - 'etag': {'readonly': True}, + "rid": {"readonly": True}, + "ts": {"readonly": True}, + "etag": {"readonly": True}, + "id": {"required": True}, + "view_definition": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'view_definition': {'key': 'viewDefinition', 'type': 'str'}, - 'rid': {'key': '_rid', 'type': 'str'}, - 'ts': {'key': '_ts', 'type': 'float'}, - 'etag': {'key': '_etag', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "view_definition": {"key": "viewDefinition", "type": "str"}, } - def __init__( - self, - *, - id: str, - view_definition: str, - **kwargs - ): + def __init__(self, *, id: str, view_definition: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Name of the Cosmos DB Cassandra view. + :keyword id: Name of the Cosmos DB Cassandra view. Required. :paramtype id: str - :keyword view_definition: Required. View Definition of the Cosmos DB Cassandra view. + :keyword view_definition: View Definition of the Cosmos DB Cassandra view. Required. :paramtype view_definition: str """ - super(CassandraViewGetPropertiesResource, self).__init__(id=id, view_definition=view_definition, **kwargs) - self.id = id - self.view_definition = view_definition + super().__init__(id=id, view_definition=view_definition, **kwargs) self.rid = None self.ts = None self.etag = None + self.id = id + self.view_definition = view_definition class CassandraViewGetResults(ARMResourceProperties): @@ -1788,12 +1829,12 @@ class CassandraViewGetResults(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -1804,20 +1845,20 @@ class CassandraViewGetResults(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'CassandraViewGetPropertiesResource'}, - 'options': {'key': 'properties.options', 'type': 'CassandraViewGetPropertiesOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "CassandraViewGetPropertiesResource"}, + "options": {"key": "properties.options", "type": "CassandraViewGetPropertiesOptions"}, } def __init__( @@ -1833,12 +1874,12 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -1847,12 +1888,12 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.CassandraViewGetPropertiesOptions """ - super(CassandraViewGetResults, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options -class CassandraViewListResult(msrest.serialization.Model): +class CassandraViewListResult(_serialization.Model): """The List operation response, that contains the Cassandra views and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1862,24 +1903,20 @@ class CassandraViewListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[CassandraViewGetResults]'}, + "value": {"key": "value", "type": "[CassandraViewGetResults]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CassandraViewListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class Certificate(msrest.serialization.Model): +class Certificate(_serialization.Model): """Certificate. :ivar pem: PEM formatted public key. @@ -1887,116 +1924,100 @@ class Certificate(msrest.serialization.Model): """ _attribute_map = { - 'pem': {'key': 'pem', 'type': 'str'}, + "pem": {"key": "pem", "type": "str"}, } - def __init__( - self, - *, - pem: Optional[str] = None, - **kwargs - ): + def __init__(self, *, pem: Optional[str] = None, **kwargs): """ :keyword pem: PEM formatted public key. :paramtype pem: str """ - super(Certificate, self).__init__(**kwargs) + super().__init__(**kwargs) self.pem = pem -class ClientEncryptionIncludedPath(msrest.serialization.Model): +class ClientEncryptionIncludedPath(_serialization.Model): """. All required parameters must be populated in order to send to Azure. - :ivar path: Required. Path that needs to be encrypted. + :ivar path: Path that needs to be encrypted. Required. :vartype path: str - :ivar client_encryption_key_id: Required. The identifier of the Client Encryption Key to be - used to encrypt the path. + :ivar client_encryption_key_id: The identifier of the Client Encryption Key to be used to + encrypt the path. Required. :vartype client_encryption_key_id: str - :ivar encryption_type: Required. The type of encryption to be performed. Eg - Deterministic, - Randomized. + :ivar encryption_type: The type of encryption to be performed. Eg - Deterministic, Randomized. + Required. :vartype encryption_type: str - :ivar encryption_algorithm: Required. The encryption algorithm which will be used. Eg - - AEAD_AES_256_CBC_HMAC_SHA256. + :ivar encryption_algorithm: The encryption algorithm which will be used. Eg - + AEAD_AES_256_CBC_HMAC_SHA256. Required. :vartype encryption_algorithm: str """ _validation = { - 'path': {'required': True}, - 'client_encryption_key_id': {'required': True}, - 'encryption_type': {'required': True}, - 'encryption_algorithm': {'required': True}, + "path": {"required": True}, + "client_encryption_key_id": {"required": True}, + "encryption_type": {"required": True}, + "encryption_algorithm": {"required": True}, } _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'client_encryption_key_id': {'key': 'clientEncryptionKeyId', 'type': 'str'}, - 'encryption_type': {'key': 'encryptionType', 'type': 'str'}, - 'encryption_algorithm': {'key': 'encryptionAlgorithm', 'type': 'str'}, + "path": {"key": "path", "type": "str"}, + "client_encryption_key_id": {"key": "clientEncryptionKeyId", "type": "str"}, + "encryption_type": {"key": "encryptionType", "type": "str"}, + "encryption_algorithm": {"key": "encryptionAlgorithm", "type": "str"}, } def __init__( - self, - *, - path: str, - client_encryption_key_id: str, - encryption_type: str, - encryption_algorithm: str, - **kwargs + self, *, path: str, client_encryption_key_id: str, encryption_type: str, encryption_algorithm: str, **kwargs ): """ - :keyword path: Required. Path that needs to be encrypted. + :keyword path: Path that needs to be encrypted. Required. :paramtype path: str - :keyword client_encryption_key_id: Required. The identifier of the Client Encryption Key to be - used to encrypt the path. + :keyword client_encryption_key_id: The identifier of the Client Encryption Key to be used to + encrypt the path. Required. :paramtype client_encryption_key_id: str - :keyword encryption_type: Required. The type of encryption to be performed. Eg - Deterministic, - Randomized. + :keyword encryption_type: The type of encryption to be performed. Eg - Deterministic, + Randomized. Required. :paramtype encryption_type: str - :keyword encryption_algorithm: Required. The encryption algorithm which will be used. Eg - - AEAD_AES_256_CBC_HMAC_SHA256. + :keyword encryption_algorithm: The encryption algorithm which will be used. Eg - + AEAD_AES_256_CBC_HMAC_SHA256. Required. :paramtype encryption_algorithm: str """ - super(ClientEncryptionIncludedPath, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.client_encryption_key_id = client_encryption_key_id self.encryption_type = encryption_type self.encryption_algorithm = encryption_algorithm -class ClientEncryptionKeyCreateUpdateParameters(msrest.serialization.Model): +class ClientEncryptionKeyCreateUpdateParameters(_serialization.Model): """Parameters to create and update ClientEncryptionKey. All required parameters must be populated in order to send to Azure. - :ivar resource: Required. The standard JSON format of a ClientEncryptionKey. + :ivar resource: The standard JSON format of a ClientEncryptionKey. Required. :vartype resource: ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyResource """ _validation = { - 'resource': {'required': True}, + "resource": {"required": True}, } _attribute_map = { - 'resource': {'key': 'properties.resource', 'type': 'ClientEncryptionKeyResource'}, + "resource": {"key": "properties.resource", "type": "ClientEncryptionKeyResource"}, } - def __init__( - self, - *, - resource: "_models.ClientEncryptionKeyResource", - **kwargs - ): + def __init__(self, *, resource: "_models.ClientEncryptionKeyResource", **kwargs): """ - :keyword resource: Required. The standard JSON format of a ClientEncryptionKey. + :keyword resource: The standard JSON format of a ClientEncryptionKey. Required. :paramtype resource: ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyResource """ - super(ClientEncryptionKeyCreateUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource = resource -class ClientEncryptionKeyResource(msrest.serialization.Model): +class ClientEncryptionKeyResource(_serialization.Model): """Cosmos DB client encryption key resource object. :ivar id: Name of the ClientEncryptionKey. @@ -2006,25 +2027,25 @@ class ClientEncryptionKeyResource(msrest.serialization.Model): :vartype encryption_algorithm: str :ivar wrapped_data_encryption_key: Wrapped (encrypted) form of the key represented as a byte array. - :vartype wrapped_data_encryption_key: bytearray + :vartype wrapped_data_encryption_key: bytes :ivar key_wrap_metadata: Metadata for the wrapping provider that can be used to unwrap the wrapped client encryption key. :vartype key_wrap_metadata: ~azure.mgmt.cosmosdb.models.KeyWrapMetadata """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'encryption_algorithm': {'key': 'encryptionAlgorithm', 'type': 'str'}, - 'wrapped_data_encryption_key': {'key': 'wrappedDataEncryptionKey', 'type': 'bytearray'}, - 'key_wrap_metadata': {'key': 'keyWrapMetadata', 'type': 'KeyWrapMetadata'}, + "id": {"key": "id", "type": "str"}, + "encryption_algorithm": {"key": "encryptionAlgorithm", "type": "str"}, + "wrapped_data_encryption_key": {"key": "wrappedDataEncryptionKey", "type": "bytearray"}, + "key_wrap_metadata": {"key": "keyWrapMetadata", "type": "KeyWrapMetadata"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin encryption_algorithm: Optional[str] = None, - wrapped_data_encryption_key: Optional[bytearray] = None, + wrapped_data_encryption_key: Optional[bytes] = None, key_wrap_metadata: Optional["_models.KeyWrapMetadata"] = None, **kwargs ): @@ -2036,23 +2057,30 @@ def __init__( :paramtype encryption_algorithm: str :keyword wrapped_data_encryption_key: Wrapped (encrypted) form of the key represented as a byte array. - :paramtype wrapped_data_encryption_key: bytearray + :paramtype wrapped_data_encryption_key: bytes :keyword key_wrap_metadata: Metadata for the wrapping provider that can be used to unwrap the wrapped client encryption key. :paramtype key_wrap_metadata: ~azure.mgmt.cosmosdb.models.KeyWrapMetadata """ - super(ClientEncryptionKeyResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.encryption_algorithm = encryption_algorithm self.wrapped_data_encryption_key = wrapped_data_encryption_key self.key_wrap_metadata = key_wrap_metadata -class ClientEncryptionKeyGetPropertiesResource(ExtendedResourceProperties, ClientEncryptionKeyResource): +class ClientEncryptionKeyGetPropertiesResource(ClientEncryptionKeyResource, ExtendedResourceProperties): """ClientEncryptionKeyGetPropertiesResource. Variables are only populated by the server, and will be ignored when sending a request. + :ivar rid: A system generated property. A unique identifier. + :vartype rid: str + :ivar ts: A system generated property that denotes the last updated timestamp of the resource. + :vartype ts: float + :ivar etag: A system generated property representing the resource etag required for optimistic + concurrency control. + :vartype etag: str :ivar id: Name of the ClientEncryptionKey. :vartype id: str :ivar encryption_algorithm: Encryption algorithm that will be used along with this client @@ -2060,41 +2088,34 @@ class ClientEncryptionKeyGetPropertiesResource(ExtendedResourceProperties, Clien :vartype encryption_algorithm: str :ivar wrapped_data_encryption_key: Wrapped (encrypted) form of the key represented as a byte array. - :vartype wrapped_data_encryption_key: bytearray + :vartype wrapped_data_encryption_key: bytes :ivar key_wrap_metadata: Metadata for the wrapping provider that can be used to unwrap the wrapped client encryption key. :vartype key_wrap_metadata: ~azure.mgmt.cosmosdb.models.KeyWrapMetadata - :ivar rid: A system generated property. A unique identifier. - :vartype rid: str - :ivar ts: A system generated property that denotes the last updated timestamp of the resource. - :vartype ts: float - :ivar etag: A system generated property representing the resource etag required for optimistic - concurrency control. - :vartype etag: str """ _validation = { - 'rid': {'readonly': True}, - 'ts': {'readonly': True}, - 'etag': {'readonly': True}, + "rid": {"readonly": True}, + "ts": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'encryption_algorithm': {'key': 'encryptionAlgorithm', 'type': 'str'}, - 'wrapped_data_encryption_key': {'key': 'wrappedDataEncryptionKey', 'type': 'bytearray'}, - 'key_wrap_metadata': {'key': 'keyWrapMetadata', 'type': 'KeyWrapMetadata'}, - 'rid': {'key': '_rid', 'type': 'str'}, - 'ts': {'key': '_ts', 'type': 'float'}, - 'etag': {'key': '_etag', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "encryption_algorithm": {"key": "encryptionAlgorithm", "type": "str"}, + "wrapped_data_encryption_key": {"key": "wrappedDataEncryptionKey", "type": "bytearray"}, + "key_wrap_metadata": {"key": "keyWrapMetadata", "type": "KeyWrapMetadata"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin encryption_algorithm: Optional[str] = None, - wrapped_data_encryption_key: Optional[bytearray] = None, + wrapped_data_encryption_key: Optional[bytes] = None, key_wrap_metadata: Optional["_models.KeyWrapMetadata"] = None, **kwargs ): @@ -2106,19 +2127,25 @@ def __init__( :paramtype encryption_algorithm: str :keyword wrapped_data_encryption_key: Wrapped (encrypted) form of the key represented as a byte array. - :paramtype wrapped_data_encryption_key: bytearray + :paramtype wrapped_data_encryption_key: bytes :keyword key_wrap_metadata: Metadata for the wrapping provider that can be used to unwrap the wrapped client encryption key. :paramtype key_wrap_metadata: ~azure.mgmt.cosmosdb.models.KeyWrapMetadata """ - super(ClientEncryptionKeyGetPropertiesResource, self).__init__(id=id, encryption_algorithm=encryption_algorithm, wrapped_data_encryption_key=wrapped_data_encryption_key, key_wrap_metadata=key_wrap_metadata, **kwargs) + super().__init__( + id=id, + encryption_algorithm=encryption_algorithm, + wrapped_data_encryption_key=wrapped_data_encryption_key, + key_wrap_metadata=key_wrap_metadata, + **kwargs + ) + self.rid = None + self.ts = None + self.etag = None self.id = id self.encryption_algorithm = encryption_algorithm self.wrapped_data_encryption_key = wrapped_data_encryption_key self.key_wrap_metadata = key_wrap_metadata - self.rid = None - self.ts = None - self.etag = None class ClientEncryptionKeyGetResults(ARMProxyResource): @@ -2137,33 +2164,28 @@ class ClientEncryptionKeyGetResults(ARMProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'resource': {'key': 'properties.resource', 'type': 'ClientEncryptionKeyGetPropertiesResource'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "resource": {"key": "properties.resource", "type": "ClientEncryptionKeyGetPropertiesResource"}, } - def __init__( - self, - *, - resource: Optional["_models.ClientEncryptionKeyGetPropertiesResource"] = None, - **kwargs - ): + def __init__(self, *, resource: Optional["_models.ClientEncryptionKeyGetPropertiesResource"] = None, **kwargs): """ :keyword resource: :paramtype resource: ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetPropertiesResource """ - super(ClientEncryptionKeyGetResults, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource = resource -class ClientEncryptionKeysListResult(msrest.serialization.Model): +class ClientEncryptionKeysListResult(_serialization.Model): """The List operation response, that contains the client encryption keys and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -2173,30 +2195,26 @@ class ClientEncryptionKeysListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ClientEncryptionKeyGetResults]'}, + "value": {"key": "value", "type": "[ClientEncryptionKeyGetResults]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ClientEncryptionKeysListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class ClientEncryptionPolicy(msrest.serialization.Model): +class ClientEncryptionPolicy(_serialization.Model): """Cosmos DB client encryption policy. All required parameters must be populated in order to send to Azure. - :ivar included_paths: Required. Paths of the item that need encryption along with path-specific - settings. + :ivar included_paths: Paths of the item that need encryption along with path-specific settings. + Required. :vartype included_paths: list[~azure.mgmt.cosmosdb.models.ClientEncryptionIncludedPath] :ivar policy_format_version: Version of the client encryption policy definition. Please note, user passed value is ignored. Default policy version is 1. @@ -2204,35 +2222,31 @@ class ClientEncryptionPolicy(msrest.serialization.Model): """ _validation = { - 'included_paths': {'required': True}, + "included_paths": {"required": True}, } _attribute_map = { - 'included_paths': {'key': 'includedPaths', 'type': '[ClientEncryptionIncludedPath]'}, - 'policy_format_version': {'key': 'policyFormatVersion', 'type': 'int'}, + "included_paths": {"key": "includedPaths", "type": "[ClientEncryptionIncludedPath]"}, + "policy_format_version": {"key": "policyFormatVersion", "type": "int"}, } def __init__( - self, - *, - included_paths: List["_models.ClientEncryptionIncludedPath"], - policy_format_version: Optional[int] = 1, - **kwargs + self, *, included_paths: List["_models.ClientEncryptionIncludedPath"], policy_format_version: int = 1, **kwargs ): """ - :keyword included_paths: Required. Paths of the item that need encryption along with - path-specific settings. + :keyword included_paths: Paths of the item that need encryption along with path-specific + settings. Required. :paramtype included_paths: list[~azure.mgmt.cosmosdb.models.ClientEncryptionIncludedPath] :keyword policy_format_version: Version of the client encryption policy definition. Please note, user passed value is ignored. Default policy version is 1. :paramtype policy_format_version: int """ - super(ClientEncryptionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.included_paths = included_paths self.policy_format_version = policy_format_version -class ClusterKey(msrest.serialization.Model): +class ClusterKey(_serialization.Model): """Cosmos DB Cassandra table cluster key. :ivar name: Name of the Cosmos DB Cassandra table cluster key. @@ -2243,17 +2257,11 @@ class ClusterKey(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'order_by': {'key': 'orderBy', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "order_by": {"key": "orderBy", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - order_by: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, order_by: Optional[str] = None, **kwargs): """ :keyword name: Name of the Cosmos DB Cassandra table cluster key. :paramtype name: str @@ -2261,12 +2269,12 @@ def __init__( "Desc". :paramtype order_by: str """ - super(ClusterKey, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.order_by = order_by -class ManagedCassandraARMResourceProperties(msrest.serialization.Model): +class ManagedCassandraARMResourceProperties(_serialization.Model): """The core properties of ARM resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -2279,30 +2287,30 @@ class ManagedCassandraARMResourceProperties(msrest.serialization.Model): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedCassandraManagedServiceIdentity """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedCassandraManagedServiceIdentity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedCassandraManagedServiceIdentity"}, } def __init__( @@ -2316,17 +2324,17 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedCassandraManagedServiceIdentity """ - super(ManagedCassandraARMResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -2348,12 +2356,12 @@ class ClusterResource(ManagedCassandraARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedCassandraManagedServiceIdentity @@ -2362,19 +2370,19 @@ class ClusterResource(ManagedCassandraARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedCassandraManagedServiceIdentity'}, - 'properties': {'key': 'properties', 'type': 'ClusterResourceProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedCassandraManagedServiceIdentity"}, + "properties": {"key": "properties", "type": "ClusterResourceProperties"}, } def __init__( @@ -2389,29 +2397,29 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedCassandraManagedServiceIdentity :keyword properties: Properties of a managed Cassandra cluster. :paramtype properties: ~azure.mgmt.cosmosdb.models.ClusterResourceProperties """ - super(ClusterResource, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.properties = properties -class ClusterResourceProperties(msrest.serialization.Model): +class ClusterResourceProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """Properties of a managed Cassandra cluster. Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The status of the resource at the time the operation was called. - Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :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 @@ -2433,7 +2441,7 @@ class ClusterResourceProperties(msrest.serialization.Model): :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'. 'Ldap' is - in preview. Known values are: "None", "Cassandra", "Ldap". + in preview. Known values are: "None", "Cassandra", and "Ldap". :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 @@ -2475,28 +2483,28 @@ class ClusterResourceProperties(msrest.serialization.Model): """ _validation = { - 'gossip_certificates': {'readonly': True}, - 'seed_nodes': {'readonly': True}, + "gossip_certificates": {"readonly": True}, + "seed_nodes": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'restore_from_backup_id': {'key': 'restoreFromBackupId', 'type': 'str'}, - 'delegated_management_subnet_id': {'key': 'delegatedManagementSubnetId', 'type': 'str'}, - 'cassandra_version': {'key': 'cassandraVersion', 'type': 'str'}, - 'cluster_name_override': {'key': 'clusterNameOverride', 'type': 'str'}, - 'authentication_method': {'key': 'authenticationMethod', 'type': 'str'}, - 'initial_cassandra_admin_password': {'key': 'initialCassandraAdminPassword', 'type': 'str'}, - 'prometheus_endpoint': {'key': 'prometheusEndpoint', 'type': 'SeedNode'}, - 'repair_enabled': {'key': 'repairEnabled', 'type': 'bool'}, - 'client_certificates': {'key': 'clientCertificates', 'type': '[Certificate]'}, - 'external_gossip_certificates': {'key': 'externalGossipCertificates', 'type': '[Certificate]'}, - 'gossip_certificates': {'key': 'gossipCertificates', 'type': '[Certificate]'}, - 'external_seed_nodes': {'key': 'externalSeedNodes', 'type': '[SeedNode]'}, - 'seed_nodes': {'key': 'seedNodes', 'type': '[SeedNode]'}, - 'hours_between_backups': {'key': 'hoursBetweenBackups', 'type': 'int'}, - 'deallocated': {'key': 'deallocated', 'type': 'bool'}, - 'cassandra_audit_logging_enabled': {'key': 'cassandraAuditLoggingEnabled', 'type': 'bool'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "restore_from_backup_id": {"key": "restoreFromBackupId", "type": "str"}, + "delegated_management_subnet_id": {"key": "delegatedManagementSubnetId", "type": "str"}, + "cassandra_version": {"key": "cassandraVersion", "type": "str"}, + "cluster_name_override": {"key": "clusterNameOverride", "type": "str"}, + "authentication_method": {"key": "authenticationMethod", "type": "str"}, + "initial_cassandra_admin_password": {"key": "initialCassandraAdminPassword", "type": "str"}, + "prometheus_endpoint": {"key": "prometheusEndpoint", "type": "SeedNode"}, + "repair_enabled": {"key": "repairEnabled", "type": "bool"}, + "client_certificates": {"key": "clientCertificates", "type": "[Certificate]"}, + "external_gossip_certificates": {"key": "externalGossipCertificates", "type": "[Certificate]"}, + "gossip_certificates": {"key": "gossipCertificates", "type": "[Certificate]"}, + "external_seed_nodes": {"key": "externalSeedNodes", "type": "[SeedNode]"}, + "seed_nodes": {"key": "seedNodes", "type": "[SeedNode]"}, + "hours_between_backups": {"key": "hoursBetweenBackups", "type": "int"}, + "deallocated": {"key": "deallocated", "type": "bool"}, + "cassandra_audit_logging_enabled": {"key": "cassandraAuditLoggingEnabled", "type": "bool"}, } def __init__( @@ -2521,7 +2529,7 @@ def __init__( ): """ :keyword provisioning_state: The status of the resource at the time the operation was called. - Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "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. @@ -2543,7 +2551,7 @@ def __init__( :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'. 'Ldap' is in preview. Known values are: "None", "Cassandra", "Ldap". + 'Cassandra'. 'Ldap' is in preview. Known values are: "None", "Cassandra", and "Ldap". :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 @@ -2576,7 +2584,7 @@ def __init__( :keyword cassandra_audit_logging_enabled: Whether Cassandra audit logging is enabled. :paramtype cassandra_audit_logging_enabled: bool """ - super(ClusterResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = provisioning_state self.restore_from_backup_id = restore_from_backup_id self.delegated_management_subnet_id = delegated_management_subnet_id @@ -2596,7 +2604,7 @@ def __init__( self.cassandra_audit_logging_enabled = cassandra_audit_logging_enabled -class Column(msrest.serialization.Model): +class Column(_serialization.Model): """Cosmos DB Cassandra table column. :ivar name: Name of the Cosmos DB Cassandra table column. @@ -2606,29 +2614,23 @@ class Column(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, 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) + super().__init__(**kwargs) self.name = name self.type = type -class CommandOutput(msrest.serialization.Model): +class CommandOutput(_serialization.Model): """Response of /command api. :ivar command_output: Output of the command. @@ -2636,33 +2638,28 @@ class CommandOutput(msrest.serialization.Model): """ _attribute_map = { - 'command_output': {'key': 'commandOutput', 'type': 'str'}, + "command_output": {"key": "commandOutput", "type": "str"}, } - def __init__( - self, - *, - command_output: Optional[str] = None, - **kwargs - ): + def __init__(self, *, command_output: Optional[str] = None, **kwargs): """ :keyword command_output: Output of the command. :paramtype command_output: str """ - super(CommandOutput, self).__init__(**kwargs) + super().__init__(**kwargs) self.command_output = command_output -class CommandPostBody(msrest.serialization.Model): +class CommandPostBody(_serialization.Model): """Specification of which command to run where. All required parameters must be populated in order to send to Azure. - :ivar command: Required. The command which should be run. + :ivar command: The command which should be run. Required. :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. + :ivar host: IP address of the cassandra host to run the command on. Required. :vartype host: str :ivar cassandra_stop_start: If true, stops cassandra before executing the command and then start it again. @@ -2673,16 +2670,16 @@ class CommandPostBody(msrest.serialization.Model): """ _validation = { - 'command': {'required': True}, - 'host': {'required': True}, + "command": {"required": True}, + "host": {"required": True}, } _attribute_map = { - 'command': {'key': 'command', 'type': 'str'}, - 'arguments': {'key': 'arguments', 'type': '{str}'}, - 'host': {'key': 'host', 'type': 'str'}, - 'cassandra_stop_start': {'key': 'cassandra-stop-start', 'type': 'bool'}, - 'readwrite': {'key': 'readwrite', 'type': 'bool'}, + "command": {"key": "command", "type": "str"}, + "arguments": {"key": "arguments", "type": "{str}"}, + "host": {"key": "host", "type": "str"}, + "cassandra_stop_start": {"key": "cassandra-stop-start", "type": "bool"}, + "readwrite": {"key": "readwrite", "type": "bool"}, } def __init__( @@ -2696,212 +2693,40 @@ def __init__( **kwargs ): """ - :keyword command: Required. The command which should be run. + :keyword command: The command which should be run. Required. :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. + :keyword host: IP address of the cassandra host to run the command on. Required. :paramtype host: str :keyword cassandra_stop_start: If true, stops cassandra before executing the command and then 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 - self.host = host - self.cassandra_stop_start = cassandra_stop_start - self.readwrite = readwrite - - -class Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): - """Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal id of user assigned identity. - :vartype principal_id: str - :ivar client_id: The client id of user assigned identity. - :vartype client_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems(msrest.serialization.Model): - """ComponentsM9L909SchemasCassandraclusterpublicstatusPropertiesDatacentersItemsPropertiesNodesItems. - - :ivar address: The node's IP address. - :vartype address: str - :ivar state: The state of the node in Cassandra ring. Known values are: "Normal", "Leaving", - "Joining", "Moving", "Stopped". - :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. - :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 at which that snapshot of these usage statistics were taken. - :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. - :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 = { - 'address': {'key': 'address', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'load': {'key': 'load', 'type': 'str'}, - 'tokens': {'key': 'tokens', 'type': '[str]'}, - 'size': {'key': 'size', 'type': 'int'}, - 'host_id': {'key': 'hostID', 'type': 'str'}, - 'rack': {'key': 'rack', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'str'}, - 'disk_used_kb': {'key': 'diskUsedKB', 'type': 'long'}, - 'disk_free_kb': {'key': 'diskFreeKB', 'type': 'long'}, - 'memory_used_kb': {'key': 'memoryUsedKB', 'type': 'long'}, - 'memory_buffers_and_cached_kb': {'key': 'memoryBuffersAndCachedKB', 'type': 'long'}, - 'memory_free_kb': {'key': 'memoryFreeKB', 'type': 'long'}, - 'memory_total_kb': {'key': 'memoryTotalKB', 'type': 'long'}, - 'cpu_usage': {'key': 'cpuUsage', 'type': 'float'}, - } - - def __init__( - self, - *, - address: Optional[str] = None, - state: Optional[Union[str, "_models.NodeState"]] = None, - status: Optional[str] = None, - load: Optional[str] = None, - tokens: Optional[List[str]] = None, - size: Optional[int] = None, - host_id: Optional[str] = None, - rack: Optional[str] = None, - timestamp: Optional[str] = None, - disk_used_kb: Optional[int] = None, - disk_free_kb: Optional[int] = None, - memory_used_kb: Optional[int] = None, - memory_buffers_and_cached_kb: Optional[int] = None, - memory_free_kb: Optional[int] = None, - memory_total_kb: Optional[int] = None, - cpu_usage: Optional[float] = None, - **kwargs - ): - """ - :keyword address: The node's IP address. - :paramtype address: str - :keyword state: The state of the node in Cassandra ring. Known values are: "Normal", "Leaving", - "Joining", "Moving", "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 at which that snapshot of these usage statistics were taken. - :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 - self.status = status - self.load = load - self.tokens = tokens - self.size = size - self.host_id = host_id - self.rack = rack - self.timestamp = timestamp - self.disk_used_kb = disk_used_kb - self.disk_free_kb = disk_free_kb - self.memory_used_kb = memory_used_kb - self.memory_buffers_and_cached_kb = memory_buffers_and_cached_kb - self.memory_free_kb = memory_free_kb - self.memory_total_kb = memory_total_kb - self.cpu_usage = cpu_usage + :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().__init__(**kwargs) + self.command = command + self.arguments = arguments + self.host = host + self.cassandra_stop_start = cassandra_stop_start + self.readwrite = readwrite -class CompositePath(msrest.serialization.Model): +class CompositePath(_serialization.Model): """CompositePath. :ivar path: The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*). :vartype path: str - :ivar order: Sort order for composite paths. Known values are: "ascending", "descending". + :ivar order: Sort order for composite paths. Known values are: "ascending" and "descending". :vartype order: str or ~azure.mgmt.cosmosdb.models.CompositePathSortOrder """ _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'order': {'key': 'order', 'type': 'str'}, + "path": {"key": "path", "type": "str"}, + "order": {"key": "order", "type": "str"}, } def __init__( @@ -2915,19 +2740,19 @@ def __init__( :keyword path: The path for which the indexing behavior applies to. Index paths typically start with root and end with wildcard (/path/*). :paramtype path: str - :keyword order: Sort order for composite paths. Known values are: "ascending", "descending". + :keyword order: Sort order for composite paths. Known values are: "ascending" and "descending". :paramtype order: str or ~azure.mgmt.cosmosdb.models.CompositePathSortOrder """ - super(CompositePath, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.order = order -class ConflictResolutionPolicy(msrest.serialization.Model): +class ConflictResolutionPolicy(_serialization.Model): """The conflict resolution policy for the container. - :ivar mode: Indicates the conflict resolution mode. Known values are: "LastWriterWins", - "Custom". Default value: "LastWriterWins". + :ivar mode: Indicates the conflict resolution mode. Known values are: "LastWriterWins" and + "Custom". :vartype mode: str or ~azure.mgmt.cosmosdb.models.ConflictResolutionMode :ivar conflict_resolution_path: The conflict resolution path in the case of LastWriterWins mode. @@ -2938,22 +2763,22 @@ class ConflictResolutionPolicy(msrest.serialization.Model): """ _attribute_map = { - 'mode': {'key': 'mode', 'type': 'str'}, - 'conflict_resolution_path': {'key': 'conflictResolutionPath', 'type': 'str'}, - 'conflict_resolution_procedure': {'key': 'conflictResolutionProcedure', 'type': 'str'}, + "mode": {"key": "mode", "type": "str"}, + "conflict_resolution_path": {"key": "conflictResolutionPath", "type": "str"}, + "conflict_resolution_procedure": {"key": "conflictResolutionProcedure", "type": "str"}, } def __init__( self, *, - mode: Optional[Union[str, "_models.ConflictResolutionMode"]] = "LastWriterWins", + mode: Union[str, "_models.ConflictResolutionMode"] = "LastWriterWins", conflict_resolution_path: Optional[str] = None, conflict_resolution_procedure: Optional[str] = None, **kwargs ): """ - :keyword mode: Indicates the conflict resolution mode. Known values are: "LastWriterWins", - "Custom". Default value: "LastWriterWins". + :keyword mode: Indicates the conflict resolution mode. Known values are: "LastWriterWins" and + "Custom". :paramtype mode: str or ~azure.mgmt.cosmosdb.models.ConflictResolutionMode :keyword conflict_resolution_path: The conflict resolution path in the case of LastWriterWins mode. @@ -2962,18 +2787,18 @@ def __init__( custom mode. :paramtype conflict_resolution_procedure: str """ - super(ConflictResolutionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.mode = mode self.conflict_resolution_path = conflict_resolution_path self.conflict_resolution_procedure = conflict_resolution_procedure -class ConnectionError(msrest.serialization.Model): +class ConnectionError(_serialization.Model): """ConnectionError. :ivar connection_state: The kind of connection error that occurred. Known values are: "Unknown", "OK", "OperatorToDataCenterNetworkError", "DatacenterToDatacenterNetworkError", - "InternalOperatorToDataCenterCertificateError", "InternalError". + "InternalOperatorToDataCenterCertificateError", and "InternalError". :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 @@ -2986,11 +2811,11 @@ class ConnectionError(msrest.serialization.Model): """ _attribute_map = { - 'connection_state': {'key': 'connectionState', 'type': 'str'}, - 'i_p_from': {'key': 'iPFrom', 'type': 'str'}, - 'i_p_to': {'key': 'iPTo', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, - 'exception': {'key': 'exception', 'type': 'str'}, + "connection_state": {"key": "connectionState", "type": "str"}, + "i_p_from": {"key": "iPFrom", "type": "str"}, + "i_p_to": {"key": "iPTo", "type": "str"}, + "port": {"key": "port", "type": "int"}, + "exception": {"key": "exception", "type": "str"}, } def __init__( @@ -3006,7 +2831,7 @@ def __init__( """ :keyword connection_state: The kind of connection error that occurred. Known values are: "Unknown", "OK", "OperatorToDataCenterNetworkError", "DatacenterToDatacenterNetworkError", - "InternalOperatorToDataCenterCertificateError", "InternalError". + "InternalOperatorToDataCenterCertificateError", and "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 @@ -3017,7 +2842,7 @@ def __init__( :keyword exception: Detailed error message about the failed connection. :paramtype exception: str """ - super(ConnectionError, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_state = connection_state self.i_p_from = i_p_from self.i_p_to = i_p_to @@ -3025,19 +2850,19 @@ def __init__( self.exception = exception -class ConsistencyPolicy(msrest.serialization.Model): +class ConsistencyPolicy(_serialization.Model): """The consistency policy for the Cosmos DB database account. All required parameters must be populated in order to send to Azure. - :ivar default_consistency_level: Required. The default consistency level and configuration - settings of the Cosmos DB account. Known values are: "Eventual", "Session", "BoundedStaleness", - "Strong", "ConsistentPrefix". + :ivar default_consistency_level: The default consistency level and configuration settings of + the Cosmos DB account. Required. Known values are: "Eventual", "Session", "BoundedStaleness", + "Strong", and "ConsistentPrefix". :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'. - :vartype max_staleness_prefix: long + :vartype max_staleness_prefix: int :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'. @@ -3045,15 +2870,15 @@ class ConsistencyPolicy(msrest.serialization.Model): """ _validation = { - 'default_consistency_level': {'required': True}, - 'max_staleness_prefix': {'maximum': 2147483647, 'minimum': 1}, - 'max_interval_in_seconds': {'maximum': 86400, 'minimum': 5}, + "default_consistency_level": {"required": True}, + "max_staleness_prefix": {"maximum": 2147483647, "minimum": 1}, + "max_interval_in_seconds": {"maximum": 86400, "minimum": 5}, } _attribute_map = { - 'default_consistency_level': {'key': 'defaultConsistencyLevel', 'type': 'str'}, - 'max_staleness_prefix': {'key': 'maxStalenessPrefix', 'type': 'long'}, - 'max_interval_in_seconds': {'key': 'maxIntervalInSeconds', 'type': 'int'}, + "default_consistency_level": {"key": "defaultConsistencyLevel", "type": "str"}, + "max_staleness_prefix": {"key": "maxStalenessPrefix", "type": "int"}, + "max_interval_in_seconds": {"key": "maxIntervalInSeconds", "type": "int"}, } def __init__( @@ -3065,27 +2890,27 @@ def __init__( **kwargs ): """ - :keyword default_consistency_level: Required. The default consistency level and configuration - settings of the Cosmos DB account. Known values are: "Eventual", "Session", "BoundedStaleness", - "Strong", "ConsistentPrefix". + :keyword default_consistency_level: The default consistency level and configuration settings of + the Cosmos DB account. Required. Known values are: "Eventual", "Session", "BoundedStaleness", + "Strong", and "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 + :paramtype max_staleness_prefix: int :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) + super().__init__(**kwargs) self.default_consistency_level = default_consistency_level self.max_staleness_prefix = max_staleness_prefix self.max_interval_in_seconds = max_interval_in_seconds -class ContainerPartitionKey(msrest.serialization.Model): +class ContainerPartitionKey(_serialization.Model): """The configuration of the partition key to be used for partitioning data into multiple partitions. Variables are only populated by the server, and will be ignored when sending a request. @@ -3094,7 +2919,7 @@ class ContainerPartitionKey(msrest.serialization.Model): :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. Known values are: - "Hash", "Range", "MultiHash". Default value: "Hash". + "Hash", "Range", and "MultiHash". :vartype kind: str or ~azure.mgmt.cosmosdb.models.PartitionKind :ivar version: Indicates the version of the partition key definition. :vartype version: int @@ -3103,22 +2928,22 @@ class ContainerPartitionKey(msrest.serialization.Model): """ _validation = { - 'version': {'maximum': 2, 'minimum': 1}, - 'system_key': {'readonly': True}, + "version": {"maximum": 2, "minimum": 1}, + "system_key": {"readonly": True}, } _attribute_map = { - 'paths': {'key': 'paths', 'type': '[str]'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'int'}, - 'system_key': {'key': 'systemKey', 'type': 'bool'}, + "paths": {"key": "paths", "type": "[str]"}, + "kind": {"key": "kind", "type": "str"}, + "version": {"key": "version", "type": "int"}, + "system_key": {"key": "systemKey", "type": "bool"}, } def __init__( self, *, paths: Optional[List[str]] = None, - kind: Optional[Union[str, "_models.PartitionKind"]] = "Hash", + kind: Union[str, "_models.PartitionKind"] = "Hash", version: Optional[int] = None, **kwargs ): @@ -3127,19 +2952,19 @@ def __init__( :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. Known values are: - "Hash", "Range", "MultiHash". Default value: "Hash". + "Hash", "Range", and "MultiHash". :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) + super().__init__(**kwargs) self.paths = paths self.kind = kind self.version = version self.system_key = None -class ContinuousBackupInformation(msrest.serialization.Model): +class ContinuousBackupInformation(_serialization.Model): """Information about the status of continuous backups. :ivar latest_restorable_timestamp: The latest restorable timestamp for a resource. @@ -3147,24 +2972,19 @@ class ContinuousBackupInformation(msrest.serialization.Model): """ _attribute_map = { - 'latest_restorable_timestamp': {'key': 'latestRestorableTimestamp', 'type': 'str'}, + "latest_restorable_timestamp": {"key": "latestRestorableTimestamp", "type": "str"}, } - def __init__( - self, - *, - latest_restorable_timestamp: Optional[str] = None, - **kwargs - ): + def __init__(self, *, 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) + super().__init__(**kwargs) self.latest_restorable_timestamp = latest_restorable_timestamp -class ContinuousBackupRestoreLocation(msrest.serialization.Model): +class ContinuousBackupRestoreLocation(_serialization.Model): """Properties of the regional restorable account. :ivar location: The name of the continuous backup restore location. @@ -3172,20 +2992,15 @@ class ContinuousBackupRestoreLocation(msrest.serialization.Model): """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, **kwargs): """ :keyword location: The name of the continuous backup restore location. :paramtype location: str """ - super(ContinuousBackupRestoreLocation, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location @@ -3194,8 +3009,8 @@ class ContinuousModeBackupPolicy(BackupPolicy): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Describes the mode of backups.Constant filled by server. Known values - are: "Periodic", "Continuous". + :ivar type: Describes the mode of backups. Required. Known values are: "Periodic" and + "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. @@ -3205,13 +3020,13 @@ class ContinuousModeBackupPolicy(BackupPolicy): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'migration_state': {'key': 'migrationState', 'type': 'BackupPolicyMigrationState'}, - 'continuous_mode_properties': {'key': 'continuousModeProperties', 'type': 'ContinuousModeProperties'}, + "type": {"key": "type", "type": "str"}, + "migration_state": {"key": "migrationState", "type": "BackupPolicyMigrationState"}, + "continuous_mode_properties": {"key": "continuousModeProperties", "type": "ContinuousModeProperties"}, } def __init__( @@ -3228,45 +3043,40 @@ def __init__( :keyword continuous_mode_properties: Configuration values for continuous mode backup. :paramtype continuous_mode_properties: ~azure.mgmt.cosmosdb.models.ContinuousModeProperties """ - super(ContinuousModeBackupPolicy, self).__init__(migration_state=migration_state, **kwargs) - self.type = 'Continuous' # type: str + super().__init__(migration_state=migration_state, **kwargs) + self.type = "Continuous" # type: str self.continuous_mode_properties = continuous_mode_properties -class ContinuousModeProperties(msrest.serialization.Model): +class ContinuousModeProperties(_serialization.Model): """Configuration values for periodic mode backup. - :ivar tier: Enum to indicate type of Continuos backup mode. Known values are: - "Continuous7Days", "Continuous30Days". + :ivar tier: Enum to indicate type of Continuos backup mode. Known values are: "Continuous7Days" + and "Continuous30Days". :vartype tier: str or ~azure.mgmt.cosmosdb.models.ContinuousTier """ _attribute_map = { - 'tier': {'key': 'tier', 'type': 'str'}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - tier: Optional[Union[str, "_models.ContinuousTier"]] = None, - **kwargs - ): + def __init__(self, *, tier: Optional[Union[str, "_models.ContinuousTier"]] = None, **kwargs): """ :keyword tier: Enum to indicate type of Continuos backup mode. Known values are: - "Continuous7Days", "Continuous30Days". + "Continuous7Days" and "Continuous30Days". :paramtype tier: str or ~azure.mgmt.cosmosdb.models.ContinuousTier """ - super(ContinuousModeProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier = tier -class CorsPolicy(msrest.serialization.Model): +class CorsPolicy(_serialization.Model): """The CORS policy for the Cosmos DB database account. All required parameters must be populated in order to send to Azure. - :ivar allowed_origins: Required. The origin domains that are permitted to make a request - against the service via CORS. + :ivar allowed_origins: The origin domains that are permitted to make a request against the + service via CORS. Required. :vartype allowed_origins: str :ivar allowed_methods: The methods (HTTP request verbs) that the origin domain may use for a CORS request. @@ -3279,20 +3089,20 @@ class CorsPolicy(msrest.serialization.Model): :vartype exposed_headers: str :ivar max_age_in_seconds: The maximum amount time that a browser should cache the preflight OPTIONS request. - :vartype max_age_in_seconds: long + :vartype max_age_in_seconds: int """ _validation = { - 'allowed_origins': {'required': True}, - 'max_age_in_seconds': {'maximum': 2147483647, 'minimum': 1}, + "allowed_origins": {"required": True}, + "max_age_in_seconds": {"maximum": 2147483647, "minimum": 1}, } _attribute_map = { - 'allowed_origins': {'key': 'allowedOrigins', 'type': 'str'}, - 'allowed_methods': {'key': 'allowedMethods', 'type': 'str'}, - 'allowed_headers': {'key': 'allowedHeaders', 'type': 'str'}, - 'exposed_headers': {'key': 'exposedHeaders', 'type': 'str'}, - 'max_age_in_seconds': {'key': 'maxAgeInSeconds', 'type': 'long'}, + "allowed_origins": {"key": "allowedOrigins", "type": "str"}, + "allowed_methods": {"key": "allowedMethods", "type": "str"}, + "allowed_headers": {"key": "allowedHeaders", "type": "str"}, + "exposed_headers": {"key": "exposedHeaders", "type": "str"}, + "max_age_in_seconds": {"key": "maxAgeInSeconds", "type": "int"}, } def __init__( @@ -3306,8 +3116,8 @@ def __init__( **kwargs ): """ - :keyword allowed_origins: Required. The origin domains that are permitted to make a request - against the service via CORS. + :keyword allowed_origins: The origin domains that are permitted to make a request against the + service via CORS. Required. :paramtype allowed_origins: str :keyword allowed_methods: The methods (HTTP request verbs) that the origin domain may use for a CORS request. @@ -3320,9 +3130,9 @@ def __init__( :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 + :paramtype max_age_in_seconds: int """ - super(CorsPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.allowed_origins = allowed_origins self.allowed_methods = allowed_methods self.allowed_headers = allowed_headers @@ -3335,8 +3145,7 @@ class CosmosCassandraDataTransferDataSourceSink(DataTransferDataSourceSink): All required parameters must be populated in order to send to Azure. - :ivar component: Required. Constant filled by server. Known values are: "CosmosDBCassandra", - "CosmosDBSql", "AzureBlobStorage". Default value: "CosmosDBCassandra". + :ivar component: Known values are: "CosmosDBCassandra", "CosmosDBSql", and "AzureBlobStorage". :vartype component: str or ~azure.mgmt.cosmosdb.models.DataTransferComponent :ivar keyspace_name: Required. :vartype keyspace_name: str @@ -3345,32 +3154,26 @@ class CosmosCassandraDataTransferDataSourceSink(DataTransferDataSourceSink): """ _validation = { - 'component': {'required': True}, - 'keyspace_name': {'required': True}, - 'table_name': {'required': True}, + "component": {"required": True}, + "keyspace_name": {"required": True}, + "table_name": {"required": True}, } _attribute_map = { - 'component': {'key': 'component', 'type': 'str'}, - 'keyspace_name': {'key': 'keyspaceName', 'type': 'str'}, - 'table_name': {'key': 'tableName', 'type': 'str'}, + "component": {"key": "component", "type": "str"}, + "keyspace_name": {"key": "keyspaceName", "type": "str"}, + "table_name": {"key": "tableName", "type": "str"}, } - def __init__( - self, - *, - keyspace_name: str, - table_name: str, - **kwargs - ): + def __init__(self, *, keyspace_name: str, table_name: str, **kwargs): """ :keyword keyspace_name: Required. :paramtype keyspace_name: str :keyword table_name: Required. :paramtype table_name: str """ - super(CosmosCassandraDataTransferDataSourceSink, self).__init__(**kwargs) - self.component = 'CosmosDBCassandra' # type: str + super().__init__(**kwargs) + self.component = "CosmosDBCassandra" # type: str self.keyspace_name = keyspace_name self.table_name = table_name @@ -3380,8 +3183,7 @@ class CosmosSqlDataTransferDataSourceSink(DataTransferDataSourceSink): All required parameters must be populated in order to send to Azure. - :ivar component: Required. Constant filled by server. Known values are: "CosmosDBCassandra", - "CosmosDBSql", "AzureBlobStorage". Default value: "CosmosDBCassandra". + :ivar component: Known values are: "CosmosDBCassandra", "CosmosDBSql", and "AzureBlobStorage". :vartype component: str or ~azure.mgmt.cosmosdb.models.DataTransferComponent :ivar database_name: Required. :vartype database_name: str @@ -3390,32 +3192,26 @@ class CosmosSqlDataTransferDataSourceSink(DataTransferDataSourceSink): """ _validation = { - 'component': {'required': True}, - 'database_name': {'required': True}, - 'container_name': {'required': True}, + "component": {"required": True}, + "database_name": {"required": True}, + "container_name": {"required": True}, } _attribute_map = { - 'component': {'key': 'component', 'type': 'str'}, - 'database_name': {'key': 'databaseName', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, + "component": {"key": "component", "type": "str"}, + "database_name": {"key": "databaseName", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, } - def __init__( - self, - *, - database_name: str, - container_name: str, - **kwargs - ): + def __init__(self, *, database_name: str, container_name: str, **kwargs): """ :keyword database_name: Required. :paramtype database_name: str :keyword container_name: Required. :paramtype container_name: str """ - super(CosmosSqlDataTransferDataSourceSink, self).__init__(**kwargs) - self.component = 'CosmosDBSql' # type: str + super().__init__(**kwargs) + self.component = "CosmosDBSql" # type: str self.database_name = database_name self.container_name = container_name @@ -3433,39 +3229,34 @@ class CreateJobRequest(ARMProxyResource): :vartype name: str :ivar type: The type of Azure resource. :vartype type: str - :ivar properties: Required. Data Transfer Create Job Properties. + :ivar properties: Data Transfer Create Job Properties. Required. :vartype properties: ~azure.mgmt.cosmosdb.models.DataTransferJobProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'properties': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DataTransferJobProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "DataTransferJobProperties"}, } - def __init__( - self, - *, - properties: "_models.DataTransferJobProperties", - **kwargs - ): + def __init__(self, *, properties: "_models.DataTransferJobProperties", **kwargs): """ - :keyword properties: Required. Data Transfer Create Job Properties. + :keyword properties: Data Transfer Create Job Properties. Required. :paramtype properties: ~azure.mgmt.cosmosdb.models.DataTransferJobProperties """ - super(CreateJobRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class CreateUpdateOptions(msrest.serialization.Model): +class CreateUpdateOptions(_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". :ivar throughput: Request Units per second. For example, "throughput": 10000. @@ -3475,8 +3266,8 @@ class CreateUpdateOptions(msrest.serialization.Model): """ _attribute_map = { - 'throughput': {'key': 'throughput', 'type': 'int'}, - 'autoscale_settings': {'key': 'autoscaleSettings', 'type': 'AutoscaleSettings'}, + "throughput": {"key": "throughput", "type": "int"}, + "autoscale_settings": {"key": "autoscaleSettings", "type": "AutoscaleSettings"}, } def __init__( @@ -3492,12 +3283,12 @@ def __init__( :keyword autoscale_settings: Specifies the Autoscale settings. :paramtype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings """ - super(CreateUpdateOptions, self).__init__(**kwargs) + super().__init__(**kwargs) self.throughput = throughput self.autoscale_settings = autoscale_settings -class DatabaseAccountConnectionString(msrest.serialization.Model): +class DatabaseAccountConnectionString(_serialization.Model): """Connection string for the Cosmos DB account. Variables are only populated by the server, and will be ignored when sending a request. @@ -3509,27 +3300,23 @@ class DatabaseAccountConnectionString(msrest.serialization.Model): """ _validation = { - 'connection_string': {'readonly': True}, - 'description': {'readonly': True}, + "connection_string": {"readonly": True}, + "description": {"readonly": True}, } _attribute_map = { - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "connection_string": {"key": "connectionString", "type": "str"}, + "description": {"key": "description", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DatabaseAccountConnectionString, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.connection_string = None self.description = None -class DatabaseAccountCreateUpdateParameters(ARMResourceProperties): +class DatabaseAccountCreateUpdateParameters(ARMResourceProperties): # pylint: disable=too-many-instance-attributes """Parameters to create and update Cosmos DB database accounts. Variables are only populated by the server, and will be ignored when sending a request. @@ -3544,24 +3331,24 @@ class DatabaseAccountCreateUpdateParameters(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :ivar kind: Indicates the type of database account. This can only be set at database account - creation. Known values are: "GlobalDocumentDB", "MongoDB", "Parse". + creation. Known values are: "GlobalDocumentDB", "MongoDB", and "Parse". :vartype kind: str or ~azure.mgmt.cosmosdb.models.DatabaseAccountKind :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. + :ivar locations: An array that contains the georeplication locations enabled for the Cosmos DB + account. Required. :vartype locations: list[~azure.mgmt.cosmosdb.models.Location] - :ivar database_account_offer_type: The offer type for the database. Has constant value: + :ivar database_account_offer_type: The offer type for the database. Required. Default value is "Standard". :vartype database_account_offer_type: str :ivar ip_rules: List of IpRules. @@ -3584,7 +3371,7 @@ class DatabaseAccountCreateUpdateParameters(ARMResourceProperties): :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. Known values are: "Small". + account. "Small" :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. @@ -3596,7 +3383,7 @@ class DatabaseAccountCreateUpdateParameters(ARMResourceProperties): "FirstPartyIdentity", "SystemAssignedIdentity" and more. :vartype default_identity: str :ivar public_network_access: Whether requests from Public Network are allowed. Known values - are: "Enabled", "Disabled". + are: "Enabled" and "Disabled". :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 @@ -3607,15 +3394,15 @@ class DatabaseAccountCreateUpdateParameters(ARMResourceProperties): :ivar analytical_storage_configuration: Analytical storage specific properties. :vartype analytical_storage_configuration: ~azure.mgmt.cosmosdb.models.AnalyticalStorageConfiguration - :ivar create_mode: Enum to indicate the mode of account creation. Known values are: "Default", - "Restore". Default value: "Default". + :ivar create_mode: Enum to indicate the mode of account creation. Known values are: "Default" + and "Restore". :vartype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode :ivar 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. Known - values are: "None", "AzureServices". + values are: "None" and "AzureServices". :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. @@ -3641,56 +3428,62 @@ class DatabaseAccountCreateUpdateParameters(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'locations': {'required': True}, - 'database_account_offer_type': {'required': True, 'constant': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'consistency_policy': {'key': 'properties.consistencyPolicy', 'type': 'ConsistencyPolicy'}, - 'locations': {'key': 'properties.locations', 'type': '[Location]'}, - 'database_account_offer_type': {'key': 'properties.databaseAccountOfferType', 'type': 'str'}, - 'ip_rules': {'key': 'properties.ipRules', 'type': '[IpAddressOrRange]'}, - 'is_virtual_network_filter_enabled': {'key': 'properties.isVirtualNetworkFilterEnabled', 'type': 'bool'}, - 'enable_automatic_failover': {'key': 'properties.enableAutomaticFailover', 'type': 'bool'}, - 'capabilities': {'key': 'properties.capabilities', 'type': '[Capability]'}, - 'virtual_network_rules': {'key': 'properties.virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'enable_multiple_write_locations': {'key': 'properties.enableMultipleWriteLocations', 'type': 'bool'}, - 'enable_cassandra_connector': {'key': 'properties.enableCassandraConnector', 'type': 'bool'}, - 'connector_offer': {'key': 'properties.connectorOffer', 'type': 'str'}, - 'disable_key_based_metadata_write_access': {'key': 'properties.disableKeyBasedMetadataWriteAccess', 'type': 'bool'}, - 'key_vault_key_uri': {'key': 'properties.keyVaultKeyUri', 'type': 'str'}, - 'default_identity': {'key': 'properties.defaultIdentity', 'type': 'str'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'enable_free_tier': {'key': 'properties.enableFreeTier', 'type': 'bool'}, - 'api_properties': {'key': 'properties.apiProperties', 'type': 'ApiProperties'}, - 'enable_analytical_storage': {'key': 'properties.enableAnalyticalStorage', 'type': 'bool'}, - 'analytical_storage_configuration': {'key': 'properties.analyticalStorageConfiguration', 'type': 'AnalyticalStorageConfiguration'}, - 'create_mode': {'key': 'properties.createMode', 'type': 'str'}, - 'backup_policy': {'key': 'properties.backupPolicy', 'type': 'BackupPolicy'}, - 'cors': {'key': 'properties.cors', 'type': '[CorsPolicy]'}, - 'network_acl_bypass': {'key': 'properties.networkAclBypass', 'type': 'str'}, - 'network_acl_bypass_resource_ids': {'key': 'properties.networkAclBypassResourceIds', 'type': '[str]'}, - 'diagnostic_log_settings': {'key': 'properties.diagnosticLogSettings', 'type': 'DiagnosticLogSettings'}, - 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, - 'restore_parameters': {'key': 'properties.restoreParameters', 'type': 'RestoreParameters'}, - 'capacity': {'key': 'properties.capacity', 'type': 'Capacity'}, - 'enable_materialized_views': {'key': 'properties.enableMaterializedViews', 'type': 'bool'}, - 'keys_metadata': {'key': 'properties.keysMetadata', 'type': 'DatabaseAccountKeysMetadata'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "locations": {"required": True}, + "database_account_offer_type": {"required": True, "constant": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "kind": {"key": "kind", "type": "str"}, + "consistency_policy": {"key": "properties.consistencyPolicy", "type": "ConsistencyPolicy"}, + "locations": {"key": "properties.locations", "type": "[Location]"}, + "database_account_offer_type": {"key": "properties.databaseAccountOfferType", "type": "str"}, + "ip_rules": {"key": "properties.ipRules", "type": "[IpAddressOrRange]"}, + "is_virtual_network_filter_enabled": {"key": "properties.isVirtualNetworkFilterEnabled", "type": "bool"}, + "enable_automatic_failover": {"key": "properties.enableAutomaticFailover", "type": "bool"}, + "capabilities": {"key": "properties.capabilities", "type": "[Capability]"}, + "virtual_network_rules": {"key": "properties.virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "enable_multiple_write_locations": {"key": "properties.enableMultipleWriteLocations", "type": "bool"}, + "enable_cassandra_connector": {"key": "properties.enableCassandraConnector", "type": "bool"}, + "connector_offer": {"key": "properties.connectorOffer", "type": "str"}, + "disable_key_based_metadata_write_access": { + "key": "properties.disableKeyBasedMetadataWriteAccess", + "type": "bool", + }, + "key_vault_key_uri": {"key": "properties.keyVaultKeyUri", "type": "str"}, + "default_identity": {"key": "properties.defaultIdentity", "type": "str"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "enable_free_tier": {"key": "properties.enableFreeTier", "type": "bool"}, + "api_properties": {"key": "properties.apiProperties", "type": "ApiProperties"}, + "enable_analytical_storage": {"key": "properties.enableAnalyticalStorage", "type": "bool"}, + "analytical_storage_configuration": { + "key": "properties.analyticalStorageConfiguration", + "type": "AnalyticalStorageConfiguration", + }, + "create_mode": {"key": "properties.createMode", "type": "str"}, + "backup_policy": {"key": "properties.backupPolicy", "type": "BackupPolicy"}, + "cors": {"key": "properties.cors", "type": "[CorsPolicy]"}, + "network_acl_bypass": {"key": "properties.networkAclBypass", "type": "str"}, + "network_acl_bypass_resource_ids": {"key": "properties.networkAclBypassResourceIds", "type": "[str]"}, + "diagnostic_log_settings": {"key": "properties.diagnosticLogSettings", "type": "DiagnosticLogSettings"}, + "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, + "restore_parameters": {"key": "properties.restoreParameters", "type": "RestoreParameters"}, + "capacity": {"key": "properties.capacity", "type": "Capacity"}, + "enable_materialized_views": {"key": "properties.enableMaterializedViews", "type": "bool"}, + "keys_metadata": {"key": "properties.keysMetadata", "type": "DatabaseAccountKeysMetadata"}, } database_account_offer_type = "Standard" - def __init__( + def __init__( # pylint: disable=too-many-locals self, *, locations: List["_models.Location"], @@ -3715,7 +3508,7 @@ def __init__( api_properties: Optional["_models.ApiProperties"] = None, enable_analytical_storage: Optional[bool] = None, analytical_storage_configuration: Optional["_models.AnalyticalStorageConfiguration"] = None, - create_mode: Optional[Union[str, "_models.CreateMode"]] = "Default", + create_mode: Union[str, "_models.CreateMode"] = "Default", backup_policy: Optional["_models.BackupPolicy"] = None, cors: Optional[List["_models.CorsPolicy"]] = None, network_acl_bypass: Optional[Union[str, "_models.NetworkAclBypass"]] = None, @@ -3731,22 +3524,22 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword kind: Indicates the type of database account. This can only be set at database account - creation. Known values are: "GlobalDocumentDB", "MongoDB", "Parse". + creation. Known values are: "GlobalDocumentDB", "MongoDB", and "Parse". :paramtype kind: str or ~azure.mgmt.cosmosdb.models.DatabaseAccountKind :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. + :keyword locations: An array that contains the georeplication locations enabled for the Cosmos + DB account. Required. :paramtype locations: list[~azure.mgmt.cosmosdb.models.Location] :keyword ip_rules: List of IpRules. :paramtype ip_rules: list[~azure.mgmt.cosmosdb.models.IpAddressOrRange] @@ -3769,7 +3562,7 @@ def __init__( account. :paramtype enable_cassandra_connector: bool :keyword connector_offer: The cassandra connector offer type for the Cosmos DB database C* - account. Known values are: "Small". + account. "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. @@ -3781,7 +3574,7 @@ def __init__( "FirstPartyIdentity", "SystemAssignedIdentity" and more. :paramtype default_identity: str :keyword public_network_access: Whether requests from Public Network are allowed. Known values - are: "Enabled", "Disabled". + are: "Enabled" and "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 @@ -3793,14 +3586,14 @@ def __init__( :paramtype analytical_storage_configuration: ~azure.mgmt.cosmosdb.models.AnalyticalStorageConfiguration :keyword create_mode: Enum to indicate the mode of account creation. Known values are: - "Default", "Restore". Default value: "Default". + "Default" and "Restore". :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. - Known values are: "None", "AzureServices". + Known values are: "None" and "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. @@ -3824,7 +3617,7 @@ def __init__( account. :paramtype keys_metadata: ~azure.mgmt.cosmosdb.models.DatabaseAccountKeysMetadata """ - super(DatabaseAccountCreateUpdateParameters, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.kind = kind self.consistency_policy = consistency_policy self.locations = locations @@ -3857,7 +3650,7 @@ def __init__( self.keys_metadata = keys_metadata -class DatabaseAccountGetResults(ARMResourceProperties): +class DatabaseAccountGetResults(ARMResourceProperties): # pylint: disable=too-many-instance-attributes """An Azure Cosmos DB database account. Variables are only populated by the server, and will be ignored when sending a request. @@ -3870,17 +3663,17 @@ class DatabaseAccountGetResults(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :ivar kind: Indicates the type of database account. This can only be set at database account - creation. Known values are: "GlobalDocumentDB", "MongoDB", "Parse". + creation. Known values are: "GlobalDocumentDB", "MongoDB", and "Parse". :vartype kind: str or ~azure.mgmt.cosmosdb.models.DatabaseAccountKind :ivar system_data: The system meta data relating to this resource. :vartype system_data: ~azure.mgmt.cosmosdb.models.SystemData @@ -3895,8 +3688,7 @@ class DatabaseAccountGetResults(ARMResourceProperties): :ivar document_endpoint: The connection endpoint for the Cosmos DB database account. :vartype document_endpoint: str :ivar database_account_offer_type: The offer type for the Cosmos DB database account. Default - value: Standard. The only acceptable values to pass in are None and "Standard". The default - value is None. + value: Standard. Default value is "Standard". :vartype database_account_offer_type: str :ivar ip_rules: List of IpRules. :vartype ip_rules: list[~azure.mgmt.cosmosdb.models.IpAddressOrRange] @@ -3934,7 +3726,7 @@ class DatabaseAccountGetResults(ARMResourceProperties): :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. Known values are: "Small". + account. "Small" :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. @@ -3946,7 +3738,7 @@ class DatabaseAccountGetResults(ARMResourceProperties): "FirstPartyIdentity", "SystemAssignedIdentity" and more. :vartype default_identity: str :ivar public_network_access: Whether requests from Public Network are allowed. Known values - are: "Enabled", "Disabled". + are: "Enabled" and "Disabled". :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 @@ -3959,8 +3751,8 @@ class DatabaseAccountGetResults(ARMResourceProperties): ~azure.mgmt.cosmosdb.models.AnalyticalStorageConfiguration :ivar instance_id: A unique identifier assigned to the database account. :vartype instance_id: str - :ivar create_mode: Enum to indicate the mode of account creation. Known values are: "Default", - "Restore". Default value: "Default". + :ivar create_mode: Enum to indicate the mode of account creation. Known values are: "Default" + and "Restore". :vartype create_mode: str or ~azure.mgmt.cosmosdb.models.CreateMode :ivar restore_parameters: Parameters to indicate the information about the restore. :vartype restore_parameters: ~azure.mgmt.cosmosdb.models.RestoreParameters @@ -3969,7 +3761,7 @@ class DatabaseAccountGetResults(ARMResourceProperties): :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. Known - values are: "None", "AzureServices". + values are: "None" and "AzureServices". :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. @@ -3992,70 +3784,79 @@ class DatabaseAccountGetResults(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'document_endpoint': {'readonly': True}, - 'database_account_offer_type': {'readonly': True}, - 'write_locations': {'readonly': True}, - 'read_locations': {'readonly': True}, - 'locations': {'readonly': True}, - 'failover_policies': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - 'instance_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'document_endpoint': {'key': 'properties.documentEndpoint', 'type': 'str'}, - 'database_account_offer_type': {'key': 'properties.databaseAccountOfferType', 'type': 'str'}, - 'ip_rules': {'key': 'properties.ipRules', 'type': '[IpAddressOrRange]'}, - 'is_virtual_network_filter_enabled': {'key': 'properties.isVirtualNetworkFilterEnabled', 'type': 'bool'}, - 'enable_automatic_failover': {'key': 'properties.enableAutomaticFailover', 'type': 'bool'}, - 'consistency_policy': {'key': 'properties.consistencyPolicy', 'type': 'ConsistencyPolicy'}, - 'capabilities': {'key': 'properties.capabilities', 'type': '[Capability]'}, - 'write_locations': {'key': 'properties.writeLocations', 'type': '[Location]'}, - 'read_locations': {'key': 'properties.readLocations', 'type': '[Location]'}, - 'locations': {'key': 'properties.locations', 'type': '[Location]'}, - 'failover_policies': {'key': 'properties.failoverPolicies', 'type': '[FailoverPolicy]'}, - 'virtual_network_rules': {'key': 'properties.virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'enable_multiple_write_locations': {'key': 'properties.enableMultipleWriteLocations', 'type': 'bool'}, - 'enable_cassandra_connector': {'key': 'properties.enableCassandraConnector', 'type': 'bool'}, - 'connector_offer': {'key': 'properties.connectorOffer', 'type': 'str'}, - 'disable_key_based_metadata_write_access': {'key': 'properties.disableKeyBasedMetadataWriteAccess', 'type': 'bool'}, - 'key_vault_key_uri': {'key': 'properties.keyVaultKeyUri', 'type': 'str'}, - 'default_identity': {'key': 'properties.defaultIdentity', 'type': 'str'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'enable_free_tier': {'key': 'properties.enableFreeTier', 'type': 'bool'}, - 'api_properties': {'key': 'properties.apiProperties', 'type': 'ApiProperties'}, - 'enable_analytical_storage': {'key': 'properties.enableAnalyticalStorage', 'type': 'bool'}, - 'analytical_storage_configuration': {'key': 'properties.analyticalStorageConfiguration', 'type': 'AnalyticalStorageConfiguration'}, - 'instance_id': {'key': 'properties.instanceId', 'type': 'str'}, - 'create_mode': {'key': 'properties.createMode', 'type': 'str'}, - 'restore_parameters': {'key': 'properties.restoreParameters', 'type': 'RestoreParameters'}, - 'backup_policy': {'key': 'properties.backupPolicy', 'type': 'BackupPolicy'}, - 'cors': {'key': 'properties.cors', 'type': '[CorsPolicy]'}, - 'network_acl_bypass': {'key': 'properties.networkAclBypass', 'type': 'str'}, - 'network_acl_bypass_resource_ids': {'key': 'properties.networkAclBypassResourceIds', 'type': '[str]'}, - 'diagnostic_log_settings': {'key': 'properties.diagnosticLogSettings', 'type': 'DiagnosticLogSettings'}, - 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, - 'capacity': {'key': 'properties.capacity', 'type': 'Capacity'}, - 'enable_materialized_views': {'key': 'properties.enableMaterializedViews', 'type': 'bool'}, - 'keys_metadata': {'key': 'properties.keysMetadata', 'type': 'DatabaseAccountKeysMetadata'}, - } - - def __init__( + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "document_endpoint": {"readonly": True}, + "database_account_offer_type": {"readonly": True}, + "write_locations": {"readonly": True}, + "read_locations": {"readonly": True}, + "locations": {"readonly": True}, + "failover_policies": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + "instance_id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "document_endpoint": {"key": "properties.documentEndpoint", "type": "str"}, + "database_account_offer_type": {"key": "properties.databaseAccountOfferType", "type": "str"}, + "ip_rules": {"key": "properties.ipRules", "type": "[IpAddressOrRange]"}, + "is_virtual_network_filter_enabled": {"key": "properties.isVirtualNetworkFilterEnabled", "type": "bool"}, + "enable_automatic_failover": {"key": "properties.enableAutomaticFailover", "type": "bool"}, + "consistency_policy": {"key": "properties.consistencyPolicy", "type": "ConsistencyPolicy"}, + "capabilities": {"key": "properties.capabilities", "type": "[Capability]"}, + "write_locations": {"key": "properties.writeLocations", "type": "[Location]"}, + "read_locations": {"key": "properties.readLocations", "type": "[Location]"}, + "locations": {"key": "properties.locations", "type": "[Location]"}, + "failover_policies": {"key": "properties.failoverPolicies", "type": "[FailoverPolicy]"}, + "virtual_network_rules": {"key": "properties.virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "enable_multiple_write_locations": {"key": "properties.enableMultipleWriteLocations", "type": "bool"}, + "enable_cassandra_connector": {"key": "properties.enableCassandraConnector", "type": "bool"}, + "connector_offer": {"key": "properties.connectorOffer", "type": "str"}, + "disable_key_based_metadata_write_access": { + "key": "properties.disableKeyBasedMetadataWriteAccess", + "type": "bool", + }, + "key_vault_key_uri": {"key": "properties.keyVaultKeyUri", "type": "str"}, + "default_identity": {"key": "properties.defaultIdentity", "type": "str"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "enable_free_tier": {"key": "properties.enableFreeTier", "type": "bool"}, + "api_properties": {"key": "properties.apiProperties", "type": "ApiProperties"}, + "enable_analytical_storage": {"key": "properties.enableAnalyticalStorage", "type": "bool"}, + "analytical_storage_configuration": { + "key": "properties.analyticalStorageConfiguration", + "type": "AnalyticalStorageConfiguration", + }, + "instance_id": {"key": "properties.instanceId", "type": "str"}, + "create_mode": {"key": "properties.createMode", "type": "str"}, + "restore_parameters": {"key": "properties.restoreParameters", "type": "RestoreParameters"}, + "backup_policy": {"key": "properties.backupPolicy", "type": "BackupPolicy"}, + "cors": {"key": "properties.cors", "type": "[CorsPolicy]"}, + "network_acl_bypass": {"key": "properties.networkAclBypass", "type": "str"}, + "network_acl_bypass_resource_ids": {"key": "properties.networkAclBypassResourceIds", "type": "[str]"}, + "diagnostic_log_settings": {"key": "properties.diagnosticLogSettings", "type": "DiagnosticLogSettings"}, + "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, + "capacity": {"key": "properties.capacity", "type": "Capacity"}, + "enable_materialized_views": {"key": "properties.enableMaterializedViews", "type": "bool"}, + "keys_metadata": {"key": "properties.keysMetadata", "type": "DatabaseAccountKeysMetadata"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: Optional[str] = None, @@ -4079,7 +3880,7 @@ def __init__( api_properties: Optional["_models.ApiProperties"] = None, enable_analytical_storage: Optional[bool] = None, analytical_storage_configuration: Optional["_models.AnalyticalStorageConfiguration"] = None, - create_mode: Optional[Union[str, "_models.CreateMode"]] = "Default", + create_mode: Union[str, "_models.CreateMode"] = "Default", restore_parameters: Optional["_models.RestoreParameters"] = None, backup_policy: Optional["_models.BackupPolicy"] = None, cors: Optional[List["_models.CorsPolicy"]] = None, @@ -4095,17 +3896,17 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword kind: Indicates the type of database account. This can only be set at database account - creation. Known values are: "GlobalDocumentDB", "MongoDB", "Parse". + creation. Known values are: "GlobalDocumentDB", "MongoDB", and "Parse". :paramtype kind: str or ~azure.mgmt.cosmosdb.models.DatabaseAccountKind :keyword ip_rules: List of IpRules. :paramtype ip_rules: list[~azure.mgmt.cosmosdb.models.IpAddressOrRange] @@ -4130,7 +3931,7 @@ def __init__( account. :paramtype enable_cassandra_connector: bool :keyword connector_offer: The cassandra connector offer type for the Cosmos DB database C* - account. Known values are: "Small". + account. "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. @@ -4142,7 +3943,7 @@ def __init__( "FirstPartyIdentity", "SystemAssignedIdentity" and more. :paramtype default_identity: str :keyword public_network_access: Whether requests from Public Network are allowed. Known values - are: "Enabled", "Disabled". + are: "Enabled" and "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 @@ -4154,7 +3955,7 @@ def __init__( :paramtype analytical_storage_configuration: ~azure.mgmt.cosmosdb.models.AnalyticalStorageConfiguration :keyword create_mode: Enum to indicate the mode of account creation. Known values are: - "Default", "Restore". Default value: "Default". + "Default" and "Restore". :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 @@ -4163,7 +3964,7 @@ def __init__( :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. - Known values are: "None", "AzureServices". + Known values are: "None" and "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. @@ -4184,7 +3985,7 @@ def __init__( Cosmos DB account. :paramtype keys_metadata: ~azure.mgmt.cosmosdb.models.DatabaseAccountKeysMetadata """ - super(DatabaseAccountGetResults, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.kind = kind self.system_data = None self.provisioning_state = None @@ -4226,7 +4027,7 @@ def __init__( self.keys_metadata = keys_metadata -class DatabaseAccountKeysMetadata(msrest.serialization.Model): +class DatabaseAccountKeysMetadata(_serialization.Model): """The metadata related to each access key for the given Cosmos DB database account. :ivar primary_master_key: The metadata related to the Primary Read-Write Key for the given @@ -4244,10 +4045,10 @@ class DatabaseAccountKeysMetadata(msrest.serialization.Model): """ _attribute_map = { - 'primary_master_key': {'key': 'primaryMasterKey', 'type': 'AccountKeyMetadata'}, - 'secondary_master_key': {'key': 'secondaryMasterKey', 'type': 'AccountKeyMetadata'}, - 'primary_readonly_master_key': {'key': 'primaryReadonlyMasterKey', 'type': 'AccountKeyMetadata'}, - 'secondary_readonly_master_key': {'key': 'secondaryReadonlyMasterKey', 'type': 'AccountKeyMetadata'}, + "primary_master_key": {"key": "primaryMasterKey", "type": "AccountKeyMetadata"}, + "secondary_master_key": {"key": "secondaryMasterKey", "type": "AccountKeyMetadata"}, + "primary_readonly_master_key": {"key": "primaryReadonlyMasterKey", "type": "AccountKeyMetadata"}, + "secondary_readonly_master_key": {"key": "secondaryReadonlyMasterKey", "type": "AccountKeyMetadata"}, } def __init__( @@ -4273,14 +4074,14 @@ def __init__( the given Cosmos DB database account. :paramtype secondary_readonly_master_key: ~azure.mgmt.cosmosdb.models.AccountKeyMetadata """ - super(DatabaseAccountKeysMetadata, self).__init__(**kwargs) + super().__init__(**kwargs) self.primary_master_key = primary_master_key self.secondary_master_key = secondary_master_key self.primary_readonly_master_key = primary_readonly_master_key self.secondary_readonly_master_key = secondary_readonly_master_key -class DatabaseAccountListConnectionStringsResult(msrest.serialization.Model): +class DatabaseAccountListConnectionStringsResult(_serialization.Model): """The connection strings for the given database account. :ivar connection_strings: An array that contains the connection strings for the Cosmos DB @@ -4289,14 +4090,11 @@ class DatabaseAccountListConnectionStringsResult(msrest.serialization.Model): """ _attribute_map = { - 'connection_strings': {'key': 'connectionStrings', 'type': '[DatabaseAccountConnectionString]'}, + "connection_strings": {"key": "connectionStrings", "type": "[DatabaseAccountConnectionString]"}, } def __init__( - self, - *, - connection_strings: Optional[List["_models.DatabaseAccountConnectionString"]] = None, - **kwargs + self, *, connection_strings: Optional[List["_models.DatabaseAccountConnectionString"]] = None, **kwargs ): """ :keyword connection_strings: An array that contains the connection strings for the Cosmos DB @@ -4304,11 +4102,11 @@ def __init__( :paramtype connection_strings: list[~azure.mgmt.cosmosdb.models.DatabaseAccountConnectionString] """ - super(DatabaseAccountListConnectionStringsResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.connection_strings = connection_strings -class DatabaseAccountListReadOnlyKeysResult(msrest.serialization.Model): +class DatabaseAccountListReadOnlyKeysResult(_serialization.Model): """The read-only access keys for the given database account. Variables are only populated by the server, and will be ignored when sending a request. @@ -4320,22 +4118,18 @@ class DatabaseAccountListReadOnlyKeysResult(msrest.serialization.Model): """ _validation = { - 'primary_readonly_master_key': {'readonly': True}, - 'secondary_readonly_master_key': {'readonly': True}, + "primary_readonly_master_key": {"readonly": True}, + "secondary_readonly_master_key": {"readonly": True}, } _attribute_map = { - 'primary_readonly_master_key': {'key': 'primaryReadonlyMasterKey', 'type': 'str'}, - 'secondary_readonly_master_key': {'key': 'secondaryReadonlyMasterKey', 'type': 'str'}, + "primary_readonly_master_key": {"key": "primaryReadonlyMasterKey", "type": "str"}, + "secondary_readonly_master_key": {"key": "secondaryReadonlyMasterKey", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DatabaseAccountListReadOnlyKeysResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.primary_readonly_master_key = None self.secondary_readonly_master_key = None @@ -4356,64 +4150,55 @@ class DatabaseAccountListKeysResult(DatabaseAccountListReadOnlyKeysResult): """ _validation = { - 'primary_readonly_master_key': {'readonly': True}, - 'secondary_readonly_master_key': {'readonly': True}, - 'primary_master_key': {'readonly': True}, - 'secondary_master_key': {'readonly': True}, + "primary_readonly_master_key": {"readonly": True}, + "secondary_readonly_master_key": {"readonly": True}, + "primary_master_key": {"readonly": True}, + "secondary_master_key": {"readonly": True}, } _attribute_map = { - 'primary_readonly_master_key': {'key': 'primaryReadonlyMasterKey', 'type': 'str'}, - 'secondary_readonly_master_key': {'key': 'secondaryReadonlyMasterKey', 'type': 'str'}, - 'primary_master_key': {'key': 'primaryMasterKey', 'type': 'str'}, - 'secondary_master_key': {'key': 'secondaryMasterKey', 'type': 'str'}, + "primary_readonly_master_key": {"key": "primaryReadonlyMasterKey", "type": "str"}, + "secondary_readonly_master_key": {"key": "secondaryReadonlyMasterKey", "type": "str"}, + "primary_master_key": {"key": "primaryMasterKey", "type": "str"}, + "secondary_master_key": {"key": "secondaryMasterKey", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DatabaseAccountListKeysResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.primary_master_key = None self.secondary_master_key = None -class DatabaseAccountRegenerateKeyParameters(msrest.serialization.Model): +class DatabaseAccountRegenerateKeyParameters(_serialization.Model): """Parameters to regenerate the keys within the database account. All required parameters must be populated in order to send to Azure. - :ivar key_kind: Required. The access key to regenerate. Known values are: "primary", - "secondary", "primaryReadonly", "secondaryReadonly". + :ivar key_kind: The access key to regenerate. Required. Known values are: "primary", + "secondary", "primaryReadonly", and "secondaryReadonly". :vartype key_kind: str or ~azure.mgmt.cosmosdb.models.KeyKind """ _validation = { - 'key_kind': {'required': True}, + "key_kind": {"required": True}, } _attribute_map = { - 'key_kind': {'key': 'keyKind', 'type': 'str'}, + "key_kind": {"key": "keyKind", "type": "str"}, } - def __init__( - self, - *, - key_kind: Union[str, "_models.KeyKind"], - **kwargs - ): + def __init__(self, *, key_kind: Union[str, "_models.KeyKind"], **kwargs): """ - :keyword key_kind: Required. The access key to regenerate. Known values are: "primary", - "secondary", "primaryReadonly", "secondaryReadonly". + :keyword key_kind: The access key to regenerate. Required. Known values are: "primary", + "secondary", "primaryReadonly", and "secondaryReadonly". :paramtype key_kind: str or ~azure.mgmt.cosmosdb.models.KeyKind """ - super(DatabaseAccountRegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_kind = key_kind -class DatabaseAccountsListResult(msrest.serialization.Model): +class DatabaseAccountsListResult(_serialization.Model): """The List operation response, that contains the database accounts and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -4423,32 +4208,28 @@ class DatabaseAccountsListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DatabaseAccountGetResults]'}, + "value": {"key": "value", "type": "[DatabaseAccountGetResults]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DatabaseAccountsListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class DatabaseAccountUpdateParameters(msrest.serialization.Model): +class DatabaseAccountUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """Parameters for patching Azure Cosmos DB database account properties. - :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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar location: The location of the resource group to which the resource belongs. :vartype location: str @@ -4479,7 +4260,7 @@ class DatabaseAccountUpdateParameters(msrest.serialization.Model): :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. Known values are: "Small". + account. "Small" :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. @@ -4491,7 +4272,7 @@ class DatabaseAccountUpdateParameters(msrest.serialization.Model): "FirstPartyIdentity", "SystemAssignedIdentity" and more. :vartype default_identity: str :ivar public_network_access: Whether requests from Public Network are allowed. Known values - are: "Enabled", "Disabled". + are: "Enabled" and "Disabled". :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 @@ -4507,7 +4288,7 @@ class DatabaseAccountUpdateParameters(msrest.serialization.Model): :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. Known - values are: "None", "AzureServices". + values are: "None" and "AzureServices". :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. @@ -4530,39 +4311,45 @@ class DatabaseAccountUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'consistency_policy': {'key': 'properties.consistencyPolicy', 'type': 'ConsistencyPolicy'}, - 'locations': {'key': 'properties.locations', 'type': '[Location]'}, - 'ip_rules': {'key': 'properties.ipRules', 'type': '[IpAddressOrRange]'}, - 'is_virtual_network_filter_enabled': {'key': 'properties.isVirtualNetworkFilterEnabled', 'type': 'bool'}, - 'enable_automatic_failover': {'key': 'properties.enableAutomaticFailover', 'type': 'bool'}, - 'capabilities': {'key': 'properties.capabilities', 'type': '[Capability]'}, - 'virtual_network_rules': {'key': 'properties.virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'enable_multiple_write_locations': {'key': 'properties.enableMultipleWriteLocations', 'type': 'bool'}, - 'enable_cassandra_connector': {'key': 'properties.enableCassandraConnector', 'type': 'bool'}, - 'connector_offer': {'key': 'properties.connectorOffer', 'type': 'str'}, - 'disable_key_based_metadata_write_access': {'key': 'properties.disableKeyBasedMetadataWriteAccess', 'type': 'bool'}, - 'key_vault_key_uri': {'key': 'properties.keyVaultKeyUri', 'type': 'str'}, - 'default_identity': {'key': 'properties.defaultIdentity', 'type': 'str'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'enable_free_tier': {'key': 'properties.enableFreeTier', 'type': 'bool'}, - 'api_properties': {'key': 'properties.apiProperties', 'type': 'ApiProperties'}, - 'enable_analytical_storage': {'key': 'properties.enableAnalyticalStorage', 'type': 'bool'}, - 'analytical_storage_configuration': {'key': 'properties.analyticalStorageConfiguration', 'type': 'AnalyticalStorageConfiguration'}, - 'backup_policy': {'key': 'properties.backupPolicy', 'type': 'BackupPolicy'}, - 'cors': {'key': 'properties.cors', 'type': '[CorsPolicy]'}, - 'network_acl_bypass': {'key': 'properties.networkAclBypass', 'type': 'str'}, - 'network_acl_bypass_resource_ids': {'key': 'properties.networkAclBypassResourceIds', 'type': '[str]'}, - 'diagnostic_log_settings': {'key': 'properties.diagnosticLogSettings', 'type': 'DiagnosticLogSettings'}, - 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, - 'capacity': {'key': 'properties.capacity', 'type': 'Capacity'}, - 'enable_materialized_views': {'key': 'properties.enableMaterializedViews', 'type': 'bool'}, - 'keys_metadata': {'key': 'properties.keysMetadata', 'type': 'DatabaseAccountKeysMetadata'}, - } - - def __init__( + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "consistency_policy": {"key": "properties.consistencyPolicy", "type": "ConsistencyPolicy"}, + "locations": {"key": "properties.locations", "type": "[Location]"}, + "ip_rules": {"key": "properties.ipRules", "type": "[IpAddressOrRange]"}, + "is_virtual_network_filter_enabled": {"key": "properties.isVirtualNetworkFilterEnabled", "type": "bool"}, + "enable_automatic_failover": {"key": "properties.enableAutomaticFailover", "type": "bool"}, + "capabilities": {"key": "properties.capabilities", "type": "[Capability]"}, + "virtual_network_rules": {"key": "properties.virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "enable_multiple_write_locations": {"key": "properties.enableMultipleWriteLocations", "type": "bool"}, + "enable_cassandra_connector": {"key": "properties.enableCassandraConnector", "type": "bool"}, + "connector_offer": {"key": "properties.connectorOffer", "type": "str"}, + "disable_key_based_metadata_write_access": { + "key": "properties.disableKeyBasedMetadataWriteAccess", + "type": "bool", + }, + "key_vault_key_uri": {"key": "properties.keyVaultKeyUri", "type": "str"}, + "default_identity": {"key": "properties.defaultIdentity", "type": "str"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "enable_free_tier": {"key": "properties.enableFreeTier", "type": "bool"}, + "api_properties": {"key": "properties.apiProperties", "type": "ApiProperties"}, + "enable_analytical_storage": {"key": "properties.enableAnalyticalStorage", "type": "bool"}, + "analytical_storage_configuration": { + "key": "properties.analyticalStorageConfiguration", + "type": "AnalyticalStorageConfiguration", + }, + "backup_policy": {"key": "properties.backupPolicy", "type": "BackupPolicy"}, + "cors": {"key": "properties.cors", "type": "[CorsPolicy]"}, + "network_acl_bypass": {"key": "properties.networkAclBypass", "type": "str"}, + "network_acl_bypass_resource_ids": {"key": "properties.networkAclBypassResourceIds", "type": "[str]"}, + "diagnostic_log_settings": {"key": "properties.diagnosticLogSettings", "type": "DiagnosticLogSettings"}, + "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, + "capacity": {"key": "properties.capacity", "type": "Capacity"}, + "enable_materialized_views": {"key": "properties.enableMaterializedViews", "type": "bool"}, + "keys_metadata": {"key": "properties.keysMetadata", "type": "DatabaseAccountKeysMetadata"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, tags: Optional[Dict[str, str]] = None, @@ -4598,12 +4385,12 @@ def __init__( **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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword location: The location of the resource group to which the resource belongs. :paramtype location: str @@ -4635,7 +4422,7 @@ def __init__( account. :paramtype enable_cassandra_connector: bool :keyword connector_offer: The cassandra connector offer type for the Cosmos DB database C* - account. Known values are: "Small". + account. "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. @@ -4647,7 +4434,7 @@ def __init__( "FirstPartyIdentity", "SystemAssignedIdentity" and more. :paramtype default_identity: str :keyword public_network_access: Whether requests from Public Network are allowed. Known values - are: "Enabled", "Disabled". + are: "Enabled" and "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 @@ -4663,7 +4450,7 @@ def __init__( :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. - Known values are: "None", "AzureServices". + Known values are: "None" and "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. @@ -4684,7 +4471,7 @@ def __init__( is read-only. The object represents the metadata for the Account Keys of the Cosmos DB account. :paramtype keys_metadata: ~azure.mgmt.cosmosdb.models.DatabaseAccountKeysMetadata """ - super(DatabaseAccountUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location self.identity = identity @@ -4717,7 +4504,7 @@ def __init__( self.keys_metadata = keys_metadata -class DatabaseRestoreResource(msrest.serialization.Model): +class DatabaseRestoreResource(_serialization.Model): """Specific Databases to restore. :ivar database_name: The name of the database available for restore. @@ -4727,24 +4514,18 @@ class DatabaseRestoreResource(msrest.serialization.Model): """ _attribute_map = { - 'database_name': {'key': 'databaseName', 'type': 'str'}, - 'collection_names': {'key': 'collectionNames', 'type': '[str]'}, + "database_name": {"key": "databaseName", "type": "str"}, + "collection_names": {"key": "collectionNames", "type": "[str]"}, } - def __init__( - self, - *, - database_name: Optional[str] = None, - collection_names: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, database_name: Optional[str] = None, 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) + super().__init__(**kwargs) self.database_name = database_name self.collection_names = collection_names @@ -4765,39 +4546,34 @@ class DataCenterResource(ARMProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DataCenterResourceProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "DataCenterResourceProperties"}, } - def __init__( - self, - *, - properties: Optional["_models.DataCenterResourceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DataCenterResourceProperties"] = None, **kwargs): """ :keyword properties: Properties of a managed Cassandra data center. :paramtype properties: ~azure.mgmt.cosmosdb.models.DataCenterResourceProperties """ - super(DataCenterResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class DataCenterResourceProperties(msrest.serialization.Model): +class DataCenterResourceProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """Properties of a managed Cassandra data center. Variables are only populated by the server, and will be ignored when sending a request. :ivar provisioning_state: The status of the resource at the time the operation was called. - Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.cosmosdb.models.ManagedCassandraProvisioningState :ivar data_center_location: The region this data center should be created in. @@ -4845,23 +4621,26 @@ class DataCenterResourceProperties(msrest.serialization.Model): """ _validation = { - 'seed_nodes': {'readonly': True}, + "seed_nodes": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'data_center_location': {'key': 'dataCenterLocation', 'type': 'str'}, - 'delegated_subnet_id': {'key': 'delegatedSubnetId', 'type': 'str'}, - 'node_count': {'key': 'nodeCount', 'type': 'int'}, - 'seed_nodes': {'key': 'seedNodes', 'type': '[SeedNode]'}, - 'base64_encoded_cassandra_yaml_fragment': {'key': 'base64EncodedCassandraYamlFragment', 'type': 'str'}, - 'managed_disk_customer_key_uri': {'key': 'managedDiskCustomerKeyUri', 'type': 'str'}, - 'backup_storage_customer_key_uri': {'key': 'backupStorageCustomerKeyUri', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'str'}, - 'disk_sku': {'key': 'diskSku', 'type': 'str'}, - 'disk_capacity': {'key': 'diskCapacity', 'type': 'int'}, - 'availability_zone': {'key': 'availabilityZone', 'type': 'bool'}, - 'authentication_method_ldap_properties': {'key': 'authenticationMethodLdapProperties', 'type': 'AuthenticationMethodLdapProperties'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "data_center_location": {"key": "dataCenterLocation", "type": "str"}, + "delegated_subnet_id": {"key": "delegatedSubnetId", "type": "str"}, + "node_count": {"key": "nodeCount", "type": "int"}, + "seed_nodes": {"key": "seedNodes", "type": "[SeedNode]"}, + "base64_encoded_cassandra_yaml_fragment": {"key": "base64EncodedCassandraYamlFragment", "type": "str"}, + "managed_disk_customer_key_uri": {"key": "managedDiskCustomerKeyUri", "type": "str"}, + "backup_storage_customer_key_uri": {"key": "backupStorageCustomerKeyUri", "type": "str"}, + "sku": {"key": "sku", "type": "str"}, + "disk_sku": {"key": "diskSku", "type": "str"}, + "disk_capacity": {"key": "diskCapacity", "type": "int"}, + "availability_zone": {"key": "availabilityZone", "type": "bool"}, + "authentication_method_ldap_properties": { + "key": "authenticationMethodLdapProperties", + "type": "AuthenticationMethodLdapProperties", + }, } def __init__( @@ -4883,7 +4662,7 @@ def __init__( ): """ :keyword provisioning_state: The status of the resource at the time the operation was called. - Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled". + Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". :paramtype provisioning_state: str or ~azure.mgmt.cosmosdb.models.ManagedCassandraProvisioningState :keyword data_center_location: The region this data center should be created in. @@ -4925,7 +4704,7 @@ def __init__( :paramtype authentication_method_ldap_properties: ~azure.mgmt.cosmosdb.models.AuthenticationMethodLdapProperties """ - super(DataCenterResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = provisioning_state self.data_center_location = data_center_location self.delegated_subnet_id = delegated_subnet_id @@ -4941,7 +4720,7 @@ def __init__( self.authentication_method_ldap_properties = authentication_method_ldap_properties -class DataTransferJobFeedResults(msrest.serialization.Model): +class DataTransferJobFeedResults(_serialization.Model): """The List operation response, that contains the Data Transfer jobs and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -4953,27 +4732,23 @@ class DataTransferJobFeedResults(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataTransferJobGetResults]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DataTransferJobGetResults]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DataTransferJobFeedResults, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DataTransferJobGetResults(ARMProxyResource): +class DataTransferJobGetResults(ARMProxyResource): # pylint: disable=too-many-instance-attributes """A Cosmos DB Data Transfer Job. Variables are only populated by the server, and will be ignored when sending a request. @@ -4993,9 +4768,9 @@ class DataTransferJobGetResults(ARMProxyResource): :ivar status: Job Status. :vartype status: str :ivar processed_count: Processed Count. - :vartype processed_count: long + :vartype processed_count: int :ivar total_count: Total Count. - :vartype total_count: long + :vartype total_count: int :ivar last_updated_utc_time: Last Updated Time (ISO-8601 format). :vartype last_updated_utc_time: ~datetime.datetime :ivar worker_count: Worker count. @@ -5005,31 +4780,31 @@ class DataTransferJobGetResults(ARMProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'job_name': {'readonly': True}, - 'status': {'readonly': True}, - 'processed_count': {'readonly': True}, - 'total_count': {'readonly': True}, - 'last_updated_utc_time': {'readonly': True}, - 'worker_count': {'minimum': 0}, - 'error': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "job_name": {"readonly": True}, + "status": {"readonly": True}, + "processed_count": {"readonly": True}, + "total_count": {"readonly": True}, + "last_updated_utc_time": {"readonly": True}, + "worker_count": {"minimum": 0}, + "error": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'job_name': {'key': 'properties.jobName', 'type': 'str'}, - 'source': {'key': 'properties.source', 'type': 'DataTransferDataSourceSink'}, - 'destination': {'key': 'properties.destination', 'type': 'DataTransferDataSourceSink'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'processed_count': {'key': 'properties.processedCount', 'type': 'long'}, - 'total_count': {'key': 'properties.totalCount', 'type': 'long'}, - 'last_updated_utc_time': {'key': 'properties.lastUpdatedUtcTime', 'type': 'iso-8601'}, - 'worker_count': {'key': 'properties.workerCount', 'type': 'int'}, - 'error': {'key': 'properties.error', 'type': 'ErrorResponse'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "job_name": {"key": "properties.jobName", "type": "str"}, + "source": {"key": "properties.source", "type": "DataTransferDataSourceSink"}, + "destination": {"key": "properties.destination", "type": "DataTransferDataSourceSink"}, + "status": {"key": "properties.status", "type": "str"}, + "processed_count": {"key": "properties.processedCount", "type": "int"}, + "total_count": {"key": "properties.totalCount", "type": "int"}, + "last_updated_utc_time": {"key": "properties.lastUpdatedUtcTime", "type": "iso-8601"}, + "worker_count": {"key": "properties.workerCount", "type": "int"}, + "error": {"key": "properties.error", "type": "ErrorResponse"}, } def __init__( @@ -5048,7 +4823,7 @@ def __init__( :keyword worker_count: Worker count. :paramtype worker_count: int """ - super(DataTransferJobGetResults, self).__init__(**kwargs) + super().__init__(**kwargs) self.job_name = None self.source = source self.destination = destination @@ -5060,7 +4835,7 @@ def __init__( self.error = None -class DataTransferJobProperties(msrest.serialization.Model): +class DataTransferJobProperties(_serialization.Model): """The properties of a DataTransfer Job. Variables are only populated by the server, and will be ignored when sending a request. @@ -5069,16 +4844,16 @@ class DataTransferJobProperties(msrest.serialization.Model): :ivar job_name: Job Name. :vartype job_name: str - :ivar source: Required. Source DataStore details. + :ivar source: Source DataStore details. Required. :vartype source: ~azure.mgmt.cosmosdb.models.DataTransferDataSourceSink - :ivar destination: Required. Destination DataStore details. + :ivar destination: Destination DataStore details. Required. :vartype destination: ~azure.mgmt.cosmosdb.models.DataTransferDataSourceSink :ivar status: Job Status. :vartype status: str :ivar processed_count: Processed Count. - :vartype processed_count: long + :vartype processed_count: int :ivar total_count: Total Count. - :vartype total_count: long + :vartype total_count: int :ivar last_updated_utc_time: Last Updated Time (ISO-8601 format). :vartype last_updated_utc_time: ~datetime.datetime :ivar worker_count: Worker count. @@ -5088,27 +4863,27 @@ class DataTransferJobProperties(msrest.serialization.Model): """ _validation = { - 'job_name': {'readonly': True}, - 'source': {'required': True}, - 'destination': {'required': True}, - 'status': {'readonly': True}, - 'processed_count': {'readonly': True}, - 'total_count': {'readonly': True}, - 'last_updated_utc_time': {'readonly': True}, - 'worker_count': {'minimum': 0}, - 'error': {'readonly': True}, + "job_name": {"readonly": True}, + "source": {"required": True}, + "destination": {"required": True}, + "status": {"readonly": True}, + "processed_count": {"readonly": True}, + "total_count": {"readonly": True}, + "last_updated_utc_time": {"readonly": True}, + "worker_count": {"minimum": 0}, + "error": {"readonly": True}, } _attribute_map = { - 'job_name': {'key': 'jobName', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'DataTransferDataSourceSink'}, - 'destination': {'key': 'destination', 'type': 'DataTransferDataSourceSink'}, - 'status': {'key': 'status', 'type': 'str'}, - 'processed_count': {'key': 'processedCount', 'type': 'long'}, - 'total_count': {'key': 'totalCount', 'type': 'long'}, - 'last_updated_utc_time': {'key': 'lastUpdatedUtcTime', 'type': 'iso-8601'}, - 'worker_count': {'key': 'workerCount', 'type': 'int'}, - 'error': {'key': 'error', 'type': 'ErrorResponse'}, + "job_name": {"key": "jobName", "type": "str"}, + "source": {"key": "source", "type": "DataTransferDataSourceSink"}, + "destination": {"key": "destination", "type": "DataTransferDataSourceSink"}, + "status": {"key": "status", "type": "str"}, + "processed_count": {"key": "processedCount", "type": "int"}, + "total_count": {"key": "totalCount", "type": "int"}, + "last_updated_utc_time": {"key": "lastUpdatedUtcTime", "type": "iso-8601"}, + "worker_count": {"key": "workerCount", "type": "int"}, + "error": {"key": "error", "type": "ErrorResponse"}, } def __init__( @@ -5120,14 +4895,14 @@ def __init__( **kwargs ): """ - :keyword source: Required. Source DataStore details. + :keyword source: Source DataStore details. Required. :paramtype source: ~azure.mgmt.cosmosdb.models.DataTransferDataSourceSink - :keyword destination: Required. Destination DataStore details. + :keyword destination: Destination DataStore details. Required. :paramtype destination: ~azure.mgmt.cosmosdb.models.DataTransferDataSourceSink :keyword worker_count: Worker count. :paramtype worker_count: int """ - super(DataTransferJobProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.job_name = None self.source = source self.destination = destination @@ -5139,7 +4914,7 @@ def __init__( self.error = None -class RegionalServiceResource(msrest.serialization.Model): +class RegionalServiceResource(_serialization.Model): """Resource for a regional service location. Variables are only populated by the server, and will be ignored when sending a request. @@ -5149,29 +4924,25 @@ class RegionalServiceResource(msrest.serialization.Model): :ivar location: The location name. :vartype location: str :ivar status: Describes the status of a service. Known values are: "Creating", "Running", - "Updating", "Deleting", "Error", "Stopped". + "Updating", "Deleting", "Error", and "Stopped". :vartype status: str or ~azure.mgmt.cosmosdb.models.ServiceStatus """ _validation = { - 'name': {'readonly': True}, - 'location': {'readonly': True}, - 'status': {'readonly': True}, + "name": {"readonly": True}, + "location": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RegionalServiceResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.location = None self.status = None @@ -5187,32 +4958,28 @@ class DataTransferRegionalServiceResource(RegionalServiceResource): :ivar location: The location name. :vartype location: str :ivar status: Describes the status of a service. Known values are: "Creating", "Running", - "Updating", "Deleting", "Error", "Stopped". + "Updating", "Deleting", "Error", and "Stopped". :vartype status: str or ~azure.mgmt.cosmosdb.models.ServiceStatus """ _validation = { - 'name': {'readonly': True}, - 'location': {'readonly': True}, - 'status': {'readonly': True}, + "name": {"readonly": True}, + "location": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DataTransferRegionalServiceResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) -class DataTransferServiceResource(msrest.serialization.Model): +class DataTransferServiceResource(_serialization.Model): """Describes the service response property. :ivar properties: Properties for DataTransferServiceResource. @@ -5220,28 +4987,24 @@ class DataTransferServiceResource(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': 'DataTransferServiceResourceProperties'}, + "properties": {"key": "properties", "type": "DataTransferServiceResourceProperties"}, } - def __init__( - self, - *, - properties: Optional["_models.DataTransferServiceResourceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.DataTransferServiceResourceProperties"] = None, **kwargs): """ :keyword properties: Properties for DataTransferServiceResource. :paramtype properties: ~azure.mgmt.cosmosdb.models.DataTransferServiceResourceProperties """ - super(DataTransferServiceResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ServiceResourceProperties(msrest.serialization.Model): +class ServiceResourceProperties(_serialization.Model): """Services response resource. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: DataTransferServiceResourceProperties, GraphAPIComputeServiceResourceProperties, MaterializedViewsBuilderServiceResourceProperties, SqlDedicatedGatewayServiceResourceProperties. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + DataTransferServiceResourceProperties, GraphAPIComputeServiceResourceProperties, + MaterializedViewsBuilderServiceResourceProperties, SqlDedicatedGatewayServiceResourceProperties Variables are only populated by the server, and will be ignored when sending a request. @@ -5249,47 +5012,51 @@ class ServiceResourceProperties(msrest.serialization.Model): :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] + :vartype additional_properties: dict[str, JSON] :ivar creation_time: Time of the last state change (ISO-8601 format). :vartype creation_time: ~datetime.datetime :ivar instance_size: Instance type for the service. Known values are: "Cosmos.D4s", - "Cosmos.D8s", "Cosmos.D16s". + "Cosmos.D8s", and "Cosmos.D16s". :vartype instance_size: str or ~azure.mgmt.cosmosdb.models.ServiceSize :ivar instance_count: Instance count for the service. :vartype instance_count: int - :ivar service_type: Required. ServiceType for the service.Constant filled by server. Known - values are: "SqlDedicatedGateway", "DataTransfer", "GraphAPICompute", - "MaterializedViewsBuilder". + :ivar service_type: ServiceType for the service. Required. Known values are: + "SqlDedicatedGateway", "DataTransfer", "GraphAPICompute", and "MaterializedViewsBuilder". :vartype service_type: str or ~azure.mgmt.cosmosdb.models.ServiceType :ivar status: Describes the status of a service. Known values are: "Creating", "Running", - "Updating", "Deleting", "Error", "Stopped". + "Updating", "Deleting", "Error", and "Stopped". :vartype status: str or ~azure.mgmt.cosmosdb.models.ServiceStatus """ _validation = { - 'creation_time': {'readonly': True}, - 'instance_count': {'minimum': 0}, - 'service_type': {'required': True}, - 'status': {'readonly': True}, + "creation_time": {"readonly": True}, + "instance_count": {"minimum": 0}, + "service_type": {"required": True}, + "status": {"readonly": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, - 'instance_size': {'key': 'instanceSize', 'type': 'str'}, - 'instance_count': {'key': 'instanceCount', 'type': 'int'}, - 'service_type': {'key': 'serviceType', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "additional_properties": {"key": "", "type": "{object}"}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + "instance_size": {"key": "instanceSize", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, + "service_type": {"key": "serviceType", "type": "str"}, + "status": {"key": "status", "type": "str"}, } _subtype_map = { - 'service_type': {'DataTransfer': 'DataTransferServiceResourceProperties', 'GraphAPICompute': 'GraphAPIComputeServiceResourceProperties', 'MaterializedViewsBuilder': 'MaterializedViewsBuilderServiceResourceProperties', 'SqlDedicatedGateway': 'SqlDedicatedGatewayServiceResourceProperties'} + "service_type": { + "DataTransfer": "DataTransferServiceResourceProperties", + "GraphAPICompute": "GraphAPIComputeServiceResourceProperties", + "MaterializedViewsBuilder": "MaterializedViewsBuilderServiceResourceProperties", + "SqlDedicatedGateway": "SqlDedicatedGatewayServiceResourceProperties", + } } def __init__( self, *, - additional_properties: Optional[Dict[str, Any]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, instance_size: Optional[Union[str, "_models.ServiceSize"]] = None, instance_count: Optional[int] = None, **kwargs @@ -5297,19 +5064,19 @@ def __init__( """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] :keyword instance_size: Instance type for the service. Known values are: "Cosmos.D4s", - "Cosmos.D8s", "Cosmos.D16s". + "Cosmos.D8s", and "Cosmos.D16s". :paramtype instance_size: str or ~azure.mgmt.cosmosdb.models.ServiceSize :keyword instance_count: Instance count for the service. :paramtype instance_count: int """ - super(ServiceResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.additional_properties = additional_properties self.creation_time = None self.instance_size = instance_size self.instance_count = instance_count - self.service_type = 'ServiceResourceProperties' # type: str + self.service_type = None # type: Optional[str] self.status = None @@ -5322,47 +5089,46 @@ class DataTransferServiceResourceProperties(ServiceResourceProperties): :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] + :vartype additional_properties: dict[str, JSON] :ivar creation_time: Time of the last state change (ISO-8601 format). :vartype creation_time: ~datetime.datetime :ivar instance_size: Instance type for the service. Known values are: "Cosmos.D4s", - "Cosmos.D8s", "Cosmos.D16s". + "Cosmos.D8s", and "Cosmos.D16s". :vartype instance_size: str or ~azure.mgmt.cosmosdb.models.ServiceSize :ivar instance_count: Instance count for the service. :vartype instance_count: int - :ivar service_type: Required. ServiceType for the service.Constant filled by server. Known - values are: "SqlDedicatedGateway", "DataTransfer", "GraphAPICompute", - "MaterializedViewsBuilder". + :ivar service_type: ServiceType for the service. Required. Known values are: + "SqlDedicatedGateway", "DataTransfer", "GraphAPICompute", and "MaterializedViewsBuilder". :vartype service_type: str or ~azure.mgmt.cosmosdb.models.ServiceType :ivar status: Describes the status of a service. Known values are: "Creating", "Running", - "Updating", "Deleting", "Error", "Stopped". + "Updating", "Deleting", "Error", and "Stopped". :vartype status: str or ~azure.mgmt.cosmosdb.models.ServiceStatus :ivar locations: An array that contains all of the locations for the service. :vartype locations: list[~azure.mgmt.cosmosdb.models.DataTransferRegionalServiceResource] """ _validation = { - 'creation_time': {'readonly': True}, - 'instance_count': {'minimum': 0}, - 'service_type': {'required': True}, - 'status': {'readonly': True}, - 'locations': {'readonly': True}, + "creation_time": {"readonly": True}, + "instance_count": {"minimum": 0}, + "service_type": {"required": True}, + "status": {"readonly": True}, + "locations": {"readonly": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, - 'instance_size': {'key': 'instanceSize', 'type': 'str'}, - 'instance_count': {'key': 'instanceCount', 'type': 'int'}, - 'service_type': {'key': 'serviceType', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[DataTransferRegionalServiceResource]'}, + "additional_properties": {"key": "", "type": "{object}"}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + "instance_size": {"key": "instanceSize", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, + "service_type": {"key": "serviceType", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "locations": {"key": "locations", "type": "[DataTransferRegionalServiceResource]"}, } def __init__( self, *, - additional_properties: Optional[Dict[str, Any]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, instance_size: Optional[Union[str, "_models.ServiceSize"]] = None, instance_count: Optional[int] = None, **kwargs @@ -5370,46 +5136,46 @@ def __init__( """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] :keyword instance_size: Instance type for the service. Known values are: "Cosmos.D4s", - "Cosmos.D8s", "Cosmos.D16s". + "Cosmos.D8s", and "Cosmos.D16s". :paramtype instance_size: str or ~azure.mgmt.cosmosdb.models.ServiceSize :keyword instance_count: Instance count for the service. :paramtype instance_count: int """ - super(DataTransferServiceResourceProperties, self).__init__(additional_properties=additional_properties, instance_size=instance_size, instance_count=instance_count, **kwargs) - self.service_type = 'DataTransfer' # type: str + super().__init__( + additional_properties=additional_properties, + instance_size=instance_size, + instance_count=instance_count, + **kwargs + ) + self.service_type = "DataTransfer" # type: str self.locations = None -class DiagnosticLogSettings(msrest.serialization.Model): +class DiagnosticLogSettings(_serialization.Model): """Indicates what diagnostic log settings are to be enabled. :ivar enable_full_text_query: Describe the level of detail with which queries are to be logged. - Known values are: "None", "True", "False". + Known values are: "None", "True", and "False". :vartype enable_full_text_query: str or ~azure.mgmt.cosmosdb.models.EnableFullTextQuery """ _attribute_map = { - 'enable_full_text_query': {'key': 'enableFullTextQuery', 'type': 'str'}, + "enable_full_text_query": {"key": "enableFullTextQuery", "type": "str"}, } - def __init__( - self, - *, - enable_full_text_query: Optional[Union[str, "_models.EnableFullTextQuery"]] = None, - **kwargs - ): + def __init__(self, *, enable_full_text_query: Optional[Union[str, "_models.EnableFullTextQuery"]] = None, **kwargs): """ :keyword enable_full_text_query: Describe the level of detail with which queries are to be - logged. Known values are: "None", "True", "False". + logged. Known values are: "None", "True", and "False". :paramtype enable_full_text_query: str or ~azure.mgmt.cosmosdb.models.EnableFullTextQuery """ - super(DiagnosticLogSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.enable_full_text_query = enable_full_text_query -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Error Response. :ivar code: Error code. @@ -5419,29 +5185,23 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, 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) + super().__init__(**kwargs) self.code = code self.message = message -class ExcludedPath(msrest.serialization.Model): +class ExcludedPath(_serialization.Model): """ExcludedPath. :ivar path: The path for which the indexing behavior applies to. Index paths typically start @@ -5450,56 +5210,46 @@ class ExcludedPath(msrest.serialization.Model): """ _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, + "path": {"key": "path", "type": "str"}, } - def __init__( - self, - *, - path: Optional[str] = None, - **kwargs - ): + def __init__(self, *, 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) + super().__init__(**kwargs) self.path = path -class FailoverPolicies(msrest.serialization.Model): +class FailoverPolicies(_serialization.Model): """The list of new failover policies for the failover priority change. All required parameters must be populated in order to send to Azure. - :ivar failover_policies: Required. List of failover policies. + :ivar failover_policies: List of failover policies. Required. :vartype failover_policies: list[~azure.mgmt.cosmosdb.models.FailoverPolicy] """ _validation = { - 'failover_policies': {'required': True}, + "failover_policies": {"required": True}, } _attribute_map = { - 'failover_policies': {'key': 'failoverPolicies', 'type': '[FailoverPolicy]'}, + "failover_policies": {"key": "failoverPolicies", "type": "[FailoverPolicy]"}, } - def __init__( - self, - *, - failover_policies: List["_models.FailoverPolicy"], - **kwargs - ): + def __init__(self, *, failover_policies: List["_models.FailoverPolicy"], **kwargs): """ - :keyword failover_policies: Required. List of failover policies. + :keyword failover_policies: List of failover policies. Required. :paramtype failover_policies: list[~azure.mgmt.cosmosdb.models.FailoverPolicy] """ - super(FailoverPolicies, self).__init__(**kwargs) + super().__init__(**kwargs) self.failover_policies = failover_policies -class FailoverPolicy(msrest.serialization.Model): +class FailoverPolicy(_serialization.Model): """The failover policy for a given region of a database account. Variables are only populated by the server, and will be ignored when sending a request. @@ -5517,23 +5267,17 @@ class FailoverPolicy(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'failover_priority': {'minimum': 0}, + "id": {"readonly": True}, + "failover_priority": {"minimum": 0}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'location_name': {'key': 'locationName', 'type': 'str'}, - 'failover_priority': {'key': 'failoverPriority', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "location_name": {"key": "locationName", "type": "str"}, + "failover_priority": {"key": "failoverPriority", "type": "int"}, } - def __init__( - self, - *, - location_name: Optional[str] = None, - failover_priority: Optional[int] = None, - **kwargs - ): + def __init__(self, *, location_name: Optional[str] = None, failover_priority: Optional[int] = None, **kwargs): """ :keyword location_name: The name of the region in which the database account exists. :paramtype location_name: str @@ -5543,7 +5287,7 @@ def __init__( account exists. :paramtype failover_priority: int """ - super(FailoverPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.location_name = location_name self.failover_priority = failover_priority @@ -5559,37 +5303,33 @@ class GraphAPIComputeRegionalServiceResource(RegionalServiceResource): :ivar location: The location name. :vartype location: str :ivar status: Describes the status of a service. Known values are: "Creating", "Running", - "Updating", "Deleting", "Error", "Stopped". + "Updating", "Deleting", "Error", and "Stopped". :vartype status: str or ~azure.mgmt.cosmosdb.models.ServiceStatus :ivar graph_api_compute_endpoint: The regional endpoint for GraphAPICompute. :vartype graph_api_compute_endpoint: str """ _validation = { - 'name': {'readonly': True}, - 'location': {'readonly': True}, - 'status': {'readonly': True}, - 'graph_api_compute_endpoint': {'readonly': True}, + "name": {"readonly": True}, + "location": {"readonly": True}, + "status": {"readonly": True}, + "graph_api_compute_endpoint": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'graph_api_compute_endpoint': {'key': 'graphApiComputeEndpoint', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "graph_api_compute_endpoint": {"key": "graphApiComputeEndpoint", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GraphAPIComputeRegionalServiceResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.graph_api_compute_endpoint = None -class GraphAPIComputeServiceResource(msrest.serialization.Model): +class GraphAPIComputeServiceResource(_serialization.Model): """Describes the service response property for GraphAPICompute. :ivar properties: Properties for GraphAPIComputeServiceResource. @@ -5597,20 +5337,15 @@ class GraphAPIComputeServiceResource(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': 'GraphAPIComputeServiceResourceProperties'}, + "properties": {"key": "properties", "type": "GraphAPIComputeServiceResourceProperties"}, } - def __init__( - self, - *, - properties: Optional["_models.GraphAPIComputeServiceResourceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.GraphAPIComputeServiceResourceProperties"] = None, **kwargs): """ :keyword properties: Properties for GraphAPIComputeServiceResource. :paramtype properties: ~azure.mgmt.cosmosdb.models.GraphAPIComputeServiceResourceProperties """ - super(GraphAPIComputeServiceResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties @@ -5623,20 +5358,19 @@ class GraphAPIComputeServiceResourceProperties(ServiceResourceProperties): :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] + :vartype additional_properties: dict[str, JSON] :ivar creation_time: Time of the last state change (ISO-8601 format). :vartype creation_time: ~datetime.datetime :ivar instance_size: Instance type for the service. Known values are: "Cosmos.D4s", - "Cosmos.D8s", "Cosmos.D16s". + "Cosmos.D8s", and "Cosmos.D16s". :vartype instance_size: str or ~azure.mgmt.cosmosdb.models.ServiceSize :ivar instance_count: Instance count for the service. :vartype instance_count: int - :ivar service_type: Required. ServiceType for the service.Constant filled by server. Known - values are: "SqlDedicatedGateway", "DataTransfer", "GraphAPICompute", - "MaterializedViewsBuilder". + :ivar service_type: ServiceType for the service. Required. Known values are: + "SqlDedicatedGateway", "DataTransfer", "GraphAPICompute", and "MaterializedViewsBuilder". :vartype service_type: str or ~azure.mgmt.cosmosdb.models.ServiceType :ivar status: Describes the status of a service. Known values are: "Creating", "Running", - "Updating", "Deleting", "Error", "Stopped". + "Updating", "Deleting", "Error", and "Stopped". :vartype status: str or ~azure.mgmt.cosmosdb.models.ServiceStatus :ivar graph_api_compute_endpoint: GraphAPICompute endpoint for the service. :vartype graph_api_compute_endpoint: str @@ -5645,28 +5379,28 @@ class GraphAPIComputeServiceResourceProperties(ServiceResourceProperties): """ _validation = { - 'creation_time': {'readonly': True}, - 'instance_count': {'minimum': 0}, - 'service_type': {'required': True}, - 'status': {'readonly': True}, - 'locations': {'readonly': True}, + "creation_time": {"readonly": True}, + "instance_count": {"minimum": 0}, + "service_type": {"required": True}, + "status": {"readonly": True}, + "locations": {"readonly": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, - 'instance_size': {'key': 'instanceSize', 'type': 'str'}, - 'instance_count': {'key': 'instanceCount', 'type': 'int'}, - 'service_type': {'key': 'serviceType', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'graph_api_compute_endpoint': {'key': 'graphApiComputeEndpoint', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[GraphAPIComputeRegionalServiceResource]'}, + "additional_properties": {"key": "", "type": "{object}"}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + "instance_size": {"key": "instanceSize", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, + "service_type": {"key": "serviceType", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "graph_api_compute_endpoint": {"key": "graphApiComputeEndpoint", "type": "str"}, + "locations": {"key": "locations", "type": "[GraphAPIComputeRegionalServiceResource]"}, } def __init__( self, *, - additional_properties: Optional[Dict[str, Any]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, instance_size: Optional[Union[str, "_models.ServiceSize"]] = None, instance_count: Optional[int] = None, graph_api_compute_endpoint: Optional[str] = None, @@ -5675,49 +5409,49 @@ def __init__( """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] :keyword instance_size: Instance type for the service. Known values are: "Cosmos.D4s", - "Cosmos.D8s", "Cosmos.D16s". + "Cosmos.D8s", and "Cosmos.D16s". :paramtype instance_size: str or ~azure.mgmt.cosmosdb.models.ServiceSize :keyword instance_count: Instance count for the service. :paramtype instance_count: int :keyword graph_api_compute_endpoint: GraphAPICompute endpoint for the service. :paramtype graph_api_compute_endpoint: str """ - super(GraphAPIComputeServiceResourceProperties, self).__init__(additional_properties=additional_properties, instance_size=instance_size, instance_count=instance_count, **kwargs) - self.service_type = 'GraphAPICompute' # type: str + super().__init__( + additional_properties=additional_properties, + instance_size=instance_size, + instance_count=instance_count, + **kwargs + ) + self.service_type = "GraphAPICompute" # type: str self.graph_api_compute_endpoint = graph_api_compute_endpoint self.locations = None -class GraphResource(msrest.serialization.Model): +class GraphResource(_serialization.Model): """Cosmos DB Graph resource object. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Name of the Cosmos DB Graph. + :ivar id: Name of the Cosmos DB Graph. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Name of the Cosmos DB Graph. + :keyword id: Name of the Cosmos DB Graph. Required. :paramtype id: str """ - super(GraphResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -5736,16 +5470,16 @@ class GraphResourceCreateUpdateParameters(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :ivar resource: Required. The standard JSON format of a Graph resource. + :ivar resource: The standard JSON format of a Graph resource. Required. :vartype resource: ~azure.mgmt.cosmosdb.models.GraphResource :ivar options: A key-value pair of options to be applied for the request. This corresponds to the headers sent with the request. @@ -5753,21 +5487,21 @@ class GraphResourceCreateUpdateParameters(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'GraphResource'}, - 'options': {'key': 'properties.options', 'type': 'CreateUpdateOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "GraphResource"}, + "options": {"key": "properties.options", "type": "CreateUpdateOptions"}, } def __init__( @@ -5783,22 +5517,22 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :keyword resource: Required. The standard JSON format of a Graph resource. + :keyword resource: The standard JSON format of a Graph resource. Required. :paramtype resource: ~azure.mgmt.cosmosdb.models.GraphResource :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(GraphResourceCreateUpdateParameters, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options @@ -5814,8 +5548,8 @@ class GraphResourceGetPropertiesOptions(OptionsResource): """ _attribute_map = { - 'throughput': {'key': 'throughput', 'type': 'int'}, - 'autoscale_settings': {'key': 'autoscaleSettings', 'type': 'AutoscaleSettings'}, + "throughput": {"key": "throughput", "type": "int"}, + "autoscale_settings": {"key": "autoscaleSettings", "type": "AutoscaleSettings"}, } def __init__( @@ -5832,7 +5566,7 @@ def __init__( :keyword autoscale_settings: Specifies the Autoscale settings. :paramtype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettings """ - super(GraphResourceGetPropertiesOptions, self).__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) + super().__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) class GraphResourceGetPropertiesResource(GraphResource): @@ -5840,29 +5574,24 @@ class GraphResourceGetPropertiesResource(GraphResource): All required parameters must be populated in order to send to Azure. - :ivar id: Required. Name of the Cosmos DB Graph. + :ivar id: Name of the Cosmos DB Graph. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Name of the Cosmos DB Graph. + :keyword id: Name of the Cosmos DB Graph. Required. :paramtype id: str """ - super(GraphResourceGetPropertiesResource, self).__init__(id=id, **kwargs) + super().__init__(id=id, **kwargs) class GraphResourceGetResults(ARMResourceProperties): @@ -5878,12 +5607,12 @@ class GraphResourceGetResults(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -5894,20 +5623,20 @@ class GraphResourceGetResults(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'GraphResourceGetPropertiesResource'}, - 'options': {'key': 'properties.options', 'type': 'GraphResourceGetPropertiesOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "GraphResourceGetPropertiesResource"}, + "options": {"key": "properties.options", "type": "GraphResourceGetPropertiesOptions"}, } def __init__( @@ -5923,12 +5652,12 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -5937,12 +5666,12 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.GraphResourceGetPropertiesOptions """ - super(GraphResourceGetResults, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options -class GraphResourcesListResult(msrest.serialization.Model): +class GraphResourcesListResult(_serialization.Model): """The List operation response, that contains the Graph resource and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -5952,20 +5681,16 @@ class GraphResourcesListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GraphResourceGetResults]'}, + "value": {"key": "value", "type": "[GraphResourceGetResults]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GraphResourcesListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -5984,16 +5709,16 @@ class GremlinDatabaseCreateUpdateParameters(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :ivar resource: Required. The standard JSON format of a Gremlin database. + :ivar resource: The standard JSON format of a Gremlin database. Required. :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. @@ -6001,21 +5726,21 @@ class GremlinDatabaseCreateUpdateParameters(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'GremlinDatabaseResource'}, - 'options': {'key': 'properties.options', 'type': 'CreateUpdateOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "GremlinDatabaseResource"}, + "options": {"key": "properties.options", "type": "CreateUpdateOptions"}, } def __init__( @@ -6031,22 +5756,22 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :keyword resource: Required. The standard JSON format of a Gremlin database. + :keyword resource: The standard JSON format of a Gremlin database. Required. :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, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options @@ -6062,8 +5787,8 @@ class GremlinDatabaseGetPropertiesOptions(OptionsResource): """ _attribute_map = { - 'throughput': {'key': 'throughput', 'type': 'int'}, - 'autoscale_settings': {'key': 'autoscaleSettings', 'type': 'AutoscaleSettings'}, + "throughput": {"key": "throughput", "type": "int"}, + "autoscale_settings": {"key": "autoscaleSettings", "type": "AutoscaleSettings"}, } def __init__( @@ -6080,49 +5805,42 @@ def __init__( :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) + super().__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) -class GremlinDatabaseResource(msrest.serialization.Model): +class GremlinDatabaseResource(_serialization.Model): """Cosmos DB Gremlin database resource object. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Name of the Cosmos DB Gremlin database. + :ivar id: Name of the Cosmos DB Gremlin database. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Name of the Cosmos DB Gremlin database. + :keyword id: Name of the Cosmos DB Gremlin database. Required. :paramtype id: str """ - super(GremlinDatabaseResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class GremlinDatabaseGetPropertiesResource(ExtendedResourceProperties, GremlinDatabaseResource): +class GremlinDatabaseGetPropertiesResource(GremlinDatabaseResource, ExtendedResourceProperties): """GremlinDatabaseGetPropertiesResource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :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. @@ -6130,37 +5848,34 @@ class GremlinDatabaseGetPropertiesResource(ExtendedResourceProperties, GremlinDa :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str + :ivar id: Name of the Cosmos DB Gremlin database. Required. + :vartype id: str """ _validation = { - 'id': {'required': True}, - 'rid': {'readonly': True}, - 'ts': {'readonly': True}, - 'etag': {'readonly': True}, + "rid": {"readonly": True}, + "ts": {"readonly": True}, + "etag": {"readonly": True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'rid': {'key': '_rid', 'type': 'str'}, - 'ts': {'key': '_ts', 'type': 'float'}, - 'etag': {'key': '_etag', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Name of the Cosmos DB Gremlin database. + :keyword id: Name of the Cosmos DB Gremlin database. Required. :paramtype id: str """ - super(GremlinDatabaseGetPropertiesResource, self).__init__(id=id, **kwargs) - self.id = id + super().__init__(id=id, **kwargs) self.rid = None self.ts = None self.etag = None + self.id = id class GremlinDatabaseGetResults(ARMResourceProperties): @@ -6176,12 +5891,12 @@ class GremlinDatabaseGetResults(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -6192,20 +5907,20 @@ class GremlinDatabaseGetResults(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'GremlinDatabaseGetPropertiesResource'}, - 'options': {'key': 'properties.options', 'type': 'GremlinDatabaseGetPropertiesOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "GremlinDatabaseGetPropertiesResource"}, + "options": {"key": "properties.options", "type": "GremlinDatabaseGetPropertiesOptions"}, } def __init__( @@ -6221,12 +5936,12 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -6235,12 +5950,12 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.GremlinDatabaseGetPropertiesOptions """ - super(GremlinDatabaseGetResults, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options -class GremlinDatabaseListResult(msrest.serialization.Model): +class GremlinDatabaseListResult(_serialization.Model): """The List operation response, that contains the Gremlin databases and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -6250,24 +5965,20 @@ class GremlinDatabaseListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GremlinDatabaseGetResults]'}, + "value": {"key": "value", "type": "[GremlinDatabaseGetResults]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GremlinDatabaseListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class GremlinDatabaseRestoreResource(msrest.serialization.Model): +class GremlinDatabaseRestoreResource(_serialization.Model): """Specific Gremlin Databases to restore. :ivar database_name: The name of the gremlin database available for restore. @@ -6277,24 +5988,18 @@ class GremlinDatabaseRestoreResource(msrest.serialization.Model): """ _attribute_map = { - 'database_name': {'key': 'databaseName', 'type': 'str'}, - 'graph_names': {'key': 'graphNames', 'type': '[str]'}, + "database_name": {"key": "databaseName", "type": "str"}, + "graph_names": {"key": "graphNames", "type": "[str]"}, } - def __init__( - self, - *, - database_name: Optional[str] = None, - graph_names: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, database_name: Optional[str] = None, graph_names: Optional[List[str]] = None, **kwargs): """ :keyword database_name: The name of the gremlin database available for restore. :paramtype database_name: str :keyword graph_names: The names of the graphs available for restore. :paramtype graph_names: list[str] """ - super(GremlinDatabaseRestoreResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.database_name = database_name self.graph_names = graph_names @@ -6314,16 +6019,16 @@ class GremlinGraphCreateUpdateParameters(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :ivar resource: Required. The standard JSON format of a Gremlin graph. + :ivar resource: The standard JSON format of a Gremlin graph. Required. :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. @@ -6331,21 +6036,21 @@ class GremlinGraphCreateUpdateParameters(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'GremlinGraphResource'}, - 'options': {'key': 'properties.options', 'type': 'CreateUpdateOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "GremlinGraphResource"}, + "options": {"key": "properties.options", "type": "CreateUpdateOptions"}, } def __init__( @@ -6361,22 +6066,22 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :keyword resource: Required. The standard JSON format of a Gremlin graph. + :keyword resource: The standard JSON format of a Gremlin graph. Required. :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, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options @@ -6392,8 +6097,8 @@ class GremlinGraphGetPropertiesOptions(OptionsResource): """ _attribute_map = { - 'throughput': {'key': 'throughput', 'type': 'int'}, - 'autoscale_settings': {'key': 'autoscaleSettings', 'type': 'AutoscaleSettings'}, + "throughput": {"key": "throughput", "type": "int"}, + "autoscale_settings": {"key": "autoscaleSettings", "type": "AutoscaleSettings"}, } def __init__( @@ -6410,15 +6115,15 @@ def __init__( :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) + super().__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) -class GremlinGraphResource(msrest.serialization.Model): +class GremlinGraphResource(_serialization.Model): """Cosmos DB Gremlin graph resource object. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Name of the Cosmos DB Gremlin graph. + :ivar id: Name of the Cosmos DB Gremlin graph. Required. :vartype id: str :ivar indexing_policy: The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the graph. @@ -6434,27 +6139,27 @@ class GremlinGraphResource(msrest.serialization.Model): :ivar conflict_resolution_policy: The conflict resolution policy for the graph. :vartype conflict_resolution_policy: ~azure.mgmt.cosmosdb.models.ConflictResolutionPolicy :ivar analytical_storage_ttl: Analytical TTL. - :vartype analytical_storage_ttl: long + :vartype analytical_storage_ttl: int """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'indexing_policy': {'key': 'indexingPolicy', 'type': 'IndexingPolicy'}, - 'partition_key': {'key': 'partitionKey', 'type': 'ContainerPartitionKey'}, - 'default_ttl': {'key': 'defaultTtl', 'type': 'int'}, - 'unique_key_policy': {'key': 'uniqueKeyPolicy', 'type': 'UniqueKeyPolicy'}, - 'conflict_resolution_policy': {'key': 'conflictResolutionPolicy', 'type': 'ConflictResolutionPolicy'}, - 'analytical_storage_ttl': {'key': 'analyticalStorageTtl', 'type': 'long'}, + "id": {"key": "id", "type": "str"}, + "indexing_policy": {"key": "indexingPolicy", "type": "IndexingPolicy"}, + "partition_key": {"key": "partitionKey", "type": "ContainerPartitionKey"}, + "default_ttl": {"key": "defaultTtl", "type": "int"}, + "unique_key_policy": {"key": "uniqueKeyPolicy", "type": "UniqueKeyPolicy"}, + "conflict_resolution_policy": {"key": "conflictResolutionPolicy", "type": "ConflictResolutionPolicy"}, + "analytical_storage_ttl": {"key": "analyticalStorageTtl", "type": "int"}, } def __init__( self, *, - id: str, + id: str, # pylint: disable=redefined-builtin indexing_policy: Optional["_models.IndexingPolicy"] = None, partition_key: Optional["_models.ContainerPartitionKey"] = None, default_ttl: Optional[int] = None, @@ -6464,7 +6169,7 @@ def __init__( **kwargs ): """ - :keyword id: Required. Name of the Cosmos DB Gremlin graph. + :keyword id: Name of the Cosmos DB Gremlin graph. Required. :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. @@ -6480,9 +6185,9 @@ def __init__( :keyword conflict_resolution_policy: The conflict resolution policy for the graph. :paramtype conflict_resolution_policy: ~azure.mgmt.cosmosdb.models.ConflictResolutionPolicy :keyword analytical_storage_ttl: Analytical TTL. - :paramtype analytical_storage_ttl: long + :paramtype analytical_storage_ttl: int """ - super(GremlinGraphResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.indexing_policy = indexing_policy self.partition_key = partition_key @@ -6492,14 +6197,21 @@ def __init__( self.analytical_storage_ttl = analytical_storage_ttl -class GremlinGraphGetPropertiesResource(ExtendedResourceProperties, GremlinGraphResource): +class GremlinGraphGetPropertiesResource(GremlinGraphResource, ExtendedResourceProperties): """GremlinGraphGetPropertiesResource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Name of the Cosmos DB Gremlin graph. + :ivar rid: A system generated property. A unique identifier. + :vartype rid: str + :ivar ts: A system generated property that denotes the last updated timestamp of the resource. + :vartype ts: float + :ivar etag: A system generated property representing the resource etag required for optimistic + concurrency control. + :vartype etag: str + :ivar id: Name of the Cosmos DB Gremlin graph. Required. :vartype id: str :ivar indexing_policy: The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the graph. @@ -6515,40 +6227,33 @@ class GremlinGraphGetPropertiesResource(ExtendedResourceProperties, GremlinGraph :ivar conflict_resolution_policy: The conflict resolution policy for the graph. :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. - :vartype ts: float - :ivar etag: A system generated property representing the resource etag required for optimistic - concurrency control. - :vartype etag: str + :vartype analytical_storage_ttl: int """ _validation = { - 'id': {'required': True}, - 'rid': {'readonly': True}, - 'ts': {'readonly': True}, - 'etag': {'readonly': True}, + "rid": {"readonly": True}, + "ts": {"readonly": True}, + "etag": {"readonly": True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'indexing_policy': {'key': 'indexingPolicy', 'type': 'IndexingPolicy'}, - 'partition_key': {'key': 'partitionKey', 'type': 'ContainerPartitionKey'}, - 'default_ttl': {'key': 'defaultTtl', 'type': 'int'}, - 'unique_key_policy': {'key': 'uniqueKeyPolicy', 'type': 'UniqueKeyPolicy'}, - 'conflict_resolution_policy': {'key': 'conflictResolutionPolicy', 'type': 'ConflictResolutionPolicy'}, - 'analytical_storage_ttl': {'key': 'analyticalStorageTtl', 'type': 'long'}, - 'rid': {'key': '_rid', 'type': 'str'}, - 'ts': {'key': '_ts', 'type': 'float'}, - 'etag': {'key': '_etag', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "indexing_policy": {"key": "indexingPolicy", "type": "IndexingPolicy"}, + "partition_key": {"key": "partitionKey", "type": "ContainerPartitionKey"}, + "default_ttl": {"key": "defaultTtl", "type": "int"}, + "unique_key_policy": {"key": "uniqueKeyPolicy", "type": "UniqueKeyPolicy"}, + "conflict_resolution_policy": {"key": "conflictResolutionPolicy", "type": "ConflictResolutionPolicy"}, + "analytical_storage_ttl": {"key": "analyticalStorageTtl", "type": "int"}, } def __init__( self, *, - id: str, + id: str, # pylint: disable=redefined-builtin indexing_policy: Optional["_models.IndexingPolicy"] = None, partition_key: Optional["_models.ContainerPartitionKey"] = None, default_ttl: Optional[int] = None, @@ -6558,7 +6263,7 @@ def __init__( **kwargs ): """ - :keyword id: Required. Name of the Cosmos DB Gremlin graph. + :keyword id: Name of the Cosmos DB Gremlin graph. Required. :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. @@ -6574,9 +6279,21 @@ def __init__( :keyword conflict_resolution_policy: The conflict resolution policy for the graph. :paramtype conflict_resolution_policy: ~azure.mgmt.cosmosdb.models.ConflictResolutionPolicy :keyword analytical_storage_ttl: Analytical TTL. - :paramtype analytical_storage_ttl: long + :paramtype analytical_storage_ttl: int """ - 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, analytical_storage_ttl=analytical_storage_ttl, **kwargs) + super().__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.rid = None + self.ts = None + self.etag = None self.id = id self.indexing_policy = indexing_policy self.partition_key = partition_key @@ -6584,9 +6301,6 @@ def __init__( self.unique_key_policy = unique_key_policy self.conflict_resolution_policy = conflict_resolution_policy self.analytical_storage_ttl = analytical_storage_ttl - self.rid = None - self.ts = None - self.etag = None class GremlinGraphGetResults(ARMResourceProperties): @@ -6602,12 +6316,12 @@ class GremlinGraphGetResults(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -6618,20 +6332,20 @@ class GremlinGraphGetResults(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'GremlinGraphGetPropertiesResource'}, - 'options': {'key': 'properties.options', 'type': 'GremlinGraphGetPropertiesOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "GremlinGraphGetPropertiesResource"}, + "options": {"key": "properties.options", "type": "GremlinGraphGetPropertiesOptions"}, } def __init__( @@ -6647,12 +6361,12 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -6661,12 +6375,12 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.GremlinGraphGetPropertiesOptions """ - super(GremlinGraphGetResults, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options -class GremlinGraphListResult(msrest.serialization.Model): +class GremlinGraphListResult(_serialization.Model): """The List operation response, that contains the graphs and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -6676,24 +6390,20 @@ class GremlinGraphListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GremlinGraphGetResults]'}, + "value": {"key": "value", "type": "[GremlinGraphGetResults]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GremlinGraphListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class IncludedPath(msrest.serialization.Model): +class IncludedPath(_serialization.Model): """The paths that are included in indexing. :ivar path: The path for which the indexing behavior applies to. Index paths typically start @@ -6704,17 +6414,11 @@ class IncludedPath(msrest.serialization.Model): """ _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'indexes': {'key': 'indexes', 'type': '[Indexes]'}, + "path": {"key": "path", "type": "str"}, + "indexes": {"key": "indexes", "type": "[Indexes]"}, } - def __init__( - self, - *, - path: Optional[str] = None, - indexes: Optional[List["_models.Indexes"]] = None, - **kwargs - ): + def __init__(self, *, path: Optional[str] = None, indexes: Optional[List["_models.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/*). @@ -6722,62 +6426,59 @@ def __init__( :keyword indexes: List of indexes for this path. :paramtype indexes: list[~azure.mgmt.cosmosdb.models.Indexes] """ - super(IncludedPath, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.indexes = indexes -class Indexes(msrest.serialization.Model): +class Indexes(_serialization.Model): """The indexes for the path. :ivar data_type: The datatype for which the indexing behavior is applied to. Known values are: - "String", "Number", "Point", "Polygon", "LineString", "MultiPolygon". Default value: "String". + "String", "Number", "Point", "Polygon", "LineString", and "MultiPolygon". :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. Known values are: "Hash", "Range", "Spatial". Default - value: "Hash". + :ivar kind: Indicates the type of index. Known values are: "Hash", "Range", and "Spatial". :vartype kind: str or ~azure.mgmt.cosmosdb.models.IndexKind """ _attribute_map = { - 'data_type': {'key': 'dataType', 'type': 'str'}, - 'precision': {'key': 'precision', 'type': 'int'}, - 'kind': {'key': 'kind', 'type': 'str'}, + "data_type": {"key": "dataType", "type": "str"}, + "precision": {"key": "precision", "type": "int"}, + "kind": {"key": "kind", "type": "str"}, } def __init__( self, *, - data_type: Optional[Union[str, "_models.DataType"]] = "String", + data_type: Union[str, "_models.DataType"] = "String", precision: Optional[int] = None, - kind: Optional[Union[str, "_models.IndexKind"]] = "Hash", + kind: Union[str, "_models.IndexKind"] = "Hash", **kwargs ): """ :keyword data_type: The datatype for which the indexing behavior is applied to. Known values - are: "String", "Number", "Point", "Polygon", "LineString", "MultiPolygon". Default value: - "String". + are: "String", "Number", "Point", "Polygon", "LineString", and "MultiPolygon". :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. Known values are: "Hash", "Range", "Spatial". - Default value: "Hash". + :keyword kind: Indicates the type of index. Known values are: "Hash", "Range", and "Spatial". :paramtype kind: str or ~azure.mgmt.cosmosdb.models.IndexKind """ - super(Indexes, self).__init__(**kwargs) + super().__init__(**kwargs) self.data_type = data_type self.precision = precision self.kind = kind -class IndexingPolicy(msrest.serialization.Model): +class IndexingPolicy(_serialization.Model): """Cosmos DB indexing policy. :ivar automatic: Indicates if the indexing policy is automatic. :vartype automatic: bool - :ivar indexing_mode: Indicates the indexing mode. Known values are: "consistent", "lazy", - "none". Default value: "consistent". + :ivar indexing_mode: Indicates the indexing mode. Known values are: "consistent", "lazy", and + "none". :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] @@ -6790,19 +6491,19 @@ class IndexingPolicy(msrest.serialization.Model): """ _attribute_map = { - 'automatic': {'key': 'automatic', 'type': 'bool'}, - 'indexing_mode': {'key': 'indexingMode', 'type': 'str'}, - 'included_paths': {'key': 'includedPaths', 'type': '[IncludedPath]'}, - 'excluded_paths': {'key': 'excludedPaths', 'type': '[ExcludedPath]'}, - 'composite_indexes': {'key': 'compositeIndexes', 'type': '[[CompositePath]]'}, - 'spatial_indexes': {'key': 'spatialIndexes', 'type': '[SpatialSpec]'}, + "automatic": {"key": "automatic", "type": "bool"}, + "indexing_mode": {"key": "indexingMode", "type": "str"}, + "included_paths": {"key": "includedPaths", "type": "[IncludedPath]"}, + "excluded_paths": {"key": "excludedPaths", "type": "[ExcludedPath]"}, + "composite_indexes": {"key": "compositeIndexes", "type": "[[CompositePath]]"}, + "spatial_indexes": {"key": "spatialIndexes", "type": "[SpatialSpec]"}, } def __init__( self, *, automatic: Optional[bool] = None, - indexing_mode: Optional[Union[str, "_models.IndexingMode"]] = "consistent", + indexing_mode: Union[str, "_models.IndexingMode"] = "consistent", included_paths: Optional[List["_models.IncludedPath"]] = None, excluded_paths: Optional[List["_models.ExcludedPath"]] = None, composite_indexes: Optional[List[List["_models.CompositePath"]]] = None, @@ -6813,7 +6514,7 @@ def __init__( :keyword automatic: Indicates if the indexing policy is automatic. :paramtype automatic: bool :keyword indexing_mode: Indicates the indexing mode. Known values are: "consistent", "lazy", - "none". Default value: "consistent". + and "none". :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] @@ -6824,7 +6525,7 @@ def __init__( :keyword spatial_indexes: List of spatial specifics. :paramtype spatial_indexes: list[~azure.mgmt.cosmosdb.models.SpatialSpec] """ - super(IndexingPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.automatic = automatic self.indexing_mode = indexing_mode self.included_paths = included_paths @@ -6833,7 +6534,7 @@ def __init__( self.spatial_indexes = spatial_indexes -class IpAddressOrRange(msrest.serialization.Model): +class IpAddressOrRange(_serialization.Model): """IpAddressOrRange object. :ivar ip_address_or_range: A single IPv4 address or a single IPv4 address range in CIDR format. @@ -6844,15 +6545,10 @@ class IpAddressOrRange(msrest.serialization.Model): """ _attribute_map = { - 'ip_address_or_range': {'key': 'ipAddressOrRange', 'type': 'str'}, + "ip_address_or_range": {"key": "ipAddressOrRange", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: Optional[str] = None, - **kwargs - ): + def __init__(self, *, 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 @@ -6861,11 +6557,11 @@ def __init__( “23.40.210.0/8”. :paramtype ip_address_or_range: str """ - super(IpAddressOrRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_address_or_range = ip_address_or_range -class KeyWrapMetadata(msrest.serialization.Model): +class KeyWrapMetadata(_serialization.Model): """Represents key wrap metadata that a key wrapping provider can use to wrap/unwrap a client encryption key. :ivar name: The name of associated KeyEncryptionKey (aka CustomerManagedKey). @@ -6879,10 +6575,10 @@ class KeyWrapMetadata(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'algorithm': {'key': 'algorithm', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "algorithm": {"key": "algorithm", "type": "str"}, } def __init__( @@ -6904,14 +6600,14 @@ def __init__( :keyword algorithm: Algorithm used in wrapping and unwrapping of the data encryption key. :paramtype algorithm: str """ - super(KeyWrapMetadata, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type self.value = value self.algorithm = algorithm -class ListBackups(msrest.serialization.Model): +class ListBackups(_serialization.Model): """List of restorable backups for a Cassandra cluster. Variables are only populated by the server, and will be ignored when sending a request. @@ -6921,24 +6617,20 @@ class ListBackups(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BackupResource]'}, + "value": {"key": "value", "type": "[BackupResource]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListBackups, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class ListClusters(msrest.serialization.Model): +class ListClusters(_serialization.Model): """List of managed Cassandra clusters. :ivar value: Container for the array of clusters. @@ -6946,24 +6638,19 @@ class ListClusters(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ClusterResource]'}, + "value": {"key": "value", "type": "[ClusterResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.ClusterResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ClusterResource"]] = None, **kwargs): """ :keyword value: Container for the array of clusters. :paramtype value: list[~azure.mgmt.cosmosdb.models.ClusterResource] """ - super(ListClusters, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class ListDataCenters(msrest.serialization.Model): +class ListDataCenters(_serialization.Model): """List of managed Cassandra data centers and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -6973,24 +6660,20 @@ class ListDataCenters(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DataCenterResource]'}, + "value": {"key": "value", "type": "[DataCenterResource]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListDataCenters, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class Location(msrest.serialization.Model): +class Location(_serialization.Model): """A region in which the Azure Cosmos DB database account is deployed. Variables are only populated by the server, and will be ignored when sending a request. @@ -7022,19 +6705,19 @@ class Location(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'document_endpoint': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'failover_priority': {'minimum': 0}, + "id": {"readonly": True}, + "document_endpoint": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "failover_priority": {"minimum": 0}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'location_name': {'key': 'locationName', 'type': 'str'}, - 'document_endpoint': {'key': 'documentEndpoint', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'failover_priority': {'key': 'failoverPriority', 'type': 'int'}, - 'is_zone_redundant': {'key': 'isZoneRedundant', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "location_name": {"key": "locationName", "type": "str"}, + "document_endpoint": {"key": "documentEndpoint", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "failover_priority": {"key": "failoverPriority", "type": "int"}, + "is_zone_redundant": {"key": "isZoneRedundant", "type": "bool"}, } def __init__( @@ -7057,7 +6740,7 @@ def __init__( region. :paramtype is_zone_redundant: bool """ - super(Location, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.location_name = location_name self.document_endpoint = None @@ -7082,33 +6765,28 @@ class LocationGetResult(ARMProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'LocationProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "LocationProperties"}, } - def __init__( - self, - *, - properties: Optional["_models.LocationProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.LocationProperties"] = None, **kwargs): """ :keyword properties: Cosmos DB location metadata. :paramtype properties: ~azure.mgmt.cosmosdb.models.LocationProperties """ - super(LocationGetResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class LocationListResult(msrest.serialization.Model): +class LocationListResult(_serialization.Model): """The List operation response, that contains Cosmos DB locations and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -7118,24 +6796,20 @@ class LocationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[LocationGetResult]'}, + "value": {"key": "value", "type": "[LocationGetResult]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(LocationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class LocationProperties(msrest.serialization.Model): +class LocationProperties(_serialization.Model): """Cosmos DB location metadata. Variables are only populated by the server, and will be ignored when sending a request. @@ -7153,33 +6827,29 @@ class LocationProperties(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'supports_availability_zone': {'readonly': True}, - 'is_residency_restricted': {'readonly': True}, - 'backup_storage_redundancies': {'readonly': True}, + "status": {"readonly": True}, + "supports_availability_zone": {"readonly": True}, + "is_residency_restricted": {"readonly": True}, + "backup_storage_redundancies": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'supports_availability_zone': {'key': 'supportsAvailabilityZone', 'type': 'bool'}, - 'is_residency_restricted': {'key': 'isResidencyRestricted', 'type': 'bool'}, - 'backup_storage_redundancies': {'key': 'backupStorageRedundancies', 'type': '[str]'}, + "status": {"key": "status", "type": "str"}, + "supports_availability_zone": {"key": "supportsAvailabilityZone", "type": "bool"}, + "is_residency_restricted": {"key": "isResidencyRestricted", "type": "bool"}, + "backup_storage_redundancies": {"key": "backupStorageRedundancies", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(LocationProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.supports_availability_zone = None self.is_residency_restricted = None self.backup_storage_redundancies = None -class ManagedCassandraManagedServiceIdentity(msrest.serialization.Model): +class ManagedCassandraManagedServiceIdentity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -7188,38 +6858,33 @@ class ManagedCassandraManagedServiceIdentity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant id of the resource. :vartype tenant_id: str - :ivar type: The type of the resource. Known values are: "SystemAssigned", "None". + :ivar type: The type of the resource. Known values are: "SystemAssigned" and "None". :vartype type: str or ~azure.mgmt.cosmosdb.models.ManagedCassandraResourceIdentityType """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Optional[Union[str, "_models.ManagedCassandraResourceIdentityType"]] = None, - **kwargs - ): + def __init__(self, *, type: Optional[Union[str, "_models.ManagedCassandraResourceIdentityType"]] = None, **kwargs): """ - :keyword type: The type of the resource. Known values are: "SystemAssigned", "None". + :keyword type: The type of the resource. Known values are: "SystemAssigned" and "None". :paramtype type: str or ~azure.mgmt.cosmosdb.models.ManagedCassandraResourceIdentityType """ - super(ManagedCassandraManagedServiceIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class ManagedCassandraReaperStatus(msrest.serialization.Model): +class ManagedCassandraReaperStatus(_serialization.Model): """ManagedCassandraReaperStatus. :ivar healthy: @@ -7231,9 +6896,9 @@ class ManagedCassandraReaperStatus(msrest.serialization.Model): """ _attribute_map = { - 'healthy': {'key': 'healthy', 'type': 'bool'}, - 'repair_run_ids': {'key': 'repairRunIds', 'type': '{str}'}, - 'repair_schedules': {'key': 'repairSchedules', 'type': '{str}'}, + "healthy": {"key": "healthy", "type": "bool"}, + "repair_run_ids": {"key": "repairRunIds", "type": "{str}"}, + "repair_schedules": {"key": "repairSchedules", "type": "{str}"}, } def __init__( @@ -7252,13 +6917,13 @@ def __init__( :keyword repair_schedules: Dictionary of :code:``. :paramtype repair_schedules: dict[str, str] """ - super(ManagedCassandraReaperStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.healthy = healthy self.repair_run_ids = repair_run_ids self.repair_schedules = repair_schedules -class ManagedServiceIdentity(msrest.serialization.Model): +class ManagedServiceIdentity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -7272,53 +6937,84 @@ class ManagedServiceIdentity(msrest.serialization.Model): :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. Known values are: "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned", "None". + "UserAssigned", "SystemAssigned,UserAssigned", and "None". :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}'. :vartype user_assigned_identities: dict[str, - ~azure.mgmt.cosmosdb.models.Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties] + ~azure.mgmt.cosmosdb.models.ManagedServiceIdentityUserAssignedIdentity] """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": { + "key": "userAssignedIdentities", + "type": "{ManagedServiceIdentityUserAssignedIdentity}", + }, } def __init__( self, *, type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "_models.Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.ManagedServiceIdentityUserAssignedIdentity"]] = 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. Known values - are: "SystemAssigned", "UserAssigned", "SystemAssigned,UserAssigned", "None". + are: "SystemAssigned", "UserAssigned", "SystemAssigned,UserAssigned", and "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] + ~azure.mgmt.cosmosdb.models.ManagedServiceIdentityUserAssignedIdentity] """ - super(ManagedServiceIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities +class ManagedServiceIdentityUserAssignedIdentity(_serialization.Model): + """ManagedServiceIdentityUserAssignedIdentity. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.principal_id = None + self.client_id = None + + class MaterializedViewsBuilderRegionalServiceResource(RegionalServiceResource): """Resource for a regional service location. @@ -7329,32 +7025,28 @@ class MaterializedViewsBuilderRegionalServiceResource(RegionalServiceResource): :ivar location: The location name. :vartype location: str :ivar status: Describes the status of a service. Known values are: "Creating", "Running", - "Updating", "Deleting", "Error", "Stopped". + "Updating", "Deleting", "Error", and "Stopped". :vartype status: str or ~azure.mgmt.cosmosdb.models.ServiceStatus """ _validation = { - 'name': {'readonly': True}, - 'location': {'readonly': True}, - 'status': {'readonly': True}, + "name": {"readonly": True}, + "location": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MaterializedViewsBuilderRegionalServiceResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) -class MaterializedViewsBuilderServiceResource(msrest.serialization.Model): +class MaterializedViewsBuilderServiceResource(_serialization.Model): """Describes the service response property for MaterializedViewsBuilder. :ivar properties: Properties for MaterializedViewsBuilderServiceResource. @@ -7363,21 +7055,18 @@ class MaterializedViewsBuilderServiceResource(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': 'MaterializedViewsBuilderServiceResourceProperties'}, + "properties": {"key": "properties", "type": "MaterializedViewsBuilderServiceResourceProperties"}, } def __init__( - self, - *, - properties: Optional["_models.MaterializedViewsBuilderServiceResourceProperties"] = None, - **kwargs + self, *, properties: Optional["_models.MaterializedViewsBuilderServiceResourceProperties"] = None, **kwargs ): """ :keyword properties: Properties for MaterializedViewsBuilderServiceResource. :paramtype properties: ~azure.mgmt.cosmosdb.models.MaterializedViewsBuilderServiceResourceProperties """ - super(MaterializedViewsBuilderServiceResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties @@ -7390,20 +7079,19 @@ class MaterializedViewsBuilderServiceResourceProperties(ServiceResourcePropertie :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] + :vartype additional_properties: dict[str, JSON] :ivar creation_time: Time of the last state change (ISO-8601 format). :vartype creation_time: ~datetime.datetime :ivar instance_size: Instance type for the service. Known values are: "Cosmos.D4s", - "Cosmos.D8s", "Cosmos.D16s". + "Cosmos.D8s", and "Cosmos.D16s". :vartype instance_size: str or ~azure.mgmt.cosmosdb.models.ServiceSize :ivar instance_count: Instance count for the service. :vartype instance_count: int - :ivar service_type: Required. ServiceType for the service.Constant filled by server. Known - values are: "SqlDedicatedGateway", "DataTransfer", "GraphAPICompute", - "MaterializedViewsBuilder". + :ivar service_type: ServiceType for the service. Required. Known values are: + "SqlDedicatedGateway", "DataTransfer", "GraphAPICompute", and "MaterializedViewsBuilder". :vartype service_type: str or ~azure.mgmt.cosmosdb.models.ServiceType :ivar status: Describes the status of a service. Known values are: "Creating", "Running", - "Updating", "Deleting", "Error", "Stopped". + "Updating", "Deleting", "Error", and "Stopped". :vartype status: str or ~azure.mgmt.cosmosdb.models.ServiceStatus :ivar locations: An array that contains all of the locations for the service. :vartype locations: @@ -7411,27 +7099,27 @@ class MaterializedViewsBuilderServiceResourceProperties(ServiceResourcePropertie """ _validation = { - 'creation_time': {'readonly': True}, - 'instance_count': {'minimum': 0}, - 'service_type': {'required': True}, - 'status': {'readonly': True}, - 'locations': {'readonly': True}, + "creation_time": {"readonly": True}, + "instance_count": {"minimum": 0}, + "service_type": {"required": True}, + "status": {"readonly": True}, + "locations": {"readonly": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, - 'instance_size': {'key': 'instanceSize', 'type': 'str'}, - 'instance_count': {'key': 'instanceCount', 'type': 'int'}, - 'service_type': {'key': 'serviceType', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[MaterializedViewsBuilderRegionalServiceResource]'}, + "additional_properties": {"key": "", "type": "{object}"}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + "instance_size": {"key": "instanceSize", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, + "service_type": {"key": "serviceType", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "locations": {"key": "locations", "type": "[MaterializedViewsBuilderRegionalServiceResource]"}, } def __init__( self, *, - additional_properties: Optional[Dict[str, Any]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, instance_size: Optional[Union[str, "_models.ServiceSize"]] = None, instance_count: Optional[int] = None, **kwargs @@ -7439,19 +7127,24 @@ def __init__( """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] :keyword instance_size: Instance type for the service. Known values are: "Cosmos.D4s", - "Cosmos.D8s", "Cosmos.D16s". + "Cosmos.D8s", and "Cosmos.D16s". :paramtype instance_size: str or ~azure.mgmt.cosmosdb.models.ServiceSize :keyword instance_count: Instance count for the service. :paramtype instance_count: int """ - super(MaterializedViewsBuilderServiceResourceProperties, self).__init__(additional_properties=additional_properties, instance_size=instance_size, instance_count=instance_count, **kwargs) - self.service_type = 'MaterializedViewsBuilder' # type: str + super().__init__( + additional_properties=additional_properties, + instance_size=instance_size, + instance_count=instance_count, + **kwargs + ) + self.service_type = "MaterializedViewsBuilder" # type: str self.locations = None -class MergeParameters(msrest.serialization.Model): +class MergeParameters(_serialization.Model): """The properties of an Azure Cosmos DB merge operations. :ivar is_dry_run: Specifies whether the operation is a real merge operation or a simulation. @@ -7459,24 +7152,19 @@ class MergeParameters(msrest.serialization.Model): """ _attribute_map = { - 'is_dry_run': {'key': 'isDryRun', 'type': 'bool'}, + "is_dry_run": {"key": "isDryRun", "type": "bool"}, } - def __init__( - self, - *, - is_dry_run: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, is_dry_run: Optional[bool] = None, **kwargs): """ :keyword is_dry_run: Specifies whether the operation is a real merge operation or a simulation. :paramtype is_dry_run: bool """ - super(MergeParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_dry_run = is_dry_run -class Metric(msrest.serialization.Model): +class Metric(_serialization.Model): """Metric data. Variables are only populated by the server, and will be ignored when sending a request. @@ -7488,7 +7176,7 @@ class Metric(msrest.serialization.Model): :ivar time_grain: The time grain to be used to summarize the metric values. :vartype time_grain: str :ivar unit: The unit of the metric. Known values are: "Count", "Bytes", "Seconds", "Percent", - "CountPerSecond", "BytesPerSecond", "Milliseconds". + "CountPerSecond", "BytesPerSecond", and "Milliseconds". :vartype unit: str or ~azure.mgmt.cosmosdb.models.UnitType :ivar name: The name information for the metric. :vartype name: ~azure.mgmt.cosmosdb.models.MetricName @@ -7497,30 +7185,26 @@ class Metric(msrest.serialization.Model): """ _validation = { - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'time_grain': {'readonly': True}, - 'unit': {'readonly': True}, - 'name': {'readonly': True}, - 'metric_values': {'readonly': True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + "time_grain": {"readonly": True}, + "unit": {"readonly": True}, + "name": {"readonly": True}, + "metric_values": {"readonly": True}, } _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'time_grain': {'key': 'timeGrain', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'MetricName'}, - 'metric_values': {'key': 'metricValues', 'type': '[MetricValue]'}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "time_grain": {"key": "timeGrain", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "name": {"key": "name", "type": "MetricName"}, + "metric_values": {"key": "metricValues", "type": "[MetricValue]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Metric, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.start_time = None self.end_time = None self.time_grain = None @@ -7529,7 +7213,7 @@ def __init__( self.metric_values = None -class MetricAvailability(msrest.serialization.Model): +class MetricAvailability(_serialization.Model): """The availability of the metric. Variables are only populated by the server, and will be ignored when sending a request. @@ -7541,27 +7225,23 @@ class MetricAvailability(msrest.serialization.Model): """ _validation = { - 'time_grain': {'readonly': True}, - 'retention': {'readonly': True}, + "time_grain": {"readonly": True}, + "retention": {"readonly": True}, } _attribute_map = { - 'time_grain': {'key': 'timeGrain', 'type': 'str'}, - 'retention': {'key': 'retention', 'type': 'str'}, + "time_grain": {"key": "timeGrain", "type": "str"}, + "retention": {"key": "retention", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MetricAvailability, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.time_grain = None self.retention = None -class MetricDefinition(msrest.serialization.Model): +class MetricDefinition(_serialization.Model): """The definition of a metric. Variables are only populated by the server, and will be ignored when sending a request. @@ -7569,10 +7249,10 @@ class MetricDefinition(msrest.serialization.Model): :ivar metric_availabilities: The list of metric availabilities for the account. :vartype metric_availabilities: list[~azure.mgmt.cosmosdb.models.MetricAvailability] :ivar primary_aggregation_type: The primary aggregation type of the metric. Known values are: - "None", "Average", "Total", "Minimum", "Maximum", "Last". + "None", "Average", "Total", "Minimum", "Maximum", and "Last". :vartype primary_aggregation_type: str or ~azure.mgmt.cosmosdb.models.PrimaryAggregationType :ivar unit: The unit of the metric. Known values are: "Count", "Bytes", "Seconds", "Percent", - "CountPerSecond", "BytesPerSecond", "Milliseconds". + "CountPerSecond", "BytesPerSecond", and "Milliseconds". :vartype unit: str or ~azure.mgmt.cosmosdb.models.UnitType :ivar resource_uri: The resource uri of the database. :vartype resource_uri: str @@ -7581,28 +7261,24 @@ class MetricDefinition(msrest.serialization.Model): """ _validation = { - 'metric_availabilities': {'readonly': True}, - 'primary_aggregation_type': {'readonly': True}, - 'unit': {'readonly': True}, - 'resource_uri': {'readonly': True}, - 'name': {'readonly': True}, + "metric_availabilities": {"readonly": True}, + "primary_aggregation_type": {"readonly": True}, + "unit": {"readonly": True}, + "resource_uri": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'metric_availabilities': {'key': 'metricAvailabilities', 'type': '[MetricAvailability]'}, - 'primary_aggregation_type': {'key': 'primaryAggregationType', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'MetricName'}, + "metric_availabilities": {"key": "metricAvailabilities", "type": "[MetricAvailability]"}, + "primary_aggregation_type": {"key": "primaryAggregationType", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "resource_uri": {"key": "resourceUri", "type": "str"}, + "name": {"key": "name", "type": "MetricName"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MetricDefinition, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.metric_availabilities = None self.primary_aggregation_type = None self.unit = None @@ -7610,7 +7286,7 @@ def __init__( self.name = None -class MetricDefinitionsListResult(msrest.serialization.Model): +class MetricDefinitionsListResult(_serialization.Model): """The response to a list metric definitions request. Variables are only populated by the server, and will be ignored when sending a request. @@ -7620,24 +7296,20 @@ class MetricDefinitionsListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MetricDefinition]'}, + "value": {"key": "value", "type": "[MetricDefinition]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MetricDefinitionsListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class MetricListResult(msrest.serialization.Model): +class MetricListResult(_serialization.Model): """The response to a list metrics request. Variables are only populated by the server, and will be ignored when sending a request. @@ -7647,24 +7319,20 @@ class MetricListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Metric]'}, + "value": {"key": "value", "type": "[Metric]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MetricListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class MetricName(msrest.serialization.Model): +class MetricName(_serialization.Model): """A metric name. Variables are only populated by the server, and will be ignored when sending a request. @@ -7676,27 +7344,23 @@ class MetricName(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'localized_value': {'readonly': True}, + "value": {"readonly": True}, + "localized_value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MetricName, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.localized_value = None -class MetricValue(msrest.serialization.Model): +class MetricValue(_serialization.Model): """Represents metrics values. Variables are only populated by the server, and will be ignored when sending a request. @@ -7716,30 +7380,26 @@ class MetricValue(msrest.serialization.Model): """ _validation = { - 'count': {'readonly': True}, - 'average': {'readonly': True}, - 'maximum': {'readonly': True}, - 'minimum': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'total': {'readonly': True}, + "count": {"readonly": True}, + "average": {"readonly": True}, + "maximum": {"readonly": True}, + "minimum": {"readonly": True}, + "timestamp": {"readonly": True}, + "total": {"readonly": True}, } _attribute_map = { - 'count': {'key': '_count', 'type': 'int'}, - 'average': {'key': 'average', 'type': 'float'}, - 'maximum': {'key': 'maximum', 'type': 'float'}, - 'minimum': {'key': 'minimum', 'type': 'float'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'total': {'key': 'total', 'type': 'float'}, + "count": {"key": "_count", "type": "int"}, + "average": {"key": "average", "type": "float"}, + "maximum": {"key": "maximum", "type": "float"}, + "minimum": {"key": "minimum", "type": "float"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "total": {"key": "total", "type": "float"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MetricValue, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.count = None self.average = None self.maximum = None @@ -7763,16 +7423,16 @@ class MongoDBCollectionCreateUpdateParameters(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :ivar resource: Required. The standard JSON format of a MongoDB collection. + :ivar resource: The standard JSON format of a MongoDB collection. Required. :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. @@ -7780,21 +7440,21 @@ class MongoDBCollectionCreateUpdateParameters(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'MongoDBCollectionResource'}, - 'options': {'key': 'properties.options', 'type': 'CreateUpdateOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "MongoDBCollectionResource"}, + "options": {"key": "properties.options", "type": "CreateUpdateOptions"}, } def __init__( @@ -7810,22 +7470,22 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :keyword resource: Required. The standard JSON format of a MongoDB collection. + :keyword resource: The standard JSON format of a MongoDB collection. Required. :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, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options @@ -7841,8 +7501,8 @@ class MongoDBCollectionGetPropertiesOptions(OptionsResource): """ _attribute_map = { - 'throughput': {'key': 'throughput', 'type': 'int'}, - 'autoscale_settings': {'key': 'autoscaleSettings', 'type': 'AutoscaleSettings'}, + "throughput": {"key": "throughput", "type": "int"}, + "autoscale_settings": {"key": "autoscaleSettings", "type": "AutoscaleSettings"}, } def __init__( @@ -7859,15 +7519,15 @@ def __init__( :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) + super().__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) -class MongoDBCollectionResource(msrest.serialization.Model): +class MongoDBCollectionResource(_serialization.Model): """Cosmos DB MongoDB collection resource object. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Name of the Cosmos DB MongoDB collection. + :ivar id: Name of the Cosmos DB MongoDB collection. Required. :vartype id: str :ivar shard_key: A key-value pair of shard keys to be applied for the request. :vartype shard_key: dict[str, str] @@ -7878,27 +7538,27 @@ class MongoDBCollectionResource(msrest.serialization.Model): """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'shard_key': {'key': 'shardKey', 'type': '{str}'}, - 'indexes': {'key': 'indexes', 'type': '[MongoIndex]'}, - 'analytical_storage_ttl': {'key': 'analyticalStorageTtl', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "shard_key": {"key": "shardKey", "type": "{str}"}, + "indexes": {"key": "indexes", "type": "[MongoIndex]"}, + "analytical_storage_ttl": {"key": "analyticalStorageTtl", "type": "int"}, } def __init__( self, *, - id: str, + id: str, # pylint: disable=redefined-builtin shard_key: Optional[Dict[str, str]] = None, indexes: Optional[List["_models.MongoIndex"]] = None, analytical_storage_ttl: Optional[int] = None, **kwargs ): """ - :keyword id: Required. Name of the Cosmos DB MongoDB collection. + :keyword id: Name of the Cosmos DB MongoDB collection. Required. :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] @@ -7907,28 +7567,20 @@ def __init__( :keyword analytical_storage_ttl: Analytical TTL. :paramtype analytical_storage_ttl: int """ - super(MongoDBCollectionResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.shard_key = shard_key self.indexes = indexes self.analytical_storage_ttl = analytical_storage_ttl -class MongoDBCollectionGetPropertiesResource(ExtendedResourceProperties, MongoDBCollectionResource): +class MongoDBCollectionGetPropertiesResource(MongoDBCollectionResource, ExtendedResourceProperties): """MongoDBCollectionGetPropertiesResource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :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. @@ -7936,36 +7588,44 @@ class MongoDBCollectionGetPropertiesResource(ExtendedResourceProperties, MongoDB :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str + :ivar id: Name of the Cosmos DB MongoDB collection. Required. + :vartype id: str + :ivar shard_key: A key-value pair of shard keys to be applied for the request. + :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 = { - 'id': {'required': True}, - 'rid': {'readonly': True}, - 'ts': {'readonly': True}, - 'etag': {'readonly': True}, + "rid": {"readonly": True}, + "ts": {"readonly": True}, + "etag": {"readonly": True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'shard_key': {'key': 'shardKey', 'type': '{str}'}, - 'indexes': {'key': 'indexes', 'type': '[MongoIndex]'}, - 'analytical_storage_ttl': {'key': 'analyticalStorageTtl', 'type': 'int'}, - 'rid': {'key': '_rid', 'type': 'str'}, - 'ts': {'key': '_ts', 'type': 'float'}, - 'etag': {'key': '_etag', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "shard_key": {"key": "shardKey", "type": "{str}"}, + "indexes": {"key": "indexes", "type": "[MongoIndex]"}, + "analytical_storage_ttl": {"key": "analyticalStorageTtl", "type": "int"}, } def __init__( self, *, - id: str, + id: str, # pylint: disable=redefined-builtin shard_key: Optional[Dict[str, str]] = None, indexes: Optional[List["_models.MongoIndex"]] = None, analytical_storage_ttl: Optional[int] = None, **kwargs ): """ - :keyword id: Required. Name of the Cosmos DB MongoDB collection. + :keyword id: Name of the Cosmos DB MongoDB collection. Required. :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] @@ -7974,14 +7634,16 @@ def __init__( :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) + super().__init__( + id=id, shard_key=shard_key, indexes=indexes, analytical_storage_ttl=analytical_storage_ttl, **kwargs + ) + self.rid = None + self.ts = None + self.etag = None self.id = id self.shard_key = shard_key self.indexes = indexes self.analytical_storage_ttl = analytical_storage_ttl - self.rid = None - self.ts = None - self.etag = None class MongoDBCollectionGetResults(ARMResourceProperties): @@ -7997,12 +7659,12 @@ class MongoDBCollectionGetResults(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -8013,20 +7675,20 @@ class MongoDBCollectionGetResults(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'MongoDBCollectionGetPropertiesResource'}, - 'options': {'key': 'properties.options', 'type': 'MongoDBCollectionGetPropertiesOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "MongoDBCollectionGetPropertiesResource"}, + "options": {"key": "properties.options", "type": "MongoDBCollectionGetPropertiesOptions"}, } def __init__( @@ -8042,12 +7704,12 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -8056,12 +7718,12 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.MongoDBCollectionGetPropertiesOptions """ - super(MongoDBCollectionGetResults, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options -class MongoDBCollectionListResult(msrest.serialization.Model): +class MongoDBCollectionListResult(_serialization.Model): """The List operation response, that contains the MongoDB collections and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -8071,20 +7733,16 @@ class MongoDBCollectionListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MongoDBCollectionGetResults]'}, + "value": {"key": "value", "type": "[MongoDBCollectionGetResults]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MongoDBCollectionListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -8103,16 +7761,16 @@ class MongoDBDatabaseCreateUpdateParameters(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :ivar resource: Required. The standard JSON format of a MongoDB database. + :ivar resource: The standard JSON format of a MongoDB database. Required. :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. @@ -8120,21 +7778,21 @@ class MongoDBDatabaseCreateUpdateParameters(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'MongoDBDatabaseResource'}, - 'options': {'key': 'properties.options', 'type': 'CreateUpdateOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "MongoDBDatabaseResource"}, + "options": {"key": "properties.options", "type": "CreateUpdateOptions"}, } def __init__( @@ -8150,22 +7808,22 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :keyword resource: Required. The standard JSON format of a MongoDB database. + :keyword resource: The standard JSON format of a MongoDB database. Required. :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, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options @@ -8181,8 +7839,8 @@ class MongoDBDatabaseGetPropertiesOptions(OptionsResource): """ _attribute_map = { - 'throughput': {'key': 'throughput', 'type': 'int'}, - 'autoscale_settings': {'key': 'autoscaleSettings', 'type': 'AutoscaleSettings'}, + "throughput": {"key": "throughput", "type": "int"}, + "autoscale_settings": {"key": "autoscaleSettings", "type": "AutoscaleSettings"}, } def __init__( @@ -8199,49 +7857,42 @@ def __init__( :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) + super().__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) -class MongoDBDatabaseResource(msrest.serialization.Model): +class MongoDBDatabaseResource(_serialization.Model): """Cosmos DB MongoDB database resource object. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Name of the Cosmos DB MongoDB database. + :ivar id: Name of the Cosmos DB MongoDB database. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Name of the Cosmos DB MongoDB database. + :keyword id: Name of the Cosmos DB MongoDB database. Required. :paramtype id: str """ - super(MongoDBDatabaseResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class MongoDBDatabaseGetPropertiesResource(ExtendedResourceProperties, MongoDBDatabaseResource): +class MongoDBDatabaseGetPropertiesResource(MongoDBDatabaseResource, ExtendedResourceProperties): """MongoDBDatabaseGetPropertiesResource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :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. @@ -8249,37 +7900,34 @@ class MongoDBDatabaseGetPropertiesResource(ExtendedResourceProperties, MongoDBDa :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str + :ivar id: Name of the Cosmos DB MongoDB database. Required. + :vartype id: str """ _validation = { - 'id': {'required': True}, - 'rid': {'readonly': True}, - 'ts': {'readonly': True}, - 'etag': {'readonly': True}, + "rid": {"readonly": True}, + "ts": {"readonly": True}, + "etag": {"readonly": True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'rid': {'key': '_rid', 'type': 'str'}, - 'ts': {'key': '_ts', 'type': 'float'}, - 'etag': {'key': '_etag', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Name of the Cosmos DB MongoDB database. + :keyword id: Name of the Cosmos DB MongoDB database. Required. :paramtype id: str """ - super(MongoDBDatabaseGetPropertiesResource, self).__init__(id=id, **kwargs) - self.id = id + super().__init__(id=id, **kwargs) self.rid = None self.ts = None self.etag = None + self.id = id class MongoDBDatabaseGetResults(ARMResourceProperties): @@ -8295,12 +7943,12 @@ class MongoDBDatabaseGetResults(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -8311,20 +7959,20 @@ class MongoDBDatabaseGetResults(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'MongoDBDatabaseGetPropertiesResource'}, - 'options': {'key': 'properties.options', 'type': 'MongoDBDatabaseGetPropertiesOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "MongoDBDatabaseGetPropertiesResource"}, + "options": {"key": "properties.options", "type": "MongoDBDatabaseGetPropertiesOptions"}, } def __init__( @@ -8340,12 +7988,12 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -8354,12 +8002,12 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.MongoDBDatabaseGetPropertiesOptions """ - super(MongoDBDatabaseGetResults, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options -class MongoDBDatabaseListResult(msrest.serialization.Model): +class MongoDBDatabaseListResult(_serialization.Model): """The List operation response, that contains the MongoDB databases and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -8369,24 +8017,20 @@ class MongoDBDatabaseListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MongoDBDatabaseGetResults]'}, + "value": {"key": "value", "type": "[MongoDBDatabaseGetResults]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MongoDBDatabaseListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class MongoIndex(msrest.serialization.Model): +class MongoIndex(_serialization.Model): """Cosmos DB MongoDB collection index key. :ivar key: Cosmos DB MongoDB collection index keys. @@ -8396,8 +8040,8 @@ class MongoIndex(msrest.serialization.Model): """ _attribute_map = { - 'key': {'key': 'key', 'type': 'MongoIndexKeys'}, - 'options': {'key': 'options', 'type': 'MongoIndexOptions'}, + "key": {"key": "key", "type": "MongoIndexKeys"}, + "options": {"key": "options", "type": "MongoIndexOptions"}, } def __init__( @@ -8413,12 +8057,12 @@ def __init__( :keyword options: Cosmos DB MongoDB collection index key options. :paramtype options: ~azure.mgmt.cosmosdb.models.MongoIndexOptions """ - super(MongoIndex, self).__init__(**kwargs) + super().__init__(**kwargs) self.key = key self.options = options -class MongoIndexKeys(msrest.serialization.Model): +class MongoIndexKeys(_serialization.Model): """Cosmos DB MongoDB collection resource object. :ivar keys: List of keys for each MongoDB collection in the Azure Cosmos DB service. @@ -8426,24 +8070,19 @@ class MongoIndexKeys(msrest.serialization.Model): """ _attribute_map = { - 'keys': {'key': 'keys', 'type': '[str]'}, + "keys": {"key": "keys", "type": "[str]"}, } - def __init__( - self, - *, - keys: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, 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) + super().__init__(**kwargs) self.keys = keys -class MongoIndexOptions(msrest.serialization.Model): +class MongoIndexOptions(_serialization.Model): """Cosmos DB MongoDB collection index options. :ivar expire_after_seconds: Expire after seconds. @@ -8453,36 +8092,30 @@ class MongoIndexOptions(msrest.serialization.Model): """ _attribute_map = { - 'expire_after_seconds': {'key': 'expireAfterSeconds', 'type': 'int'}, - 'unique': {'key': 'unique', 'type': 'bool'}, + "expire_after_seconds": {"key": "expireAfterSeconds", "type": "int"}, + "unique": {"key": "unique", "type": "bool"}, } - def __init__( - self, - *, - expire_after_seconds: Optional[int] = None, - unique: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, expire_after_seconds: Optional[int] = None, 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) + super().__init__(**kwargs) self.expire_after_seconds = expire_after_seconds self.unique = unique -class MongoRoleDefinitionCreateUpdateParameters(msrest.serialization.Model): +class MongoRoleDefinitionCreateUpdateParameters(_serialization.Model): """Parameters to create and update an Azure Cosmos DB Mongo Role Definition. :ivar role_name: A user-friendly name for the Role Definition. Must be unique for the database account. :vartype role_name: str :ivar type: Indicates whether the Role Definition was built-in or user created. Known values - are: "BuiltInRole", "CustomRole". + are: "BuiltInRole" and "CustomRole". :vartype type: str or ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionType :ivar database_name: The database name for which access is being granted for this Role Definition. @@ -8496,11 +8129,11 @@ class MongoRoleDefinitionCreateUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'role_name': {'key': 'properties.roleName', 'type': 'str'}, - 'type': {'key': 'properties.type', 'type': 'str'}, - 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, - 'privileges': {'key': 'properties.privileges', 'type': '[Privilege]'}, - 'roles': {'key': 'properties.roles', 'type': '[Role]'}, + "role_name": {"key": "properties.roleName", "type": "str"}, + "type": {"key": "properties.type", "type": "str"}, + "database_name": {"key": "properties.databaseName", "type": "str"}, + "privileges": {"key": "properties.privileges", "type": "[Privilege]"}, + "roles": {"key": "properties.roles", "type": "[Role]"}, } def __init__( @@ -8518,7 +8151,7 @@ def __init__( database account. :paramtype role_name: str :keyword type: Indicates whether the Role Definition was built-in or user created. Known values - are: "BuiltInRole", "CustomRole". + are: "BuiltInRole" and "CustomRole". :paramtype type: str or ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionType :keyword database_name: The database name for which access is being granted for this Role Definition. @@ -8530,7 +8163,7 @@ def __init__( :keyword roles: The set of roles inherited by this Role Definition. :paramtype roles: list[~azure.mgmt.cosmosdb.models.Role] """ - super(MongoRoleDefinitionCreateUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.role_name = role_name self.type = type self.database_name = database_name @@ -8553,7 +8186,7 @@ class MongoRoleDefinitionGetResults(ARMProxyResource): account. :vartype role_name: str :ivar type_properties_type: Indicates whether the Role Definition was built-in or user created. - Known values are: "BuiltInRole", "CustomRole". + Known values are: "BuiltInRole" and "CustomRole". :vartype type_properties_type: str or ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionType :ivar database_name: The database name for which access is being granted for this Role Definition. @@ -8567,20 +8200,20 @@ class MongoRoleDefinitionGetResults(ARMProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'role_name': {'key': 'properties.roleName', 'type': 'str'}, - 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, - 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, - 'privileges': {'key': 'properties.privileges', 'type': '[Privilege]'}, - 'roles': {'key': 'properties.roles', 'type': '[Role]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "role_name": {"key": "properties.roleName", "type": "str"}, + "type_properties_type": {"key": "properties.type", "type": "str"}, + "database_name": {"key": "properties.databaseName", "type": "str"}, + "privileges": {"key": "properties.privileges", "type": "[Privilege]"}, + "roles": {"key": "properties.roles", "type": "[Role]"}, } def __init__( @@ -8598,7 +8231,7 @@ def __init__( database account. :paramtype role_name: str :keyword type_properties_type: Indicates whether the Role Definition was built-in or user - created. Known values are: "BuiltInRole", "CustomRole". + created. Known values are: "BuiltInRole" and "CustomRole". :paramtype type_properties_type: str or ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionType :keyword database_name: The database name for which access is being granted for this Role Definition. @@ -8610,7 +8243,7 @@ def __init__( :keyword roles: The set of roles inherited by this Role Definition. :paramtype roles: list[~azure.mgmt.cosmosdb.models.Role] """ - super(MongoRoleDefinitionGetResults, self).__init__(**kwargs) + super().__init__(**kwargs) self.role_name = role_name self.type_properties_type = type_properties_type self.database_name = database_name @@ -8618,7 +8251,7 @@ def __init__( self.roles = roles -class MongoRoleDefinitionListResult(msrest.serialization.Model): +class MongoRoleDefinitionListResult(_serialization.Model): """The relevant Mongo Role Definitions. Variables are only populated by the server, and will be ignored when sending a request. @@ -8628,24 +8261,20 @@ class MongoRoleDefinitionListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MongoRoleDefinitionGetResults]'}, + "value": {"key": "value", "type": "[MongoRoleDefinitionGetResults]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MongoRoleDefinitionListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class MongoUserDefinitionCreateUpdateParameters(msrest.serialization.Model): +class MongoUserDefinitionCreateUpdateParameters(_serialization.Model): """Parameters to create and update an Azure Cosmos DB Mongo User Definition. :ivar user_name: The user name for User Definition. @@ -8665,12 +8294,12 @@ class MongoUserDefinitionCreateUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'password': {'key': 'properties.password', 'type': 'str'}, - 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, - 'custom_data': {'key': 'properties.customData', 'type': 'str'}, - 'roles': {'key': 'properties.roles', 'type': '[Role]'}, - 'mechanisms': {'key': 'properties.mechanisms', 'type': 'str'}, + "user_name": {"key": "properties.userName", "type": "str"}, + "password": {"key": "properties.password", "type": "str"}, + "database_name": {"key": "properties.databaseName", "type": "str"}, + "custom_data": {"key": "properties.customData", "type": "str"}, + "roles": {"key": "properties.roles", "type": "[Role]"}, + "mechanisms": {"key": "properties.mechanisms", "type": "str"}, } def __init__( @@ -8700,7 +8329,7 @@ def __init__( SCRAM-SHA-256. :paramtype mechanisms: str """ - super(MongoUserDefinitionCreateUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.user_name = user_name self.password = password self.database_name = database_name @@ -8737,21 +8366,21 @@ class MongoUserDefinitionGetResults(ARMProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_name': {'key': 'properties.userName', 'type': 'str'}, - 'password': {'key': 'properties.password', 'type': 'str'}, - 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, - 'custom_data': {'key': 'properties.customData', 'type': 'str'}, - 'roles': {'key': 'properties.roles', 'type': '[Role]'}, - 'mechanisms': {'key': 'properties.mechanisms', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_name": {"key": "properties.userName", "type": "str"}, + "password": {"key": "properties.password", "type": "str"}, + "database_name": {"key": "properties.databaseName", "type": "str"}, + "custom_data": {"key": "properties.customData", "type": "str"}, + "roles": {"key": "properties.roles", "type": "[Role]"}, + "mechanisms": {"key": "properties.mechanisms", "type": "str"}, } def __init__( @@ -8781,7 +8410,7 @@ def __init__( SCRAM-SHA-256. :paramtype mechanisms: str """ - super(MongoUserDefinitionGetResults, self).__init__(**kwargs) + super().__init__(**kwargs) self.user_name = user_name self.password = password self.database_name = database_name @@ -8790,7 +8419,7 @@ def __init__( self.mechanisms = mechanisms -class MongoUserDefinitionListResult(msrest.serialization.Model): +class MongoUserDefinitionListResult(_serialization.Model): """The relevant User Definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -8800,20 +8429,16 @@ class MongoUserDefinitionListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[MongoUserDefinitionGetResults]'}, + "value": {"key": "value", "type": "[MongoUserDefinitionGetResults]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(MongoUserDefinitionListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -8836,33 +8461,29 @@ class NotebookWorkspace(ARMProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'notebook_server_endpoint': {'readonly': True}, - 'status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "notebook_server_endpoint": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'notebook_server_endpoint': {'key': 'properties.notebookServerEndpoint', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "notebook_server_endpoint": {"key": "properties.notebookServerEndpoint", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(NotebookWorkspace, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.notebook_server_endpoint = None self.status = None -class NotebookWorkspaceConnectionInfoResult(msrest.serialization.Model): +class NotebookWorkspaceConnectionInfoResult(_serialization.Model): """The connection info for the given notebook workspace. Variables are only populated by the server, and will be ignored when sending a request. @@ -8875,22 +8496,18 @@ class NotebookWorkspaceConnectionInfoResult(msrest.serialization.Model): """ _validation = { - 'auth_token': {'readonly': True}, - 'notebook_server_endpoint': {'readonly': True}, + "auth_token": {"readonly": True}, + "notebook_server_endpoint": {"readonly": True}, } _attribute_map = { - 'auth_token': {'key': 'authToken', 'type': 'str'}, - 'notebook_server_endpoint': {'key': 'notebookServerEndpoint', 'type': 'str'}, + "auth_token": {"key": "authToken", "type": "str"}, + "notebook_server_endpoint": {"key": "notebookServerEndpoint", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(NotebookWorkspaceConnectionInfoResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.auth_token = None self.notebook_server_endpoint = None @@ -8909,27 +8526,23 @@ class NotebookWorkspaceCreateUpdateParameters(ARMProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(NotebookWorkspaceCreateUpdateParameters, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) -class NotebookWorkspaceListResult(msrest.serialization.Model): +class NotebookWorkspaceListResult(_serialization.Model): """A list of notebook workspace resources. :ivar value: Array of notebook workspace resources. @@ -8937,24 +8550,19 @@ class NotebookWorkspaceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[NotebookWorkspace]'}, + "value": {"key": "value", "type": "[NotebookWorkspace]"}, } - def __init__( - self, - *, - value: Optional[List["_models.NotebookWorkspace"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.NotebookWorkspace"]] = None, **kwargs): """ :keyword value: Array of notebook workspace resources. :paramtype value: list[~azure.mgmt.cosmosdb.models.NotebookWorkspace] """ - super(NotebookWorkspaceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """REST API operation. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -8964,29 +8572,23 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["_models.OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display: Optional["_models.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) + super().__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. :ivar provider: Service provider: Microsoft.ResourceProvider. @@ -9000,10 +8602,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'Provider', 'type': 'str'}, - 'resource': {'key': 'Resource', 'type': 'str'}, - 'operation': {'key': 'Operation', 'type': 'str'}, - 'description': {'key': 'Description', 'type': 'str'}, + "provider": {"key": "Provider", "type": "str"}, + "resource": {"key": "Resource", "type": "str"}, + "operation": {"key": "Operation", "type": "str"}, + "description": {"key": "Description", "type": "str"}, } def __init__( @@ -9025,14 +8627,14 @@ def __init__( :keyword description: Description of operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Resource Provider operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of operations supported by the Resource Provider. @@ -9042,24 +8644,18 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, 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) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -9076,7 +8672,7 @@ class PartitionMetric(Metric): :ivar time_grain: The time grain to be used to summarize the metric values. :vartype time_grain: str :ivar unit: The unit of the metric. Known values are: "Count", "Bytes", "Seconds", "Percent", - "CountPerSecond", "BytesPerSecond", "Milliseconds". + "CountPerSecond", "BytesPerSecond", and "Milliseconds". :vartype unit: str or ~azure.mgmt.cosmosdb.models.UnitType :ivar name: The name information for the metric. :vartype name: ~azure.mgmt.cosmosdb.models.MetricName @@ -9090,39 +8686,35 @@ class PartitionMetric(Metric): """ _validation = { - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'time_grain': {'readonly': True}, - 'unit': {'readonly': True}, - 'name': {'readonly': True}, - 'metric_values': {'readonly': True}, - 'partition_id': {'readonly': True}, - 'partition_key_range_id': {'readonly': True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + "time_grain": {"readonly": True}, + "unit": {"readonly": True}, + "name": {"readonly": True}, + "metric_values": {"readonly": True}, + "partition_id": {"readonly": True}, + "partition_key_range_id": {"readonly": True}, } _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'time_grain': {'key': 'timeGrain', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'MetricName'}, - 'metric_values': {'key': 'metricValues', 'type': '[MetricValue]'}, - 'partition_id': {'key': 'partitionId', 'type': 'str'}, - 'partition_key_range_id': {'key': 'partitionKeyRangeId', 'type': 'str'}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "time_grain": {"key": "timeGrain", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "name": {"key": "name", "type": "MetricName"}, + "metric_values": {"key": "metricValues", "type": "[MetricValue]"}, + "partition_id": {"key": "partitionId", "type": "str"}, + "partition_key_range_id": {"key": "partitionKeyRangeId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PartitionMetric, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.partition_id = None self.partition_key_range_id = None -class PartitionMetricListResult(msrest.serialization.Model): +class PartitionMetricListResult(_serialization.Model): """The response to a list partition metrics request. Variables are only populated by the server, and will be ignored when sending a request. @@ -9132,64 +8724,56 @@ class PartitionMetricListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[PartitionMetric]'}, + "value": {"key": "value", "type": "[PartitionMetric]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PartitionMetricListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class Usage(msrest.serialization.Model): +class Usage(_serialization.Model): """The usage data for a usage request. Variables are only populated by the server, and will be ignored when sending a request. :ivar unit: The unit of the metric. Known values are: "Count", "Bytes", "Seconds", "Percent", - "CountPerSecond", "BytesPerSecond", "Milliseconds". + "CountPerSecond", "BytesPerSecond", and "Milliseconds". :vartype unit: str or ~azure.mgmt.cosmosdb.models.UnitType :ivar name: The name information for the metric. :vartype name: ~azure.mgmt.cosmosdb.models.MetricName :ivar quota_period: The quota period used to summarize the usage values. :vartype quota_period: str :ivar limit: Maximum value for this metric. - :vartype limit: long + :vartype limit: int :ivar current_value: Current value for this metric. - :vartype current_value: long + :vartype current_value: int """ _validation = { - 'unit': {'readonly': True}, - 'name': {'readonly': True}, - 'quota_period': {'readonly': True}, - 'limit': {'readonly': True}, - 'current_value': {'readonly': True}, + "unit": {"readonly": True}, + "name": {"readonly": True}, + "quota_period": {"readonly": True}, + "limit": {"readonly": True}, + "current_value": {"readonly": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'MetricName'}, - 'quota_period': {'key': 'quotaPeriod', 'type': 'str'}, - 'limit': {'key': 'limit', 'type': 'long'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, + "unit": {"key": "unit", "type": "str"}, + "name": {"key": "name", "type": "MetricName"}, + "quota_period": {"key": "quotaPeriod", "type": "str"}, + "limit": {"key": "limit", "type": "int"}, + "current_value": {"key": "currentValue", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Usage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.unit = None self.name = None self.quota_period = None @@ -9203,16 +8787,16 @@ class PartitionUsage(Usage): Variables are only populated by the server, and will be ignored when sending a request. :ivar unit: The unit of the metric. Known values are: "Count", "Bytes", "Seconds", "Percent", - "CountPerSecond", "BytesPerSecond", "Milliseconds". + "CountPerSecond", "BytesPerSecond", and "Milliseconds". :vartype unit: str or ~azure.mgmt.cosmosdb.models.UnitType :ivar name: The name information for the metric. :vartype name: ~azure.mgmt.cosmosdb.models.MetricName :ivar quota_period: The quota period used to summarize the usage values. :vartype quota_period: str :ivar limit: Maximum value for this metric. - :vartype limit: long + :vartype limit: int :ivar current_value: Current value for this metric. - :vartype current_value: long + :vartype current_value: int :ivar partition_id: The partition id (GUID identifier) of the usages. :vartype partition_id: str :ivar partition_key_range_id: The partition key range id (integer identifier) of the usages. @@ -9220,37 +8804,33 @@ class PartitionUsage(Usage): """ _validation = { - 'unit': {'readonly': True}, - 'name': {'readonly': True}, - 'quota_period': {'readonly': True}, - 'limit': {'readonly': True}, - 'current_value': {'readonly': True}, - 'partition_id': {'readonly': True}, - 'partition_key_range_id': {'readonly': True}, + "unit": {"readonly": True}, + "name": {"readonly": True}, + "quota_period": {"readonly": True}, + "limit": {"readonly": True}, + "current_value": {"readonly": True}, + "partition_id": {"readonly": True}, + "partition_key_range_id": {"readonly": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'MetricName'}, - 'quota_period': {'key': 'quotaPeriod', 'type': 'str'}, - 'limit': {'key': 'limit', 'type': 'long'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'partition_id': {'key': 'partitionId', 'type': 'str'}, - 'partition_key_range_id': {'key': 'partitionKeyRangeId', 'type': 'str'}, + "unit": {"key": "unit", "type": "str"}, + "name": {"key": "name", "type": "MetricName"}, + "quota_period": {"key": "quotaPeriod", "type": "str"}, + "limit": {"key": "limit", "type": "int"}, + "current_value": {"key": "currentValue", "type": "int"}, + "partition_id": {"key": "partitionId", "type": "str"}, + "partition_key_range_id": {"key": "partitionKeyRangeId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PartitionUsage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.partition_id = None self.partition_key_range_id = None -class PartitionUsagesResult(msrest.serialization.Model): +class PartitionUsagesResult(_serialization.Model): """The response to a list partition level usage request. Variables are only populated by the server, and will be ignored when sending a request. @@ -9261,24 +8841,20 @@ class PartitionUsagesResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[PartitionUsage]'}, + "value": {"key": "value", "type": "[PartitionUsage]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PartitionUsagesResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class PercentileMetric(msrest.serialization.Model): +class PercentileMetric(_serialization.Model): """Percentile Metric data. Variables are only populated by the server, and will be ignored when sending a request. @@ -9290,7 +8866,7 @@ class PercentileMetric(msrest.serialization.Model): :ivar time_grain: The time grain to be used to summarize the metric values. :vartype time_grain: str :ivar unit: The unit of the metric. Known values are: "Count", "Bytes", "Seconds", "Percent", - "CountPerSecond", "BytesPerSecond", "Milliseconds". + "CountPerSecond", "BytesPerSecond", and "Milliseconds". :vartype unit: str or ~azure.mgmt.cosmosdb.models.UnitType :ivar name: The name information for the metric. :vartype name: ~azure.mgmt.cosmosdb.models.MetricName @@ -9299,30 +8875,26 @@ class PercentileMetric(msrest.serialization.Model): """ _validation = { - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'time_grain': {'readonly': True}, - 'unit': {'readonly': True}, - 'name': {'readonly': True}, - 'metric_values': {'readonly': True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + "time_grain": {"readonly": True}, + "unit": {"readonly": True}, + "name": {"readonly": True}, + "metric_values": {"readonly": True}, } _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'time_grain': {'key': 'timeGrain', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'MetricName'}, - 'metric_values': {'key': 'metricValues', 'type': '[PercentileMetricValue]'}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "time_grain": {"key": "timeGrain", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "name": {"key": "name", "type": "MetricName"}, + "metric_values": {"key": "metricValues", "type": "[PercentileMetricValue]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PercentileMetric, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.start_time = None self.end_time = None self.time_grain = None @@ -9331,7 +8903,7 @@ def __init__( self.metric_values = None -class PercentileMetricListResult(msrest.serialization.Model): +class PercentileMetricListResult(_serialization.Model): """The response to a list percentile metrics request. Variables are only populated by the server, and will be ignored when sending a request. @@ -9341,24 +8913,20 @@ class PercentileMetricListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[PercentileMetric]'}, + "value": {"key": "value", "type": "[PercentileMetric]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PercentileMetricListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class PercentileMetricValue(MetricValue): +class PercentileMetricValue(MetricValue): # pylint: disable=too-many-instance-attributes """Represents percentile metrics values. Variables are only populated by the server, and will be ignored when sending a request. @@ -9392,44 +8960,40 @@ class PercentileMetricValue(MetricValue): """ _validation = { - 'count': {'readonly': True}, - 'average': {'readonly': True}, - 'maximum': {'readonly': True}, - 'minimum': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'total': {'readonly': True}, - 'p10': {'readonly': True}, - 'p25': {'readonly': True}, - 'p50': {'readonly': True}, - 'p75': {'readonly': True}, - 'p90': {'readonly': True}, - 'p95': {'readonly': True}, - 'p99': {'readonly': True}, - } - - _attribute_map = { - 'count': {'key': '_count', 'type': 'int'}, - 'average': {'key': 'average', 'type': 'float'}, - 'maximum': {'key': 'maximum', 'type': 'float'}, - 'minimum': {'key': 'minimum', 'type': 'float'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'total': {'key': 'total', 'type': 'float'}, - 'p10': {'key': 'P10', 'type': 'float'}, - 'p25': {'key': 'P25', 'type': 'float'}, - 'p50': {'key': 'P50', 'type': 'float'}, - 'p75': {'key': 'P75', 'type': 'float'}, - 'p90': {'key': 'P90', 'type': 'float'}, - 'p95': {'key': 'P95', 'type': 'float'}, - 'p99': {'key': 'P99', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(PercentileMetricValue, self).__init__(**kwargs) + "count": {"readonly": True}, + "average": {"readonly": True}, + "maximum": {"readonly": True}, + "minimum": {"readonly": True}, + "timestamp": {"readonly": True}, + "total": {"readonly": True}, + "p10": {"readonly": True}, + "p25": {"readonly": True}, + "p50": {"readonly": True}, + "p75": {"readonly": True}, + "p90": {"readonly": True}, + "p95": {"readonly": True}, + "p99": {"readonly": True}, + } + + _attribute_map = { + "count": {"key": "_count", "type": "int"}, + "average": {"key": "average", "type": "float"}, + "maximum": {"key": "maximum", "type": "float"}, + "minimum": {"key": "minimum", "type": "float"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "total": {"key": "total", "type": "float"}, + "p10": {"key": "P10", "type": "float"}, + "p25": {"key": "P25", "type": "float"}, + "p50": {"key": "P50", "type": "float"}, + "p75": {"key": "P75", "type": "float"}, + "p90": {"key": "P90", "type": "float"}, + "p95": {"key": "P95", "type": "float"}, + "p99": {"key": "P99", "type": "float"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.p10 = None self.p25 = None self.p50 = None @@ -9444,8 +9008,8 @@ class PeriodicModeBackupPolicy(BackupPolicy): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Describes the mode of backups.Constant filled by server. Known values - are: "Periodic", "Continuous". + :ivar type: Describes the mode of backups. Required. Known values are: "Periodic" and + "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. @@ -9455,13 +9019,13 @@ class PeriodicModeBackupPolicy(BackupPolicy): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'migration_state': {'key': 'migrationState', 'type': 'BackupPolicyMigrationState'}, - 'periodic_mode_properties': {'key': 'periodicModeProperties', 'type': 'PeriodicModeProperties'}, + "type": {"key": "type", "type": "str"}, + "migration_state": {"key": "migrationState", "type": "BackupPolicyMigrationState"}, + "periodic_mode_properties": {"key": "periodicModeProperties", "type": "PeriodicModeProperties"}, } def __init__( @@ -9478,12 +9042,12 @@ def __init__( :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 + super().__init__(migration_state=migration_state, **kwargs) + self.type = "Periodic" # type: str self.periodic_mode_properties = periodic_mode_properties -class PeriodicModeProperties(msrest.serialization.Model): +class PeriodicModeProperties(_serialization.Model): """Configuration values for periodic mode backup. :ivar backup_interval_in_minutes: An integer representing the interval in minutes between two @@ -9493,19 +9057,19 @@ class PeriodicModeProperties(msrest.serialization.Model): backup is retained. :vartype backup_retention_interval_in_hours: int :ivar backup_storage_redundancy: Enum to indicate type of backup residency. Known values are: - "Geo", "Local", "Zone". + "Geo", "Local", and "Zone". :vartype backup_storage_redundancy: str or ~azure.mgmt.cosmosdb.models.BackupStorageRedundancy """ _validation = { - 'backup_interval_in_minutes': {'minimum': 0}, - 'backup_retention_interval_in_hours': {'minimum': 0}, + "backup_interval_in_minutes": {"minimum": 0}, + "backup_retention_interval_in_hours": {"minimum": 0}, } _attribute_map = { - 'backup_interval_in_minutes': {'key': 'backupIntervalInMinutes', 'type': 'int'}, - 'backup_retention_interval_in_hours': {'key': 'backupRetentionIntervalInHours', 'type': 'int'}, - 'backup_storage_redundancy': {'key': 'backupStorageRedundancy', 'type': 'str'}, + "backup_interval_in_minutes": {"key": "backupIntervalInMinutes", "type": "int"}, + "backup_retention_interval_in_hours": {"key": "backupRetentionIntervalInHours", "type": "int"}, + "backup_storage_redundancy": {"key": "backupStorageRedundancy", "type": "str"}, } def __init__( @@ -9524,17 +9088,17 @@ def __init__( each backup is retained. :paramtype backup_retention_interval_in_hours: int :keyword backup_storage_redundancy: Enum to indicate type of backup residency. Known values - are: "Geo", "Local", "Zone". + are: "Geo", "Local", and "Zone". :paramtype backup_storage_redundancy: str or ~azure.mgmt.cosmosdb.models.BackupStorageRedundancy """ - super(PeriodicModeProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.backup_interval_in_minutes = backup_interval_in_minutes self.backup_retention_interval_in_hours = backup_retention_interval_in_hours self.backup_storage_redundancy = backup_storage_redundancy -class Permission(msrest.serialization.Model): +class Permission(_serialization.Model): """The set of data plane operations permitted through this Role Definition. :ivar data_actions: An array of data actions that are allowed. @@ -9544,16 +9108,12 @@ class Permission(msrest.serialization.Model): """ _attribute_map = { - 'data_actions': {'key': 'dataActions', 'type': '[str]'}, - 'not_data_actions': {'key': 'notDataActions', 'type': '[str]'}, + "data_actions": {"key": "dataActions", "type": "[str]"}, + "not_data_actions": {"key": "notDataActions", "type": "[str]"}, } - def __init__( - self, - *, - data_actions: Optional[List[str]] = None, - not_data_actions: Optional[List[str]] = None, - **kwargs + def __init__( + self, *, data_actions: Optional[List[str]] = None, not_data_actions: Optional[List[str]] = None, **kwargs ): """ :keyword data_actions: An array of data actions that are allowed. @@ -9561,43 +9121,38 @@ def __init__( :keyword not_data_actions: An array of data actions that are denied. :paramtype not_data_actions: list[str] """ - super(Permission, self).__init__(**kwargs) + super().__init__(**kwargs) self.data_actions = data_actions self.not_data_actions = not_data_actions -class PhysicalPartitionId(msrest.serialization.Model): +class PhysicalPartitionId(_serialization.Model): """PhysicalPartitionId object. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Id of a physical partition. + :ivar id: Id of a physical partition. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Id of a physical partition. + :keyword id: Id of a physical partition. Required. :paramtype id: str """ - super(PhysicalPartitionId, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class PhysicalPartitionStorageInfo(msrest.serialization.Model): +class PhysicalPartitionStorageInfo(_serialization.Model): """The storage of a physical partition. Variables are only populated by the server, and will be ignored when sending a request. @@ -9609,27 +9164,23 @@ class PhysicalPartitionStorageInfo(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'storage_in_kb': {'readonly': True}, + "id": {"readonly": True}, + "storage_in_kb": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'storage_in_kb': {'key': 'storageInKB', 'type': 'float'}, + "id": {"key": "id", "type": "str"}, + "storage_in_kb": {"key": "storageInKB", "type": "float"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PhysicalPartitionStorageInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.storage_in_kb = None -class PhysicalPartitionStorageInfoCollection(msrest.serialization.Model): +class PhysicalPartitionStorageInfoCollection(_serialization.Model): """List of physical partitions and their properties returned by a merge operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -9641,24 +9192,23 @@ class PhysicalPartitionStorageInfoCollection(msrest.serialization.Model): """ _validation = { - 'physical_partition_storage_info_collection': {'readonly': True}, + "physical_partition_storage_info_collection": {"readonly": True}, } _attribute_map = { - 'physical_partition_storage_info_collection': {'key': 'physicalPartitionStorageInfoCollection', 'type': '[PhysicalPartitionStorageInfo]'}, + "physical_partition_storage_info_collection": { + "key": "physicalPartitionStorageInfoCollection", + "type": "[PhysicalPartitionStorageInfo]", + }, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PhysicalPartitionStorageInfoCollection, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.physical_partition_storage_info_collection = None -class PhysicalPartitionThroughputInfoProperties(msrest.serialization.Model): +class PhysicalPartitionThroughputInfoProperties(_serialization.Model): """The properties of an Azure Cosmos DB PhysicalPartitionThroughputInfoProperties object. :ivar physical_partition_throughput_info: Array of physical partition throughput info objects. @@ -9667,7 +9217,10 @@ class PhysicalPartitionThroughputInfoProperties(msrest.serialization.Model): """ _attribute_map = { - 'physical_partition_throughput_info': {'key': 'physicalPartitionThroughputInfo', 'type': '[PhysicalPartitionThroughputInfoResource]'}, + "physical_partition_throughput_info": { + "key": "physicalPartitionThroughputInfo", + "type": "[PhysicalPartitionThroughputInfoResource]", + }, } def __init__( @@ -9682,44 +9235,38 @@ def __init__( :paramtype physical_partition_throughput_info: list[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResource] """ - super(PhysicalPartitionThroughputInfoProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.physical_partition_throughput_info = physical_partition_throughput_info -class PhysicalPartitionThroughputInfoResource(msrest.serialization.Model): +class PhysicalPartitionThroughputInfoResource(_serialization.Model): """PhysicalPartitionThroughputInfo object. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Id of a physical partition. + :ivar id: Id of a physical partition. Required. :vartype id: str :ivar throughput: Throughput of a physical partition. :vartype throughput: float """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'throughput': {'key': 'throughput', 'type': 'float'}, + "id": {"key": "id", "type": "str"}, + "throughput": {"key": "throughput", "type": "float"}, } - def __init__( - self, - *, - id: str, - throughput: Optional[float] = None, - **kwargs - ): + def __init__(self, *, id: str, throughput: Optional[float] = None, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Id of a physical partition. + :keyword id: Id of a physical partition. Required. :paramtype id: str :keyword throughput: Throughput of a physical partition. :paramtype throughput: float """ - super(PhysicalPartitionThroughputInfoResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.throughput = throughput @@ -9737,12 +9284,12 @@ class PhysicalPartitionThroughputInfoResult(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -9752,19 +9299,19 @@ class PhysicalPartitionThroughputInfoResult(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'PhysicalPartitionThroughputInfoResultPropertiesResource'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "PhysicalPartitionThroughputInfoResultPropertiesResource"}, } def __init__( @@ -9779,12 +9326,12 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -9792,7 +9339,7 @@ def __init__( :paramtype resource: ~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResultPropertiesResource """ - super(PhysicalPartitionThroughputInfoResult, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource @@ -9805,7 +9352,10 @@ class PhysicalPartitionThroughputInfoResultPropertiesResource(PhysicalPartitionT """ _attribute_map = { - 'physical_partition_throughput_info': {'key': 'physicalPartitionThroughputInfo', 'type': '[PhysicalPartitionThroughputInfoResource]'}, + "physical_partition_throughput_info": { + "key": "physicalPartitionThroughputInfo", + "type": "[PhysicalPartitionThroughputInfoResource]", + }, } def __init__( @@ -9820,10 +9370,10 @@ def __init__( :paramtype physical_partition_throughput_info: list[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResource] """ - super(PhysicalPartitionThroughputInfoResultPropertiesResource, self).__init__(physical_partition_throughput_info=physical_partition_throughput_info, **kwargs) + super().__init__(physical_partition_throughput_info=physical_partition_throughput_info, **kwargs) -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -9839,24 +9389,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -9878,24 +9424,20 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) class PrivateEndpointConnection(ProxyResource): @@ -9924,19 +9466,22 @@ class PrivateEndpointConnection(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpointProperty'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionStateProperty'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpointProperty"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionStateProperty", + }, + "group_id": {"key": "properties.groupId", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -9960,14 +9505,14 @@ def __init__( :keyword provisioning_state: Provisioning state of the private endpoint. :paramtype provisioning_state: str """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.group_id = group_id self.provisioning_state = provisioning_state -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """A list of private endpoint connections. :ivar value: Array of private endpoint connections. @@ -9975,24 +9520,19 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateEndpointConnection"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs): """ :keyword value: Array of private endpoint connections. :paramtype value: list[~azure.mgmt.cosmosdb.models.PrivateEndpointConnection] """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateEndpointProperty(msrest.serialization.Model): +class PrivateEndpointProperty(_serialization.Model): """Private endpoint which the connection belongs to. :ivar id: Resource id of the private endpoint. @@ -10000,20 +9540,15 @@ class PrivateEndpointProperty(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Resource id of the private endpoint. :paramtype id: str """ - super(PrivateEndpointProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -10037,36 +9572,32 @@ class PrivateLinkResource(ARMProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, - 'required_zone_names': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, + "required_zone_names": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateLinkResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.group_id = None self.required_members = None self.required_zone_names = None -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """A list of private link resources. :ivar value: Array of private link resources. @@ -10074,24 +9605,19 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs): """ :keyword value: Array of private link resources. :paramtype value: list[~azure.mgmt.cosmosdb.models.PrivateLinkResource] """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateLinkServiceConnectionStateProperty(msrest.serialization.Model): +class PrivateLinkServiceConnectionStateProperty(_serialization.Model): """Connection State of the Private Endpoint Connection. Variables are only populated by the server, and will be ignored when sending a request. @@ -10106,35 +9632,29 @@ class PrivateLinkServiceConnectionStateProperty(msrest.serialization.Model): """ _validation = { - 'actions_required': {'readonly': True}, + "actions_required": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, } - def __init__( - self, - *, - status: Optional[str] = None, - description: Optional[str] = None, - **kwargs - ): + def __init__(self, *, status: Optional[str] = None, 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) + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = None -class Privilege(msrest.serialization.Model): +class Privilege(_serialization.Model): """The set of data plane operations permitted through this Role Definition. :ivar resource: An Azure Cosmos DB Mongo DB Resource. @@ -10144,16 +9664,12 @@ class Privilege(msrest.serialization.Model): """ _attribute_map = { - 'resource': {'key': 'resource', 'type': 'PrivilegeResource'}, - 'actions': {'key': 'actions', 'type': '[str]'}, + "resource": {"key": "resource", "type": "PrivilegeResource"}, + "actions": {"key": "actions", "type": "[str]"}, } def __init__( - self, - *, - resource: Optional["_models.PrivilegeResource"] = None, - actions: Optional[List[str]] = None, - **kwargs + self, *, resource: Optional["_models.PrivilegeResource"] = None, actions: Optional[List[str]] = None, **kwargs ): """ :keyword resource: An Azure Cosmos DB Mongo DB Resource. @@ -10161,12 +9677,12 @@ def __init__( :keyword actions: An array of actions that are allowed. :paramtype actions: list[str] """ - super(Privilege, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource = resource self.actions = actions -class PrivilegeResource(msrest.serialization.Model): +class PrivilegeResource(_serialization.Model): """An Azure Cosmos DB Mongo DB Resource. :ivar db: The database name the role is applied. @@ -10176,24 +9692,18 @@ class PrivilegeResource(msrest.serialization.Model): """ _attribute_map = { - 'db': {'key': 'db', 'type': 'str'}, - 'collection': {'key': 'collection', 'type': 'str'}, + "db": {"key": "db", "type": "str"}, + "collection": {"key": "collection", "type": "str"}, } - def __init__( - self, - *, - db: Optional[str] = None, - collection: Optional[str] = None, - **kwargs - ): + def __init__(self, *, db: Optional[str] = None, collection: Optional[str] = None, **kwargs): """ :keyword db: The database name the role is applied. :paramtype db: str :keyword collection: The collection name the role is applied. :paramtype collection: str """ - super(PrivilegeResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.db = db self.collection = collection @@ -10213,34 +9723,34 @@ class RedistributeThroughputParameters(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :ivar resource: Required. The standard JSON format of a resource throughput. + :ivar resource: The standard JSON format of a resource throughput. Required. :vartype resource: ~azure.mgmt.cosmosdb.models.RedistributeThroughputPropertiesResource """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'RedistributeThroughputPropertiesResource'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "RedistributeThroughputPropertiesResource"}, } def __init__( @@ -10255,50 +9765,56 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :keyword resource: Required. The standard JSON format of a resource throughput. + :keyword resource: The standard JSON format of a resource throughput. Required. :paramtype resource: ~azure.mgmt.cosmosdb.models.RedistributeThroughputPropertiesResource """ - super(RedistributeThroughputParameters, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource -class RedistributeThroughputPropertiesResource(msrest.serialization.Model): +class RedistributeThroughputPropertiesResource(_serialization.Model): """Resource to redistribute throughput for Azure Cosmos DB resource. All required parameters must be populated in order to send to Azure. - :ivar throughput_policy: Required. ThroughputPolicy to apply for throughput redistribution. - Known values are: "none", "equal", "custom". + :ivar throughput_policy: ThroughputPolicy to apply for throughput redistribution. Required. + Known values are: "none", "equal", and "custom". :vartype throughput_policy: str or ~azure.mgmt.cosmosdb.models.ThroughputPolicyType - :ivar target_physical_partition_throughput_info: Required. Array of - PhysicalPartitionThroughputInfoResource objects. + :ivar target_physical_partition_throughput_info: Array of + PhysicalPartitionThroughputInfoResource objects. Required. :vartype target_physical_partition_throughput_info: list[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResource] - :ivar source_physical_partition_throughput_info: Required. Array of - PhysicalPartitionThroughputInfoResource objects. + :ivar source_physical_partition_throughput_info: Array of + PhysicalPartitionThroughputInfoResource objects. Required. :vartype source_physical_partition_throughput_info: list[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResource] """ _validation = { - 'throughput_policy': {'required': True}, - 'target_physical_partition_throughput_info': {'required': True}, - 'source_physical_partition_throughput_info': {'required': True}, + "throughput_policy": {"required": True}, + "target_physical_partition_throughput_info": {"required": True}, + "source_physical_partition_throughput_info": {"required": True}, } _attribute_map = { - 'throughput_policy': {'key': 'throughputPolicy', 'type': 'str'}, - 'target_physical_partition_throughput_info': {'key': 'targetPhysicalPartitionThroughputInfo', 'type': '[PhysicalPartitionThroughputInfoResource]'}, - 'source_physical_partition_throughput_info': {'key': 'sourcePhysicalPartitionThroughputInfo', 'type': '[PhysicalPartitionThroughputInfoResource]'}, + "throughput_policy": {"key": "throughputPolicy", "type": "str"}, + "target_physical_partition_throughput_info": { + "key": "targetPhysicalPartitionThroughputInfo", + "type": "[PhysicalPartitionThroughputInfoResource]", + }, + "source_physical_partition_throughput_info": { + "key": "sourcePhysicalPartitionThroughputInfo", + "type": "[PhysicalPartitionThroughputInfoResource]", + }, } def __init__( @@ -10310,57 +9826,52 @@ def __init__( **kwargs ): """ - :keyword throughput_policy: Required. ThroughputPolicy to apply for throughput redistribution. - Known values are: "none", "equal", "custom". + :keyword throughput_policy: ThroughputPolicy to apply for throughput redistribution. Required. + Known values are: "none", "equal", and "custom". :paramtype throughput_policy: str or ~azure.mgmt.cosmosdb.models.ThroughputPolicyType - :keyword target_physical_partition_throughput_info: Required. Array of - PhysicalPartitionThroughputInfoResource objects. + :keyword target_physical_partition_throughput_info: Array of + PhysicalPartitionThroughputInfoResource objects. Required. :paramtype target_physical_partition_throughput_info: list[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResource] - :keyword source_physical_partition_throughput_info: Required. Array of - PhysicalPartitionThroughputInfoResource objects. + :keyword source_physical_partition_throughput_info: Array of + PhysicalPartitionThroughputInfoResource objects. Required. :paramtype source_physical_partition_throughput_info: list[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResource] """ - super(RedistributeThroughputPropertiesResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.throughput_policy = throughput_policy self.target_physical_partition_throughput_info = target_physical_partition_throughput_info self.source_physical_partition_throughput_info = source_physical_partition_throughput_info -class RegionForOnlineOffline(msrest.serialization.Model): +class RegionForOnlineOffline(_serialization.Model): """Cosmos DB region to online or offline. All required parameters must be populated in order to send to Azure. - :ivar region: Required. Cosmos DB region, with spaces between words and each word capitalized. + :ivar region: Cosmos DB region, with spaces between words and each word capitalized. Required. :vartype region: str """ _validation = { - 'region': {'required': True}, + "region": {"required": True}, } _attribute_map = { - 'region': {'key': 'region', 'type': 'str'}, + "region": {"key": "region", "type": "str"}, } - def __init__( - self, - *, - region: str, - **kwargs - ): + def __init__(self, *, region: str, **kwargs): """ - :keyword region: Required. Cosmos DB region, with spaces between words and each word - capitalized. + :keyword region: Cosmos DB region, with spaces between words and each word capitalized. + Required. :paramtype region: str """ - super(RegionForOnlineOffline, self).__init__(**kwargs) + super().__init__(**kwargs) self.region = region -class RestorableDatabaseAccountGetResult(msrest.serialization.Model): +class RestorableDatabaseAccountGetResult(_serialization.Model): """A Azure Cosmos DB restorable database account. Variables are only populated by the server, and will be ignored when sending a request. @@ -10384,7 +9895,7 @@ class RestorableDatabaseAccountGetResult(msrest.serialization.Model): (ISO-8601 format). :vartype deletion_time: ~datetime.datetime :ivar api_type: The API type of the restorable database account. Known values are: "MongoDB", - "Gremlin", "Cassandra", "Table", "Sql", "GremlinV2". + "Gremlin", "Cassandra", "Table", "Sql", and "GremlinV2". :vartype api_type: str or ~azure.mgmt.cosmosdb.models.ApiType :ivar restorable_locations: List of regions where the of the database account can be restored from. @@ -10392,24 +9903,24 @@ class RestorableDatabaseAccountGetResult(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'api_type': {'readonly': True}, - 'restorable_locations': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "api_type": {"readonly": True}, + "restorable_locations": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'account_name': {'key': 'properties.accountName', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'oldest_restorable_time': {'key': 'properties.oldestRestorableTime', 'type': 'iso-8601'}, - 'deletion_time': {'key': 'properties.deletionTime', 'type': 'iso-8601'}, - 'api_type': {'key': 'properties.apiType', 'type': 'str'}, - 'restorable_locations': {'key': 'properties.restorableLocations', 'type': '[RestorableLocationResource]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "account_name": {"key": "properties.accountName", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "oldest_restorable_time": {"key": "properties.oldestRestorableTime", "type": "iso-8601"}, + "deletion_time": {"key": "properties.deletionTime", "type": "iso-8601"}, + "api_type": {"key": "properties.apiType", "type": "str"}, + "restorable_locations": {"key": "properties.restorableLocations", "type": "[RestorableLocationResource]"}, } def __init__( @@ -10436,7 +9947,7 @@ def __init__( (ISO-8601 format). :paramtype deletion_time: ~datetime.datetime """ - super(RestorableDatabaseAccountGetResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -10449,7 +9960,7 @@ def __init__( self.restorable_locations = None -class RestorableDatabaseAccountsListResult(msrest.serialization.Model): +class RestorableDatabaseAccountsListResult(_serialization.Model): """The List operation response, that contains the restorable database accounts and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -10459,24 +9970,20 @@ class RestorableDatabaseAccountsListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[RestorableDatabaseAccountGetResult]'}, + "value": {"key": "value", "type": "[RestorableDatabaseAccountGetResult]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorableDatabaseAccountsListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class RestorableGremlinDatabaseGetResult(msrest.serialization.Model): +class RestorableGremlinDatabaseGetResult(_serialization.Model): """An Azure Cosmos DB Gremlin database event. Variables are only populated by the server, and will be ignored when sending a request. @@ -10492,36 +9999,31 @@ class RestorableGremlinDatabaseGetResult(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'resource': {'key': 'properties.resource', 'type': 'RestorableGremlinDatabasePropertiesResource'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "resource": {"key": "properties.resource", "type": "RestorableGremlinDatabasePropertiesResource"}, } - def __init__( - self, - *, - resource: Optional["_models.RestorableGremlinDatabasePropertiesResource"] = None, - **kwargs - ): + def __init__(self, *, resource: Optional["_models.RestorableGremlinDatabasePropertiesResource"] = None, **kwargs): """ :keyword resource: The resource of an Azure Cosmos DB Gremlin database event. :paramtype resource: ~azure.mgmt.cosmosdb.models.RestorableGremlinDatabasePropertiesResource """ - super(RestorableGremlinDatabaseGetResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.resource = resource -class RestorableGremlinDatabasePropertiesResource(msrest.serialization.Model): +class RestorableGremlinDatabasePropertiesResource(_serialization.Model): """The resource of an Azure Cosmos DB Gremlin database event. Variables are only populated by the server, and will be ignored when sending a request. @@ -10529,7 +10031,7 @@ class RestorableGremlinDatabasePropertiesResource(msrest.serialization.Model): :ivar rid: A system generated property. A unique identifier. :vartype rid: str :ivar operation_type: The operation type of this database event. Known values are: "Create", - "Replace", "Delete", "SystemOperation". + "Replace", "Delete", and "SystemOperation". :vartype operation_type: str or ~azure.mgmt.cosmosdb.models.OperationType :ivar event_timestamp: The time when this database event happened. :vartype event_timestamp: str @@ -10540,28 +10042,24 @@ class RestorableGremlinDatabasePropertiesResource(msrest.serialization.Model): """ _validation = { - 'rid': {'readonly': True}, - 'operation_type': {'readonly': True}, - 'event_timestamp': {'readonly': True}, - 'owner_id': {'readonly': True}, - 'owner_resource_id': {'readonly': True}, + "rid": {"readonly": True}, + "operation_type": {"readonly": True}, + "event_timestamp": {"readonly": True}, + "owner_id": {"readonly": True}, + "owner_resource_id": {"readonly": True}, } _attribute_map = { - 'rid': {'key': '_rid', 'type': 'str'}, - 'operation_type': {'key': 'operationType', 'type': 'str'}, - 'event_timestamp': {'key': 'eventTimestamp', 'type': 'str'}, - 'owner_id': {'key': 'ownerId', 'type': 'str'}, - 'owner_resource_id': {'key': 'ownerResourceId', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "operation_type": {"key": "operationType", "type": "str"}, + "event_timestamp": {"key": "eventTimestamp", "type": "str"}, + "owner_id": {"key": "ownerId", "type": "str"}, + "owner_resource_id": {"key": "ownerResourceId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorableGremlinDatabasePropertiesResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.rid = None self.operation_type = None self.event_timestamp = None @@ -10569,7 +10067,7 @@ def __init__( self.owner_resource_id = None -class RestorableGremlinDatabasesListResult(msrest.serialization.Model): +class RestorableGremlinDatabasesListResult(_serialization.Model): """The List operation response, that contains the Gremlin database events and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -10579,24 +10077,20 @@ class RestorableGremlinDatabasesListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[RestorableGremlinDatabaseGetResult]'}, + "value": {"key": "value", "type": "[RestorableGremlinDatabaseGetResult]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorableGremlinDatabasesListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class RestorableGremlinGraphGetResult(msrest.serialization.Model): +class RestorableGremlinGraphGetResult(_serialization.Model): """An Azure Cosmos DB Gremlin graph event. Variables are only populated by the server, and will be ignored when sending a request. @@ -10612,36 +10106,31 @@ class RestorableGremlinGraphGetResult(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'resource': {'key': 'properties.resource', 'type': 'RestorableGremlinGraphPropertiesResource'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "resource": {"key": "properties.resource", "type": "RestorableGremlinGraphPropertiesResource"}, } - def __init__( - self, - *, - resource: Optional["_models.RestorableGremlinGraphPropertiesResource"] = None, - **kwargs - ): + def __init__(self, *, resource: Optional["_models.RestorableGremlinGraphPropertiesResource"] = None, **kwargs): """ :keyword resource: The resource of an Azure Cosmos DB Gremlin graph event. :paramtype resource: ~azure.mgmt.cosmosdb.models.RestorableGremlinGraphPropertiesResource """ - super(RestorableGremlinGraphGetResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.resource = resource -class RestorableGremlinGraphPropertiesResource(msrest.serialization.Model): +class RestorableGremlinGraphPropertiesResource(_serialization.Model): """The resource of an Azure Cosmos DB Gremlin graph event. Variables are only populated by the server, and will be ignored when sending a request. @@ -10649,7 +10138,7 @@ class RestorableGremlinGraphPropertiesResource(msrest.serialization.Model): :ivar rid: A system generated property. A unique identifier. :vartype rid: str :ivar operation_type: The operation type of this graph event. Known values are: "Create", - "Replace", "Delete", "SystemOperation". + "Replace", "Delete", and "SystemOperation". :vartype operation_type: str or ~azure.mgmt.cosmosdb.models.OperationType :ivar event_timestamp: The time when this graph event happened. :vartype event_timestamp: str @@ -10660,28 +10149,24 @@ class RestorableGremlinGraphPropertiesResource(msrest.serialization.Model): """ _validation = { - 'rid': {'readonly': True}, - 'operation_type': {'readonly': True}, - 'event_timestamp': {'readonly': True}, - 'owner_id': {'readonly': True}, - 'owner_resource_id': {'readonly': True}, + "rid": {"readonly": True}, + "operation_type": {"readonly": True}, + "event_timestamp": {"readonly": True}, + "owner_id": {"readonly": True}, + "owner_resource_id": {"readonly": True}, } _attribute_map = { - 'rid': {'key': '_rid', 'type': 'str'}, - 'operation_type': {'key': 'operationType', 'type': 'str'}, - 'event_timestamp': {'key': 'eventTimestamp', 'type': 'str'}, - 'owner_id': {'key': 'ownerId', 'type': 'str'}, - 'owner_resource_id': {'key': 'ownerResourceId', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "operation_type": {"key": "operationType", "type": "str"}, + "event_timestamp": {"key": "eventTimestamp", "type": "str"}, + "owner_id": {"key": "ownerId", "type": "str"}, + "owner_resource_id": {"key": "ownerResourceId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorableGremlinGraphPropertiesResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.rid = None self.operation_type = None self.event_timestamp = None @@ -10689,7 +10174,7 @@ def __init__( self.owner_resource_id = None -class RestorableGremlinGraphsListResult(msrest.serialization.Model): +class RestorableGremlinGraphsListResult(_serialization.Model): """The List operation response, that contains the Gremlin graph events and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -10699,24 +10184,20 @@ class RestorableGremlinGraphsListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[RestorableGremlinGraphGetResult]'}, + "value": {"key": "value", "type": "[RestorableGremlinGraphGetResult]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorableGremlinGraphsListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class RestorableGremlinResourcesGetResult(msrest.serialization.Model): +class RestorableGremlinResourcesGetResult(_serialization.Model): """Specific Databases to restore. Variables are only populated by the server, and will be ignored when sending a request. @@ -10734,33 +10215,27 @@ class RestorableGremlinResourcesGetResult(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'database_name': {'key': 'databaseName', 'type': 'str'}, - 'graph_names': {'key': 'graphNames', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "database_name": {"key": "databaseName", "type": "str"}, + "graph_names": {"key": "graphNames", "type": "[str]"}, } - def __init__( - self, - *, - database_name: Optional[str] = None, - graph_names: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, database_name: Optional[str] = None, graph_names: Optional[List[str]] = None, **kwargs): """ :keyword database_name: The name of the gremlin database available for restore. :paramtype database_name: str :keyword graph_names: The names of the graphs available for restore. :paramtype graph_names: list[str] """ - super(RestorableGremlinResourcesGetResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -10768,7 +10243,7 @@ def __init__( self.graph_names = graph_names -class RestorableGremlinResourcesListResult(msrest.serialization.Model): +class RestorableGremlinResourcesListResult(_serialization.Model): """The List operation response, that contains the restorable Gremlin resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -10779,24 +10254,20 @@ class RestorableGremlinResourcesListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[RestorableGremlinResourcesGetResult]'}, + "value": {"key": "value", "type": "[RestorableGremlinResourcesGetResult]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorableGremlinResourcesListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class RestorableLocationResource(msrest.serialization.Model): +class RestorableLocationResource(_serialization.Model): """Properties of the regional restorable account. Variables are only populated by the server, and will be ignored when sending a request. @@ -10815,33 +10286,29 @@ class RestorableLocationResource(msrest.serialization.Model): """ _validation = { - 'location_name': {'readonly': True}, - 'regional_database_account_instance_id': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'deletion_time': {'readonly': True}, + "location_name": {"readonly": True}, + "regional_database_account_instance_id": {"readonly": True}, + "creation_time": {"readonly": True}, + "deletion_time": {"readonly": True}, } _attribute_map = { - 'location_name': {'key': 'locationName', 'type': 'str'}, - 'regional_database_account_instance_id': {'key': 'regionalDatabaseAccountInstanceId', 'type': 'str'}, - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, - 'deletion_time': {'key': 'deletionTime', 'type': 'iso-8601'}, + "location_name": {"key": "locationName", "type": "str"}, + "regional_database_account_instance_id": {"key": "regionalDatabaseAccountInstanceId", "type": "str"}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + "deletion_time": {"key": "deletionTime", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorableLocationResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.location_name = None self.regional_database_account_instance_id = None self.creation_time = None self.deletion_time = None -class RestorableMongodbCollectionGetResult(msrest.serialization.Model): +class RestorableMongodbCollectionGetResult(_serialization.Model): """An Azure Cosmos DB MongoDB collection event. Variables are only populated by the server, and will be ignored when sending a request. @@ -10857,36 +10324,31 @@ class RestorableMongodbCollectionGetResult(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'resource': {'key': 'properties.resource', 'type': 'RestorableMongodbCollectionPropertiesResource'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "resource": {"key": "properties.resource", "type": "RestorableMongodbCollectionPropertiesResource"}, } - def __init__( - self, - *, - resource: Optional["_models.RestorableMongodbCollectionPropertiesResource"] = None, - **kwargs - ): + def __init__(self, *, resource: Optional["_models.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) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.resource = resource -class RestorableMongodbCollectionPropertiesResource(msrest.serialization.Model): +class RestorableMongodbCollectionPropertiesResource(_serialization.Model): """The resource of an Azure Cosmos DB MongoDB collection event. Variables are only populated by the server, and will be ignored when sending a request. @@ -10894,7 +10356,7 @@ class RestorableMongodbCollectionPropertiesResource(msrest.serialization.Model): :ivar rid: A system generated property. A unique identifier. :vartype rid: str :ivar operation_type: The operation type of this collection event. Known values are: "Create", - "Replace", "Delete", "SystemOperation". + "Replace", "Delete", and "SystemOperation". :vartype operation_type: str or ~azure.mgmt.cosmosdb.models.OperationType :ivar event_timestamp: The time when this collection event happened. :vartype event_timestamp: str @@ -10905,28 +10367,24 @@ class RestorableMongodbCollectionPropertiesResource(msrest.serialization.Model): """ _validation = { - 'rid': {'readonly': True}, - 'operation_type': {'readonly': True}, - 'event_timestamp': {'readonly': True}, - 'owner_id': {'readonly': True}, - 'owner_resource_id': {'readonly': True}, + "rid": {"readonly": True}, + "operation_type": {"readonly": True}, + "event_timestamp": {"readonly": True}, + "owner_id": {"readonly": True}, + "owner_resource_id": {"readonly": True}, } _attribute_map = { - 'rid': {'key': '_rid', 'type': 'str'}, - 'operation_type': {'key': 'operationType', 'type': 'str'}, - 'event_timestamp': {'key': 'eventTimestamp', 'type': 'str'}, - 'owner_id': {'key': 'ownerId', 'type': 'str'}, - 'owner_resource_id': {'key': 'ownerResourceId', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "operation_type": {"key": "operationType", "type": "str"}, + "event_timestamp": {"key": "eventTimestamp", "type": "str"}, + "owner_id": {"key": "ownerId", "type": "str"}, + "owner_resource_id": {"key": "ownerResourceId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorableMongodbCollectionPropertiesResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.rid = None self.operation_type = None self.event_timestamp = None @@ -10934,7 +10392,7 @@ def __init__( self.owner_resource_id = None -class RestorableMongodbCollectionsListResult(msrest.serialization.Model): +class RestorableMongodbCollectionsListResult(_serialization.Model): """The List operation response, that contains the MongoDB collection events and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -10944,24 +10402,20 @@ class RestorableMongodbCollectionsListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[RestorableMongodbCollectionGetResult]'}, + "value": {"key": "value", "type": "[RestorableMongodbCollectionGetResult]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorableMongodbCollectionsListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class RestorableMongodbDatabaseGetResult(msrest.serialization.Model): +class RestorableMongodbDatabaseGetResult(_serialization.Model): """An Azure Cosmos DB MongoDB database event. Variables are only populated by the server, and will be ignored when sending a request. @@ -10977,36 +10431,31 @@ class RestorableMongodbDatabaseGetResult(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'resource': {'key': 'properties.resource', 'type': 'RestorableMongodbDatabasePropertiesResource'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "resource": {"key": "properties.resource", "type": "RestorableMongodbDatabasePropertiesResource"}, } - def __init__( - self, - *, - resource: Optional["_models.RestorableMongodbDatabasePropertiesResource"] = None, - **kwargs - ): + def __init__(self, *, resource: Optional["_models.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) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.resource = resource -class RestorableMongodbDatabasePropertiesResource(msrest.serialization.Model): +class RestorableMongodbDatabasePropertiesResource(_serialization.Model): """The resource of an Azure Cosmos DB MongoDB database event. Variables are only populated by the server, and will be ignored when sending a request. @@ -11014,7 +10463,7 @@ class RestorableMongodbDatabasePropertiesResource(msrest.serialization.Model): :ivar rid: A system generated property. A unique identifier. :vartype rid: str :ivar operation_type: The operation type of this database event. Known values are: "Create", - "Replace", "Delete", "SystemOperation". + "Replace", "Delete", and "SystemOperation". :vartype operation_type: str or ~azure.mgmt.cosmosdb.models.OperationType :ivar event_timestamp: The time when this database event happened. :vartype event_timestamp: str @@ -11025,28 +10474,24 @@ class RestorableMongodbDatabasePropertiesResource(msrest.serialization.Model): """ _validation = { - 'rid': {'readonly': True}, - 'operation_type': {'readonly': True}, - 'event_timestamp': {'readonly': True}, - 'owner_id': {'readonly': True}, - 'owner_resource_id': {'readonly': True}, + "rid": {"readonly": True}, + "operation_type": {"readonly": True}, + "event_timestamp": {"readonly": True}, + "owner_id": {"readonly": True}, + "owner_resource_id": {"readonly": True}, } _attribute_map = { - 'rid': {'key': '_rid', 'type': 'str'}, - 'operation_type': {'key': 'operationType', 'type': 'str'}, - 'event_timestamp': {'key': 'eventTimestamp', 'type': 'str'}, - 'owner_id': {'key': 'ownerId', 'type': 'str'}, - 'owner_resource_id': {'key': 'ownerResourceId', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "operation_type": {"key": "operationType", "type": "str"}, + "event_timestamp": {"key": "eventTimestamp", "type": "str"}, + "owner_id": {"key": "ownerId", "type": "str"}, + "owner_resource_id": {"key": "ownerResourceId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorableMongodbDatabasePropertiesResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.rid = None self.operation_type = None self.event_timestamp = None @@ -11054,7 +10499,7 @@ def __init__( self.owner_resource_id = None -class RestorableMongodbDatabasesListResult(msrest.serialization.Model): +class RestorableMongodbDatabasesListResult(_serialization.Model): """The List operation response, that contains the MongoDB database events and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -11064,24 +10509,20 @@ class RestorableMongodbDatabasesListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[RestorableMongodbDatabaseGetResult]'}, + "value": {"key": "value", "type": "[RestorableMongodbDatabaseGetResult]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorableMongodbDatabasesListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class RestorableMongodbResourcesGetResult(msrest.serialization.Model): +class RestorableMongodbResourcesGetResult(_serialization.Model): """Specific Databases to restore. Variables are only populated by the server, and will be ignored when sending a request. @@ -11099,33 +10540,27 @@ class RestorableMongodbResourcesGetResult(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'database_name': {'key': 'databaseName', 'type': 'str'}, - 'collection_names': {'key': 'collectionNames', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "database_name": {"key": "databaseName", "type": "str"}, + "collection_names": {"key": "collectionNames", "type": "[str]"}, } - def __init__( - self, - *, - database_name: Optional[str] = None, - collection_names: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, database_name: Optional[str] = None, 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(RestorableMongodbResourcesGetResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -11133,7 +10568,7 @@ def __init__( self.collection_names = collection_names -class RestorableMongodbResourcesListResult(msrest.serialization.Model): +class RestorableMongodbResourcesListResult(_serialization.Model): """The List operation response, that contains the restorable MongoDB resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -11143,24 +10578,20 @@ class RestorableMongodbResourcesListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[RestorableMongodbResourcesGetResult]'}, + "value": {"key": "value", "type": "[RestorableMongodbResourcesGetResult]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorableMongodbResourcesListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class RestorableSqlContainerGetResult(msrest.serialization.Model): +class RestorableSqlContainerGetResult(_serialization.Model): """An Azure Cosmos DB SQL container event. Variables are only populated by the server, and will be ignored when sending a request. @@ -11176,36 +10607,31 @@ class RestorableSqlContainerGetResult(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'resource': {'key': 'properties.resource', 'type': 'RestorableSqlContainerPropertiesResource'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "resource": {"key": "properties.resource", "type": "RestorableSqlContainerPropertiesResource"}, } - def __init__( - self, - *, - resource: Optional["_models.RestorableSqlContainerPropertiesResource"] = None, - **kwargs - ): + def __init__(self, *, resource: Optional["_models.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) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.resource = resource -class RestorableSqlContainerPropertiesResource(msrest.serialization.Model): +class RestorableSqlContainerPropertiesResource(_serialization.Model): """The resource of an Azure Cosmos DB SQL container event. Variables are only populated by the server, and will be ignored when sending a request. @@ -11213,7 +10639,7 @@ class RestorableSqlContainerPropertiesResource(msrest.serialization.Model): :ivar rid: A system generated property. A unique identifier. :vartype rid: str :ivar operation_type: The operation type of this container event. Known values are: "Create", - "Replace", "Delete", "SystemOperation". + "Replace", "Delete", and "SystemOperation". :vartype operation_type: str or ~azure.mgmt.cosmosdb.models.OperationType :ivar event_timestamp: The when this container event happened. :vartype event_timestamp: str @@ -11227,34 +10653,31 @@ class RestorableSqlContainerPropertiesResource(msrest.serialization.Model): """ _validation = { - 'rid': {'readonly': True}, - 'operation_type': {'readonly': True}, - 'event_timestamp': {'readonly': True}, - 'owner_id': {'readonly': True}, - 'owner_resource_id': {'readonly': True}, + "rid": {"readonly": True}, + "operation_type": {"readonly": True}, + "event_timestamp": {"readonly": True}, + "owner_id": {"readonly": True}, + "owner_resource_id": {"readonly": True}, } _attribute_map = { - 'rid': {'key': '_rid', 'type': 'str'}, - 'operation_type': {'key': 'operationType', 'type': 'str'}, - 'event_timestamp': {'key': 'eventTimestamp', 'type': 'str'}, - 'owner_id': {'key': 'ownerId', 'type': 'str'}, - 'owner_resource_id': {'key': 'ownerResourceId', 'type': 'str'}, - 'container': {'key': 'container', 'type': 'RestorableSqlContainerPropertiesResourceContainer'}, + "rid": {"key": "_rid", "type": "str"}, + "operation_type": {"key": "operationType", "type": "str"}, + "event_timestamp": {"key": "eventTimestamp", "type": "str"}, + "owner_id": {"key": "ownerId", "type": "str"}, + "owner_resource_id": {"key": "ownerResourceId", "type": "str"}, + "container": {"key": "container", "type": "RestorableSqlContainerPropertiesResourceContainer"}, } def __init__( - self, - *, - container: Optional["_models.RestorableSqlContainerPropertiesResourceContainer"] = None, - **kwargs + self, *, container: Optional["_models.RestorableSqlContainerPropertiesResourceContainer"] = None, **kwargs ): """ :keyword container: Cosmos DB SQL container resource object. :paramtype container: ~azure.mgmt.cosmosdb.models.RestorableSqlContainerPropertiesResourceContainer """ - super(RestorableSqlContainerPropertiesResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.rid = None self.operation_type = None self.event_timestamp = None @@ -11263,12 +10686,12 @@ def __init__( self.container = container -class SqlContainerResource(msrest.serialization.Model): +class SqlContainerResource(_serialization.Model): """Cosmos DB SQL container resource object. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Name of the Cosmos DB SQL container. + :ivar id: Name of the Cosmos DB SQL container. Required. :vartype id: str :ivar indexing_policy: The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container. @@ -11286,28 +10709,28 @@ class SqlContainerResource(msrest.serialization.Model): :ivar client_encryption_policy: The client encryption policy for the container. :vartype client_encryption_policy: ~azure.mgmt.cosmosdb.models.ClientEncryptionPolicy :ivar analytical_storage_ttl: Analytical TTL. - :vartype analytical_storage_ttl: long + :vartype analytical_storage_ttl: int """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'indexing_policy': {'key': 'indexingPolicy', 'type': 'IndexingPolicy'}, - 'partition_key': {'key': 'partitionKey', 'type': 'ContainerPartitionKey'}, - 'default_ttl': {'key': 'defaultTtl', 'type': 'int'}, - 'unique_key_policy': {'key': 'uniqueKeyPolicy', 'type': 'UniqueKeyPolicy'}, - 'conflict_resolution_policy': {'key': 'conflictResolutionPolicy', 'type': 'ConflictResolutionPolicy'}, - 'client_encryption_policy': {'key': 'clientEncryptionPolicy', 'type': 'ClientEncryptionPolicy'}, - 'analytical_storage_ttl': {'key': 'analyticalStorageTtl', 'type': 'long'}, + "id": {"key": "id", "type": "str"}, + "indexing_policy": {"key": "indexingPolicy", "type": "IndexingPolicy"}, + "partition_key": {"key": "partitionKey", "type": "ContainerPartitionKey"}, + "default_ttl": {"key": "defaultTtl", "type": "int"}, + "unique_key_policy": {"key": "uniqueKeyPolicy", "type": "UniqueKeyPolicy"}, + "conflict_resolution_policy": {"key": "conflictResolutionPolicy", "type": "ConflictResolutionPolicy"}, + "client_encryption_policy": {"key": "clientEncryptionPolicy", "type": "ClientEncryptionPolicy"}, + "analytical_storage_ttl": {"key": "analyticalStorageTtl", "type": "int"}, } def __init__( self, *, - id: str, + id: str, # pylint: disable=redefined-builtin indexing_policy: Optional["_models.IndexingPolicy"] = None, partition_key: Optional["_models.ContainerPartitionKey"] = None, default_ttl: Optional[int] = None, @@ -11318,7 +10741,7 @@ def __init__( **kwargs ): """ - :keyword id: Required. Name of the Cosmos DB SQL container. + :keyword id: Name of the Cosmos DB SQL container. Required. :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. @@ -11336,9 +10759,9 @@ def __init__( :keyword client_encryption_policy: The client encryption policy for the container. :paramtype client_encryption_policy: ~azure.mgmt.cosmosdb.models.ClientEncryptionPolicy :keyword analytical_storage_ttl: Analytical TTL. - :paramtype analytical_storage_ttl: long + :paramtype analytical_storage_ttl: int """ - super(SqlContainerResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.indexing_policy = indexing_policy self.partition_key = partition_key @@ -11349,14 +10772,23 @@ def __init__( self.analytical_storage_ttl = analytical_storage_ttl -class RestorableSqlContainerPropertiesResourceContainer(ExtendedResourceProperties, SqlContainerResource): +class RestorableSqlContainerPropertiesResourceContainer( + SqlContainerResource, ExtendedResourceProperties +): # pylint: disable=too-many-instance-attributes """Cosmos DB SQL container resource object. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Name of the Cosmos DB SQL container. + :ivar rid: A system generated property. A unique identifier. + :vartype rid: str + :ivar ts: A system generated property that denotes the last updated timestamp of the resource. + :vartype ts: float + :ivar etag: A system generated property representing the resource etag required for optimistic + concurrency control. + :vartype etag: str + :ivar id: Name of the Cosmos DB SQL container. Required. :vartype id: str :ivar indexing_policy: The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container. @@ -11374,46 +10806,39 @@ class RestorableSqlContainerPropertiesResourceContainer(ExtendedResourceProperti :ivar client_encryption_policy: The client encryption policy for the container. :vartype client_encryption_policy: ~azure.mgmt.cosmosdb.models.ClientEncryptionPolicy :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. - :vartype ts: float - :ivar etag: A system generated property representing the resource etag required for optimistic - concurrency control. - :vartype etag: str + :vartype analytical_storage_ttl: int :ivar self_property: A system generated property that specifies the addressable path of the container resource. :vartype self_property: str """ _validation = { - 'id': {'required': True}, - 'rid': {'readonly': True}, - 'ts': {'readonly': True}, - 'etag': {'readonly': True}, - 'self_property': {'readonly': True}, + "rid": {"readonly": True}, + "ts": {"readonly": True}, + "etag": {"readonly": True}, + "id": {"required": True}, + "self_property": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'indexing_policy': {'key': 'indexingPolicy', 'type': 'IndexingPolicy'}, - 'partition_key': {'key': 'partitionKey', 'type': 'ContainerPartitionKey'}, - 'default_ttl': {'key': 'defaultTtl', 'type': 'int'}, - 'unique_key_policy': {'key': 'uniqueKeyPolicy', 'type': 'UniqueKeyPolicy'}, - 'conflict_resolution_policy': {'key': 'conflictResolutionPolicy', 'type': 'ConflictResolutionPolicy'}, - 'client_encryption_policy': {'key': 'clientEncryptionPolicy', 'type': 'ClientEncryptionPolicy'}, - 'analytical_storage_ttl': {'key': 'analyticalStorageTtl', 'type': 'long'}, - 'rid': {'key': '_rid', 'type': 'str'}, - 'ts': {'key': '_ts', 'type': 'float'}, - 'etag': {'key': '_etag', 'type': 'str'}, - 'self_property': {'key': '_self', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "indexing_policy": {"key": "indexingPolicy", "type": "IndexingPolicy"}, + "partition_key": {"key": "partitionKey", "type": "ContainerPartitionKey"}, + "default_ttl": {"key": "defaultTtl", "type": "int"}, + "unique_key_policy": {"key": "uniqueKeyPolicy", "type": "UniqueKeyPolicy"}, + "conflict_resolution_policy": {"key": "conflictResolutionPolicy", "type": "ConflictResolutionPolicy"}, + "client_encryption_policy": {"key": "clientEncryptionPolicy", "type": "ClientEncryptionPolicy"}, + "analytical_storage_ttl": {"key": "analyticalStorageTtl", "type": "int"}, + "self_property": {"key": "_self", "type": "str"}, } def __init__( self, *, - id: str, + id: str, # pylint: disable=redefined-builtin indexing_policy: Optional["_models.IndexingPolicy"] = None, partition_key: Optional["_models.ContainerPartitionKey"] = None, default_ttl: Optional[int] = None, @@ -11424,7 +10849,7 @@ def __init__( **kwargs ): """ - :keyword id: Required. Name of the Cosmos DB SQL container. + :keyword id: Name of the Cosmos DB SQL container. Required. :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. @@ -11442,9 +10867,23 @@ def __init__( :keyword client_encryption_policy: The client encryption policy for the container. :paramtype client_encryption_policy: ~azure.mgmt.cosmosdb.models.ClientEncryptionPolicy :keyword analytical_storage_ttl: Analytical TTL. - :paramtype analytical_storage_ttl: long + :paramtype analytical_storage_ttl: int """ - 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, client_encryption_policy=client_encryption_policy, analytical_storage_ttl=analytical_storage_ttl, **kwargs) + super().__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, + client_encryption_policy=client_encryption_policy, + analytical_storage_ttl=analytical_storage_ttl, + **kwargs + ) + self.rid = None + self.ts = None + self.etag = None + self.self_property = None self.id = id self.indexing_policy = indexing_policy self.partition_key = partition_key @@ -11453,13 +10892,9 @@ def __init__( self.conflict_resolution_policy = conflict_resolution_policy self.client_encryption_policy = client_encryption_policy self.analytical_storage_ttl = analytical_storage_ttl - self.self_property = None - self.rid = None - self.ts = None - self.etag = None -class RestorableSqlContainersListResult(msrest.serialization.Model): +class RestorableSqlContainersListResult(_serialization.Model): """The List operation response, that contains the SQL container events and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -11469,24 +10904,20 @@ class RestorableSqlContainersListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[RestorableSqlContainerGetResult]'}, + "value": {"key": "value", "type": "[RestorableSqlContainerGetResult]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorableSqlContainersListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class RestorableSqlDatabaseGetResult(msrest.serialization.Model): +class RestorableSqlDatabaseGetResult(_serialization.Model): """An Azure Cosmos DB SQL database event. Variables are only populated by the server, and will be ignored when sending a request. @@ -11502,36 +10933,31 @@ class RestorableSqlDatabaseGetResult(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'resource': {'key': 'properties.resource', 'type': 'RestorableSqlDatabasePropertiesResource'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "resource": {"key": "properties.resource", "type": "RestorableSqlDatabasePropertiesResource"}, } - def __init__( - self, - *, - resource: Optional["_models.RestorableSqlDatabasePropertiesResource"] = None, - **kwargs - ): + def __init__(self, *, resource: Optional["_models.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) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.resource = resource -class RestorableSqlDatabasePropertiesResource(msrest.serialization.Model): +class RestorableSqlDatabasePropertiesResource(_serialization.Model): """The resource of an Azure Cosmos DB SQL database event. Variables are only populated by the server, and will be ignored when sending a request. @@ -11539,7 +10965,7 @@ class RestorableSqlDatabasePropertiesResource(msrest.serialization.Model): :ivar rid: A system generated property. A unique identifier. :vartype rid: str :ivar operation_type: The operation type of this database event. Known values are: "Create", - "Replace", "Delete", "SystemOperation". + "Replace", "Delete", and "SystemOperation". :vartype operation_type: str or ~azure.mgmt.cosmosdb.models.OperationType :ivar event_timestamp: The time when this database event happened. :vartype event_timestamp: str @@ -11552,34 +10978,31 @@ class RestorableSqlDatabasePropertiesResource(msrest.serialization.Model): """ _validation = { - 'rid': {'readonly': True}, - 'operation_type': {'readonly': True}, - 'event_timestamp': {'readonly': True}, - 'owner_id': {'readonly': True}, - 'owner_resource_id': {'readonly': True}, + "rid": {"readonly": True}, + "operation_type": {"readonly": True}, + "event_timestamp": {"readonly": True}, + "owner_id": {"readonly": True}, + "owner_resource_id": {"readonly": True}, } _attribute_map = { - 'rid': {'key': '_rid', 'type': 'str'}, - 'operation_type': {'key': 'operationType', 'type': 'str'}, - 'event_timestamp': {'key': 'eventTimestamp', 'type': 'str'}, - 'owner_id': {'key': 'ownerId', 'type': 'str'}, - 'owner_resource_id': {'key': 'ownerResourceId', 'type': 'str'}, - 'database': {'key': 'database', 'type': 'RestorableSqlDatabasePropertiesResourceDatabase'}, + "rid": {"key": "_rid", "type": "str"}, + "operation_type": {"key": "operationType", "type": "str"}, + "event_timestamp": {"key": "eventTimestamp", "type": "str"}, + "owner_id": {"key": "ownerId", "type": "str"}, + "owner_resource_id": {"key": "ownerResourceId", "type": "str"}, + "database": {"key": "database", "type": "RestorableSqlDatabasePropertiesResourceDatabase"}, } def __init__( - self, - *, - database: Optional["_models.RestorableSqlDatabasePropertiesResourceDatabase"] = None, - **kwargs + self, *, database: Optional["_models.RestorableSqlDatabasePropertiesResourceDatabase"] = None, **kwargs ): """ :keyword database: Cosmos DB SQL database resource object. :paramtype database: ~azure.mgmt.cosmosdb.models.RestorableSqlDatabasePropertiesResourceDatabase """ - super(RestorableSqlDatabasePropertiesResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.rid = None self.operation_type = None self.event_timestamp = None @@ -11588,34 +11011,29 @@ def __init__( self.database = database -class SqlDatabaseResource(msrest.serialization.Model): +class SqlDatabaseResource(_serialization.Model): """Cosmos DB SQL database resource object. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Name of the Cosmos DB SQL database. + :ivar id: Name of the Cosmos DB SQL database. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Name of the Cosmos DB SQL database. + :keyword id: Name of the Cosmos DB SQL database. Required. :paramtype id: str """ - super(SqlDatabaseResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -11633,7 +11051,7 @@ class RestorableSqlDatabasePropertiesResourceDatabase(SqlDatabaseResource, Exten :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str - :ivar id: Required. Name of the Cosmos DB SQL database. + :ivar id: Name of the Cosmos DB SQL database. Required. :vartype id: str :ivar colls: A system generated property that specified the addressable path of the collections resource. @@ -11647,36 +11065,31 @@ class RestorableSqlDatabasePropertiesResourceDatabase(SqlDatabaseResource, Exten """ _validation = { - 'rid': {'readonly': True}, - 'ts': {'readonly': True}, - 'etag': {'readonly': True}, - 'id': {'required': True}, - 'colls': {'readonly': True}, - 'users': {'readonly': True}, - 'self_property': {'readonly': True}, + "rid": {"readonly": True}, + "ts": {"readonly": True}, + "etag": {"readonly": True}, + "id": {"required": True}, + "colls": {"readonly": True}, + "users": {"readonly": True}, + "self_property": {"readonly": True}, } _attribute_map = { - 'rid': {'key': '_rid', 'type': 'str'}, - 'ts': {'key': '_ts', 'type': 'float'}, - 'etag': {'key': '_etag', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'colls': {'key': '_colls', 'type': 'str'}, - 'users': {'key': '_users', 'type': 'str'}, - 'self_property': {'key': '_self', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "colls": {"key": "_colls", "type": "str"}, + "users": {"key": "_users", "type": "str"}, + "self_property": {"key": "_self", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Name of the Cosmos DB SQL database. + :keyword id: Name of the Cosmos DB SQL database. Required. :paramtype id: str """ - super(RestorableSqlDatabasePropertiesResourceDatabase, self).__init__(id=id, **kwargs) + super().__init__(id=id, **kwargs) self.rid = None self.ts = None self.etag = None @@ -11686,7 +11099,7 @@ def __init__( self.id = id -class RestorableSqlDatabasesListResult(msrest.serialization.Model): +class RestorableSqlDatabasesListResult(_serialization.Model): """The List operation response, that contains the SQL database events and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -11696,24 +11109,20 @@ class RestorableSqlDatabasesListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[RestorableSqlDatabaseGetResult]'}, + "value": {"key": "value", "type": "[RestorableSqlDatabaseGetResult]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorableSqlDatabasesListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class RestorableSqlResourcesGetResult(msrest.serialization.Model): +class RestorableSqlResourcesGetResult(_serialization.Model): """Specific Databases to restore. Variables are only populated by the server, and will be ignored when sending a request. @@ -11731,33 +11140,27 @@ class RestorableSqlResourcesGetResult(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'database_name': {'key': 'databaseName', 'type': 'str'}, - 'collection_names': {'key': 'collectionNames', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "database_name": {"key": "databaseName", "type": "str"}, + "collection_names": {"key": "collectionNames", "type": "[str]"}, } - def __init__( - self, - *, - database_name: Optional[str] = None, - collection_names: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, database_name: Optional[str] = None, 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(RestorableSqlResourcesGetResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -11765,7 +11168,7 @@ def __init__( self.collection_names = collection_names -class RestorableSqlResourcesListResult(msrest.serialization.Model): +class RestorableSqlResourcesListResult(_serialization.Model): """The List operation response, that contains the restorable SQL resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -11775,24 +11178,20 @@ class RestorableSqlResourcesListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[RestorableSqlResourcesGetResult]'}, + "value": {"key": "value", "type": "[RestorableSqlResourcesGetResult]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorableSqlResourcesListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class RestorableTableGetResult(msrest.serialization.Model): +class RestorableTableGetResult(_serialization.Model): """An Azure Cosmos DB Table event. Variables are only populated by the server, and will be ignored when sending a request. @@ -11808,36 +11207,31 @@ class RestorableTableGetResult(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'resource': {'key': 'properties.resource', 'type': 'RestorableTablePropertiesResource'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "resource": {"key": "properties.resource", "type": "RestorableTablePropertiesResource"}, } - def __init__( - self, - *, - resource: Optional["_models.RestorableTablePropertiesResource"] = None, - **kwargs - ): + def __init__(self, *, resource: Optional["_models.RestorableTablePropertiesResource"] = None, **kwargs): """ :keyword resource: The resource of an Azure Cosmos DB Table event. :paramtype resource: ~azure.mgmt.cosmosdb.models.RestorableTablePropertiesResource """ - super(RestorableTableGetResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.resource = resource -class RestorableTablePropertiesResource(msrest.serialization.Model): +class RestorableTablePropertiesResource(_serialization.Model): """The resource of an Azure Cosmos DB Table event. Variables are only populated by the server, and will be ignored when sending a request. @@ -11845,7 +11239,7 @@ class RestorableTablePropertiesResource(msrest.serialization.Model): :ivar rid: A system generated property. A unique identifier. :vartype rid: str :ivar operation_type: The operation type of this table event. Known values are: "Create", - "Replace", "Delete", "SystemOperation". + "Replace", "Delete", and "SystemOperation". :vartype operation_type: str or ~azure.mgmt.cosmosdb.models.OperationType :ivar event_timestamp: The time when this table event happened. :vartype event_timestamp: str @@ -11856,28 +11250,24 @@ class RestorableTablePropertiesResource(msrest.serialization.Model): """ _validation = { - 'rid': {'readonly': True}, - 'operation_type': {'readonly': True}, - 'event_timestamp': {'readonly': True}, - 'owner_id': {'readonly': True}, - 'owner_resource_id': {'readonly': True}, + "rid": {"readonly": True}, + "operation_type": {"readonly": True}, + "event_timestamp": {"readonly": True}, + "owner_id": {"readonly": True}, + "owner_resource_id": {"readonly": True}, } _attribute_map = { - 'rid': {'key': '_rid', 'type': 'str'}, - 'operation_type': {'key': 'operationType', 'type': 'str'}, - 'event_timestamp': {'key': 'eventTimestamp', 'type': 'str'}, - 'owner_id': {'key': 'ownerId', 'type': 'str'}, - 'owner_resource_id': {'key': 'ownerResourceId', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "operation_type": {"key": "operationType", "type": "str"}, + "event_timestamp": {"key": "eventTimestamp", "type": "str"}, + "owner_id": {"key": "ownerId", "type": "str"}, + "owner_resource_id": {"key": "ownerResourceId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorableTablePropertiesResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.rid = None self.operation_type = None self.event_timestamp = None @@ -11885,7 +11275,7 @@ def __init__( self.owner_resource_id = None -class RestorableTableResourcesGetResult(msrest.serialization.Model): +class RestorableTableResourcesGetResult(_serialization.Model): """Specific Databases to restore. Variables are only populated by the server, and will be ignored when sending a request. @@ -11899,30 +11289,26 @@ class RestorableTableResourcesGetResult(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorableTableResourcesGetResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None -class RestorableTableResourcesListResult(msrest.serialization.Model): +class RestorableTableResourcesListResult(_serialization.Model): """List of restorable table names. Variables are only populated by the server, and will be ignored when sending a request. @@ -11932,24 +11318,20 @@ class RestorableTableResourcesListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[RestorableTableResourcesGetResult]'}, + "value": {"key": "value", "type": "[RestorableTableResourcesGetResult]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorableTableResourcesListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class RestorableTablesListResult(msrest.serialization.Model): +class RestorableTablesListResult(_serialization.Model): """The List operation response, that contains the Table events and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -11959,27 +11341,23 @@ class RestorableTablesListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[RestorableTableGetResult]'}, + "value": {"key": "value", "type": "[RestorableTableGetResult]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorableTablesListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class RestoreParameters(msrest.serialization.Model): +class RestoreParameters(_serialization.Model): """Parameters to indicate the information about the restore. - :ivar restore_mode: Describes the mode of the restore. Known values are: "PointInTime". + :ivar restore_mode: Describes the mode of the restore. "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: @@ -11997,12 +11375,15 @@ class RestoreParameters(msrest.serialization.Model): """ _attribute_map = { - 'restore_mode': {'key': 'restoreMode', 'type': 'str'}, - 'restore_source': {'key': 'restoreSource', 'type': 'str'}, - 'restore_timestamp_in_utc': {'key': 'restoreTimestampInUtc', 'type': 'iso-8601'}, - 'databases_to_restore': {'key': 'databasesToRestore', 'type': '[DatabaseRestoreResource]'}, - 'gremlin_databases_to_restore': {'key': 'gremlinDatabasesToRestore', 'type': '[GremlinDatabaseRestoreResource]'}, - 'tables_to_restore': {'key': 'tablesToRestore', 'type': '[str]'}, + "restore_mode": {"key": "restoreMode", "type": "str"}, + "restore_source": {"key": "restoreSource", "type": "str"}, + "restore_timestamp_in_utc": {"key": "restoreTimestampInUtc", "type": "iso-8601"}, + "databases_to_restore": {"key": "databasesToRestore", "type": "[DatabaseRestoreResource]"}, + "gremlin_databases_to_restore": { + "key": "gremlinDatabasesToRestore", + "type": "[GremlinDatabaseRestoreResource]", + }, + "tables_to_restore": {"key": "tablesToRestore", "type": "[str]"}, } def __init__( @@ -12017,7 +11398,7 @@ def __init__( **kwargs ): """ - :keyword restore_mode: Describes the mode of the restore. Known values are: "PointInTime". + :keyword restore_mode: Describes the mode of the restore. "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: @@ -12035,7 +11416,7 @@ def __init__( :keyword tables_to_restore: List of specific tables available for restore. :paramtype tables_to_restore: list[str] """ - super(RestoreParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.restore_mode = restore_mode self.restore_source = restore_source self.restore_timestamp_in_utc = restore_timestamp_in_utc @@ -12059,34 +11440,34 @@ class RetrieveThroughputParameters(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :ivar resource: Required. The standard JSON format of a resource throughput. + :ivar resource: The standard JSON format of a resource throughput. Required. :vartype resource: ~azure.mgmt.cosmosdb.models.RetrieveThroughputPropertiesResource """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'RetrieveThroughputPropertiesResource'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "RetrieveThroughputPropertiesResource"}, } def __init__( @@ -12101,54 +11482,49 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :keyword resource: Required. The standard JSON format of a resource throughput. + :keyword resource: The standard JSON format of a resource throughput. Required. :paramtype resource: ~azure.mgmt.cosmosdb.models.RetrieveThroughputPropertiesResource """ - super(RetrieveThroughputParameters, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource -class RetrieveThroughputPropertiesResource(msrest.serialization.Model): +class RetrieveThroughputPropertiesResource(_serialization.Model): """Resource to retrieve throughput information for Cosmos DB resource. All required parameters must be populated in order to send to Azure. - :ivar physical_partition_ids: Required. Array of PhysicalPartitionId objects. + :ivar physical_partition_ids: Array of PhysicalPartitionId objects. Required. :vartype physical_partition_ids: list[~azure.mgmt.cosmosdb.models.PhysicalPartitionId] """ _validation = { - 'physical_partition_ids': {'required': True}, + "physical_partition_ids": {"required": True}, } _attribute_map = { - 'physical_partition_ids': {'key': 'physicalPartitionIds', 'type': '[PhysicalPartitionId]'}, + "physical_partition_ids": {"key": "physicalPartitionIds", "type": "[PhysicalPartitionId]"}, } - def __init__( - self, - *, - physical_partition_ids: List["_models.PhysicalPartitionId"], - **kwargs - ): + def __init__(self, *, physical_partition_ids: List["_models.PhysicalPartitionId"], **kwargs): """ - :keyword physical_partition_ids: Required. Array of PhysicalPartitionId objects. + :keyword physical_partition_ids: Array of PhysicalPartitionId objects. Required. :paramtype physical_partition_ids: list[~azure.mgmt.cosmosdb.models.PhysicalPartitionId] """ - super(RetrieveThroughputPropertiesResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.physical_partition_ids = physical_partition_ids -class Role(msrest.serialization.Model): +class Role(_serialization.Model): """The set of roles permitted through this Role Definition. :ivar db: The database name the role is applied. @@ -12158,29 +11534,23 @@ class Role(msrest.serialization.Model): """ _attribute_map = { - 'db': {'key': 'db', 'type': 'str'}, - 'role': {'key': 'role', 'type': 'str'}, + "db": {"key": "db", "type": "str"}, + "role": {"key": "role", "type": "str"}, } - def __init__( - self, - *, - db: Optional[str] = None, - role: Optional[str] = None, - **kwargs - ): + def __init__(self, *, db: Optional[str] = None, role: Optional[str] = None, **kwargs): """ :keyword db: The database name the role is applied. :paramtype db: str :keyword role: The role name. :paramtype role: str """ - super(Role, self).__init__(**kwargs) + super().__init__(**kwargs) self.db = db self.role = role -class SeedNode(msrest.serialization.Model): +class SeedNode(_serialization.Model): """SeedNode. :ivar ip_address: IP address of this seed node. @@ -12188,20 +11558,15 @@ class SeedNode(msrest.serialization.Model): """ _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, + "ip_address": {"key": "ipAddress", "type": "str"}, } - def __init__( - self, - *, - ip_address: Optional[str] = None, - **kwargs - ): + def __init__(self, *, ip_address: Optional[str] = None, **kwargs): """ :keyword ip_address: IP address of this seed node. :paramtype ip_address: str """ - super(SeedNode, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_address = ip_address @@ -12221,53 +11586,48 @@ class ServiceResource(ARMProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ServiceResourceProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "ServiceResourceProperties"}, } - def __init__( - self, - *, - properties: Optional["_models.ServiceResourceProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ServiceResourceProperties"] = None, **kwargs): """ :keyword properties: Services response resource. :paramtype properties: ~azure.mgmt.cosmosdb.models.ServiceResourceProperties """ - super(ServiceResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ServiceResourceCreateUpdateParameters(msrest.serialization.Model): +class ServiceResourceCreateUpdateParameters(_serialization.Model): """Parameters for Create or Update Request for ServiceResource. :ivar instance_size: Instance type for the service. Known values are: "Cosmos.D4s", - "Cosmos.D8s", "Cosmos.D16s". + "Cosmos.D8s", and "Cosmos.D16s". :vartype instance_size: str or ~azure.mgmt.cosmosdb.models.ServiceSize :ivar instance_count: Instance count for the service. :vartype instance_count: int :ivar service_type: ServiceType for the service. Known values are: "SqlDedicatedGateway", - "DataTransfer", "GraphAPICompute", "MaterializedViewsBuilder". + "DataTransfer", "GraphAPICompute", and "MaterializedViewsBuilder". :vartype service_type: str or ~azure.mgmt.cosmosdb.models.ServiceType """ _validation = { - 'instance_count': {'minimum': 0}, + "instance_count": {"minimum": 0}, } _attribute_map = { - 'instance_size': {'key': 'properties.instanceSize', 'type': 'str'}, - 'instance_count': {'key': 'properties.instanceCount', 'type': 'int'}, - 'service_type': {'key': 'properties.serviceType', 'type': 'str'}, + "instance_size": {"key": "properties.instanceSize", "type": "str"}, + "instance_count": {"key": "properties.instanceCount", "type": "int"}, + "service_type": {"key": "properties.serviceType", "type": "str"}, } def __init__( @@ -12280,21 +11640,21 @@ def __init__( ): """ :keyword instance_size: Instance type for the service. Known values are: "Cosmos.D4s", - "Cosmos.D8s", "Cosmos.D16s". + "Cosmos.D8s", and "Cosmos.D16s". :paramtype instance_size: str or ~azure.mgmt.cosmosdb.models.ServiceSize :keyword instance_count: Instance count for the service. :paramtype instance_count: int :keyword service_type: ServiceType for the service. Known values are: "SqlDedicatedGateway", - "DataTransfer", "GraphAPICompute", "MaterializedViewsBuilder". + "DataTransfer", "GraphAPICompute", and "MaterializedViewsBuilder". :paramtype service_type: str or ~azure.mgmt.cosmosdb.models.ServiceType """ - super(ServiceResourceCreateUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.instance_size = instance_size self.instance_count = instance_count self.service_type = service_type -class ServiceResourceListResult(msrest.serialization.Model): +class ServiceResourceListResult(_serialization.Model): """The List operation response, that contains the Service Resource and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -12304,24 +11664,20 @@ class ServiceResourceListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ServiceResource]'}, + "value": {"key": "value", "type": "[ServiceResource]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ServiceResourceListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class SpatialSpec(msrest.serialization.Model): +class SpatialSpec(_serialization.Model): """SpatialSpec. :ivar path: The path for which the indexing behavior applies to. Index paths typically start @@ -12332,16 +11688,12 @@ class SpatialSpec(msrest.serialization.Model): """ _attribute_map = { - 'path': {'key': 'path', 'type': 'str'}, - 'types': {'key': 'types', 'type': '[str]'}, + "path": {"key": "path", "type": "str"}, + "types": {"key": "types", "type": "[str]"}, } def __init__( - self, - *, - path: Optional[str] = None, - types: Optional[List[Union[str, "_models.SpatialType"]]] = None, - **kwargs + self, *, path: Optional[str] = None, types: Optional[List[Union[str, "_models.SpatialType"]]] = None, **kwargs ): """ :keyword path: The path for which the indexing behavior applies to. Index paths typically start @@ -12350,7 +11702,7 @@ def __init__( :keyword types: List of path's spatial type. :paramtype types: list[str or ~azure.mgmt.cosmosdb.models.SpatialType] """ - super(SpatialSpec, self).__init__(**kwargs) + super().__init__(**kwargs) self.path = path self.types = types @@ -12370,16 +11722,16 @@ class SqlContainerCreateUpdateParameters(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :ivar resource: Required. The standard JSON format of a container. + :ivar resource: The standard JSON format of a container. Required. :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. @@ -12387,21 +11739,21 @@ class SqlContainerCreateUpdateParameters(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'SqlContainerResource'}, - 'options': {'key': 'properties.options', 'type': 'CreateUpdateOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "SqlContainerResource"}, + "options": {"key": "properties.options", "type": "CreateUpdateOptions"}, } def __init__( @@ -12417,22 +11769,22 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :keyword resource: Required. The standard JSON format of a container. + :keyword resource: The standard JSON format of a container. Required. :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, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options @@ -12448,8 +11800,8 @@ class SqlContainerGetPropertiesOptions(OptionsResource): """ _attribute_map = { - 'throughput': {'key': 'throughput', 'type': 'int'}, - 'autoscale_settings': {'key': 'autoscaleSettings', 'type': 'AutoscaleSettings'}, + "throughput": {"key": "throughput", "type": "int"}, + "autoscale_settings": {"key": "autoscaleSettings", "type": "AutoscaleSettings"}, } def __init__( @@ -12466,17 +11818,26 @@ def __init__( :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) + super().__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) -class SqlContainerGetPropertiesResource(ExtendedResourceProperties, SqlContainerResource): +class SqlContainerGetPropertiesResource( + SqlContainerResource, ExtendedResourceProperties +): # pylint: disable=too-many-instance-attributes """SqlContainerGetPropertiesResource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Name of the Cosmos DB SQL container. + :ivar rid: A system generated property. A unique identifier. + :vartype rid: str + :ivar ts: A system generated property that denotes the last updated timestamp of the resource. + :vartype ts: float + :ivar etag: A system generated property representing the resource etag required for optimistic + concurrency control. + :vartype etag: str + :ivar id: Name of the Cosmos DB SQL container. Required. :vartype id: str :ivar indexing_policy: The configuration of the indexing policy. By default, the indexing is automatic for all document paths within the container. @@ -12494,41 +11855,34 @@ class SqlContainerGetPropertiesResource(ExtendedResourceProperties, SqlContainer :ivar client_encryption_policy: The client encryption policy for the container. :vartype client_encryption_policy: ~azure.mgmt.cosmosdb.models.ClientEncryptionPolicy :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. - :vartype ts: float - :ivar etag: A system generated property representing the resource etag required for optimistic - concurrency control. - :vartype etag: str + :vartype analytical_storage_ttl: int """ _validation = { - 'id': {'required': True}, - 'rid': {'readonly': True}, - 'ts': {'readonly': True}, - 'etag': {'readonly': True}, + "rid": {"readonly": True}, + "ts": {"readonly": True}, + "etag": {"readonly": True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'indexing_policy': {'key': 'indexingPolicy', 'type': 'IndexingPolicy'}, - 'partition_key': {'key': 'partitionKey', 'type': 'ContainerPartitionKey'}, - 'default_ttl': {'key': 'defaultTtl', 'type': 'int'}, - 'unique_key_policy': {'key': 'uniqueKeyPolicy', 'type': 'UniqueKeyPolicy'}, - 'conflict_resolution_policy': {'key': 'conflictResolutionPolicy', 'type': 'ConflictResolutionPolicy'}, - 'client_encryption_policy': {'key': 'clientEncryptionPolicy', 'type': 'ClientEncryptionPolicy'}, - 'analytical_storage_ttl': {'key': 'analyticalStorageTtl', 'type': 'long'}, - 'rid': {'key': '_rid', 'type': 'str'}, - 'ts': {'key': '_ts', 'type': 'float'}, - 'etag': {'key': '_etag', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "indexing_policy": {"key": "indexingPolicy", "type": "IndexingPolicy"}, + "partition_key": {"key": "partitionKey", "type": "ContainerPartitionKey"}, + "default_ttl": {"key": "defaultTtl", "type": "int"}, + "unique_key_policy": {"key": "uniqueKeyPolicy", "type": "UniqueKeyPolicy"}, + "conflict_resolution_policy": {"key": "conflictResolutionPolicy", "type": "ConflictResolutionPolicy"}, + "client_encryption_policy": {"key": "clientEncryptionPolicy", "type": "ClientEncryptionPolicy"}, + "analytical_storage_ttl": {"key": "analyticalStorageTtl", "type": "int"}, } def __init__( self, *, - id: str, + id: str, # pylint: disable=redefined-builtin indexing_policy: Optional["_models.IndexingPolicy"] = None, partition_key: Optional["_models.ContainerPartitionKey"] = None, default_ttl: Optional[int] = None, @@ -12539,7 +11893,7 @@ def __init__( **kwargs ): """ - :keyword id: Required. Name of the Cosmos DB SQL container. + :keyword id: Name of the Cosmos DB SQL container. Required. :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. @@ -12557,9 +11911,22 @@ def __init__( :keyword client_encryption_policy: The client encryption policy for the container. :paramtype client_encryption_policy: ~azure.mgmt.cosmosdb.models.ClientEncryptionPolicy :keyword analytical_storage_ttl: Analytical TTL. - :paramtype analytical_storage_ttl: long + :paramtype analytical_storage_ttl: int """ - 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, client_encryption_policy=client_encryption_policy, analytical_storage_ttl=analytical_storage_ttl, **kwargs) + super().__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, + client_encryption_policy=client_encryption_policy, + analytical_storage_ttl=analytical_storage_ttl, + **kwargs + ) + self.rid = None + self.ts = None + self.etag = None self.id = id self.indexing_policy = indexing_policy self.partition_key = partition_key @@ -12568,9 +11935,6 @@ def __init__( self.conflict_resolution_policy = conflict_resolution_policy self.client_encryption_policy = client_encryption_policy self.analytical_storage_ttl = analytical_storage_ttl - self.rid = None - self.ts = None - self.etag = None class SqlContainerGetResults(ARMResourceProperties): @@ -12586,12 +11950,12 @@ class SqlContainerGetResults(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -12602,20 +11966,20 @@ class SqlContainerGetResults(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'SqlContainerGetPropertiesResource'}, - 'options': {'key': 'properties.options', 'type': 'SqlContainerGetPropertiesOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "SqlContainerGetPropertiesResource"}, + "options": {"key": "properties.options", "type": "SqlContainerGetPropertiesOptions"}, } def __init__( @@ -12631,12 +11995,12 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -12645,12 +12009,12 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.SqlContainerGetPropertiesOptions """ - super(SqlContainerGetResults, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options -class SqlContainerListResult(msrest.serialization.Model): +class SqlContainerListResult(_serialization.Model): """The List operation response, that contains the containers and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -12660,20 +12024,16 @@ class SqlContainerListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SqlContainerGetResults]'}, + "value": {"key": "value", "type": "[SqlContainerGetResults]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SqlContainerListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -12692,16 +12052,16 @@ class SqlDatabaseCreateUpdateParameters(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :ivar resource: Required. The standard JSON format of a SQL database. + :ivar resource: The standard JSON format of a SQL database. Required. :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. @@ -12709,21 +12069,21 @@ class SqlDatabaseCreateUpdateParameters(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'SqlDatabaseResource'}, - 'options': {'key': 'properties.options', 'type': 'CreateUpdateOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "SqlDatabaseResource"}, + "options": {"key": "properties.options", "type": "CreateUpdateOptions"}, } def __init__( @@ -12739,22 +12099,22 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :keyword resource: Required. The standard JSON format of a SQL database. + :keyword resource: The standard JSON format of a SQL database. Required. :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, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options @@ -12770,8 +12130,8 @@ class SqlDatabaseGetPropertiesOptions(OptionsResource): """ _attribute_map = { - 'throughput': {'key': 'throughput', 'type': 'int'}, - 'autoscale_settings': {'key': 'autoscaleSettings', 'type': 'AutoscaleSettings'}, + "throughput": {"key": "throughput", "type": "int"}, + "autoscale_settings": {"key": "autoscaleSettings", "type": "AutoscaleSettings"}, } def __init__( @@ -12788,7 +12148,7 @@ def __init__( :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) + super().__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) class SqlDatabaseGetPropertiesResource(SqlDatabaseResource, ExtendedResourceProperties): @@ -12805,7 +12165,7 @@ class SqlDatabaseGetPropertiesResource(SqlDatabaseResource, ExtendedResourceProp :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str - :ivar id: Required. Name of the Cosmos DB SQL database. + :ivar id: Name of the Cosmos DB SQL database. Required. :vartype id: str :ivar colls: A system generated property that specified the addressable path of the collections resource. @@ -12816,31 +12176,31 @@ class SqlDatabaseGetPropertiesResource(SqlDatabaseResource, ExtendedResourceProp """ _validation = { - 'rid': {'readonly': True}, - 'ts': {'readonly': True}, - 'etag': {'readonly': True}, - 'id': {'required': True}, + "rid": {"readonly": True}, + "ts": {"readonly": True}, + "etag": {"readonly": True}, + "id": {"required": True}, } _attribute_map = { - 'rid': {'key': '_rid', 'type': 'str'}, - 'ts': {'key': '_ts', 'type': 'float'}, - 'etag': {'key': '_etag', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'colls': {'key': '_colls', 'type': 'str'}, - 'users': {'key': '_users', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "colls": {"key": "_colls", "type": "str"}, + "users": {"key": "_users", "type": "str"}, } def __init__( self, *, - id: str, + id: str, # pylint: disable=redefined-builtin colls: Optional[str] = None, users: Optional[str] = None, **kwargs ): """ - :keyword id: Required. Name of the Cosmos DB SQL database. + :keyword id: Name of the Cosmos DB SQL database. Required. :paramtype id: str :keyword colls: A system generated property that specified the addressable path of the collections resource. @@ -12849,7 +12209,7 @@ def __init__( resource. :paramtype users: str """ - super(SqlDatabaseGetPropertiesResource, self).__init__(id=id, **kwargs) + super().__init__(id=id, **kwargs) self.rid = None self.ts = None self.etag = None @@ -12871,12 +12231,12 @@ class SqlDatabaseGetResults(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -12887,20 +12247,20 @@ class SqlDatabaseGetResults(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'SqlDatabaseGetPropertiesResource'}, - 'options': {'key': 'properties.options', 'type': 'SqlDatabaseGetPropertiesOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "SqlDatabaseGetPropertiesResource"}, + "options": {"key": "properties.options", "type": "SqlDatabaseGetPropertiesOptions"}, } def __init__( @@ -12916,12 +12276,12 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -12930,12 +12290,12 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.SqlDatabaseGetPropertiesOptions """ - super(SqlDatabaseGetResults, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options -class SqlDatabaseListResult(msrest.serialization.Model): +class SqlDatabaseListResult(_serialization.Model): """The List operation response, that contains the SQL databases and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -12945,20 +12305,16 @@ class SqlDatabaseListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SqlDatabaseGetResults]'}, + "value": {"key": "value", "type": "[SqlDatabaseGetResults]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SqlDatabaseListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -12972,37 +12328,33 @@ class SqlDedicatedGatewayRegionalServiceResource(RegionalServiceResource): :ivar location: The location name. :vartype location: str :ivar status: Describes the status of a service. Known values are: "Creating", "Running", - "Updating", "Deleting", "Error", "Stopped". + "Updating", "Deleting", "Error", and "Stopped". :vartype status: str or ~azure.mgmt.cosmosdb.models.ServiceStatus :ivar sql_dedicated_gateway_endpoint: The regional endpoint for SqlDedicatedGateway. :vartype sql_dedicated_gateway_endpoint: str """ _validation = { - 'name': {'readonly': True}, - 'location': {'readonly': True}, - 'status': {'readonly': True}, - 'sql_dedicated_gateway_endpoint': {'readonly': True}, + "name": {"readonly": True}, + "location": {"readonly": True}, + "status": {"readonly": True}, + "sql_dedicated_gateway_endpoint": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'sql_dedicated_gateway_endpoint': {'key': 'sqlDedicatedGatewayEndpoint', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "sql_dedicated_gateway_endpoint": {"key": "sqlDedicatedGatewayEndpoint", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SqlDedicatedGatewayRegionalServiceResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.sql_dedicated_gateway_endpoint = None -class SqlDedicatedGatewayServiceResource(msrest.serialization.Model): +class SqlDedicatedGatewayServiceResource(_serialization.Model): """Describes the service response property for SqlDedicatedGateway. :ivar properties: Properties for SqlDedicatedGatewayServiceResource. @@ -13010,20 +12362,17 @@ class SqlDedicatedGatewayServiceResource(msrest.serialization.Model): """ _attribute_map = { - 'properties': {'key': 'properties', 'type': 'SqlDedicatedGatewayServiceResourceProperties'}, + "properties": {"key": "properties", "type": "SqlDedicatedGatewayServiceResourceProperties"}, } def __init__( - self, - *, - properties: Optional["_models.SqlDedicatedGatewayServiceResourceProperties"] = None, - **kwargs + self, *, properties: Optional["_models.SqlDedicatedGatewayServiceResourceProperties"] = None, **kwargs ): """ :keyword properties: Properties for SqlDedicatedGatewayServiceResource. :paramtype properties: ~azure.mgmt.cosmosdb.models.SqlDedicatedGatewayServiceResourceProperties """ - super(SqlDedicatedGatewayServiceResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties @@ -13036,20 +12385,19 @@ class SqlDedicatedGatewayServiceResourceProperties(ServiceResourceProperties): :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] + :vartype additional_properties: dict[str, JSON] :ivar creation_time: Time of the last state change (ISO-8601 format). :vartype creation_time: ~datetime.datetime :ivar instance_size: Instance type for the service. Known values are: "Cosmos.D4s", - "Cosmos.D8s", "Cosmos.D16s". + "Cosmos.D8s", and "Cosmos.D16s". :vartype instance_size: str or ~azure.mgmt.cosmosdb.models.ServiceSize :ivar instance_count: Instance count for the service. :vartype instance_count: int - :ivar service_type: Required. ServiceType for the service.Constant filled by server. Known - values are: "SqlDedicatedGateway", "DataTransfer", "GraphAPICompute", - "MaterializedViewsBuilder". + :ivar service_type: ServiceType for the service. Required. Known values are: + "SqlDedicatedGateway", "DataTransfer", "GraphAPICompute", and "MaterializedViewsBuilder". :vartype service_type: str or ~azure.mgmt.cosmosdb.models.ServiceType :ivar status: Describes the status of a service. Known values are: "Creating", "Running", - "Updating", "Deleting", "Error", "Stopped". + "Updating", "Deleting", "Error", and "Stopped". :vartype status: str or ~azure.mgmt.cosmosdb.models.ServiceStatus :ivar sql_dedicated_gateway_endpoint: SqlDedicatedGateway endpoint for the service. :vartype sql_dedicated_gateway_endpoint: str @@ -13059,28 +12407,28 @@ class SqlDedicatedGatewayServiceResourceProperties(ServiceResourceProperties): """ _validation = { - 'creation_time': {'readonly': True}, - 'instance_count': {'minimum': 0}, - 'service_type': {'required': True}, - 'status': {'readonly': True}, - 'locations': {'readonly': True}, + "creation_time": {"readonly": True}, + "instance_count": {"minimum": 0}, + "service_type": {"required": True}, + "status": {"readonly": True}, + "locations": {"readonly": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, - 'instance_size': {'key': 'instanceSize', 'type': 'str'}, - 'instance_count': {'key': 'instanceCount', 'type': 'int'}, - 'service_type': {'key': 'serviceType', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'sql_dedicated_gateway_endpoint': {'key': 'sqlDedicatedGatewayEndpoint', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[SqlDedicatedGatewayRegionalServiceResource]'}, + "additional_properties": {"key": "", "type": "{object}"}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + "instance_size": {"key": "instanceSize", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, + "service_type": {"key": "serviceType", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "sql_dedicated_gateway_endpoint": {"key": "sqlDedicatedGatewayEndpoint", "type": "str"}, + "locations": {"key": "locations", "type": "[SqlDedicatedGatewayRegionalServiceResource]"}, } def __init__( self, *, - additional_properties: Optional[Dict[str, Any]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, instance_size: Optional[Union[str, "_models.ServiceSize"]] = None, instance_count: Optional[int] = None, sql_dedicated_gateway_endpoint: Optional[str] = None, @@ -13089,22 +12437,27 @@ def __init__( """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] :keyword instance_size: Instance type for the service. Known values are: "Cosmos.D4s", - "Cosmos.D8s", "Cosmos.D16s". + "Cosmos.D8s", and "Cosmos.D16s". :paramtype instance_size: str or ~azure.mgmt.cosmosdb.models.ServiceSize :keyword instance_count: Instance count for the service. :paramtype instance_count: int :keyword sql_dedicated_gateway_endpoint: SqlDedicatedGateway endpoint for the service. :paramtype sql_dedicated_gateway_endpoint: str """ - super(SqlDedicatedGatewayServiceResourceProperties, self).__init__(additional_properties=additional_properties, instance_size=instance_size, instance_count=instance_count, **kwargs) - self.service_type = 'SqlDedicatedGateway' # type: str + super().__init__( + additional_properties=additional_properties, + instance_size=instance_size, + instance_count=instance_count, + **kwargs + ) + self.service_type = "SqlDedicatedGateway" # type: str self.sql_dedicated_gateway_endpoint = sql_dedicated_gateway_endpoint self.locations = None -class SqlRoleAssignmentCreateUpdateParameters(msrest.serialization.Model): +class SqlRoleAssignmentCreateUpdateParameters(_serialization.Model): """Parameters to create and update an Azure Cosmos DB SQL Role Assignment. :ivar role_definition_id: The unique identifier for the associated Role Definition. @@ -13119,9 +12472,9 @@ class SqlRoleAssignmentCreateUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, + "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "principal_id": {"key": "properties.principalId", "type": "str"}, } def __init__( @@ -13143,7 +12496,7 @@ def __init__( inferred using the tenant associated with the subscription. :paramtype principal_id: str """ - super(SqlRoleAssignmentCreateUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.role_definition_id = role_definition_id self.scope = scope self.principal_id = principal_id @@ -13172,18 +12525,18 @@ class SqlRoleAssignmentGetResults(ARMProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "role_definition_id": {"key": "properties.roleDefinitionId", "type": "str"}, + "scope": {"key": "properties.scope", "type": "str"}, + "principal_id": {"key": "properties.principalId", "type": "str"}, } def __init__( @@ -13205,13 +12558,13 @@ def __init__( inferred using the tenant associated with the subscription. :paramtype principal_id: str """ - super(SqlRoleAssignmentGetResults, self).__init__(**kwargs) + super().__init__(**kwargs) self.role_definition_id = role_definition_id self.scope = scope self.principal_id = principal_id -class SqlRoleAssignmentListResult(msrest.serialization.Model): +class SqlRoleAssignmentListResult(_serialization.Model): """The relevant Role Assignments. Variables are only populated by the server, and will be ignored when sending a request. @@ -13221,31 +12574,27 @@ class SqlRoleAssignmentListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SqlRoleAssignmentGetResults]'}, + "value": {"key": "value", "type": "[SqlRoleAssignmentGetResults]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SqlRoleAssignmentListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class SqlRoleDefinitionCreateUpdateParameters(msrest.serialization.Model): +class SqlRoleDefinitionCreateUpdateParameters(_serialization.Model): """Parameters to create and update an Azure Cosmos DB SQL Role Definition. :ivar role_name: A user-friendly name for the Role Definition. Must be unique for the database account. :vartype role_name: str :ivar type: Indicates whether the Role Definition was built-in or user created. Known values - are: "BuiltInRole", "CustomRole". + are: "BuiltInRole" and "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 @@ -13258,10 +12607,10 @@ class SqlRoleDefinitionCreateUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'role_name': {'key': 'properties.roleName', 'type': 'str'}, - 'type': {'key': 'properties.type', 'type': 'str'}, - 'assignable_scopes': {'key': 'properties.assignableScopes', 'type': '[str]'}, - 'permissions': {'key': 'properties.permissions', 'type': '[Permission]'}, + "role_name": {"key": "properties.roleName", "type": "str"}, + "type": {"key": "properties.type", "type": "str"}, + "assignable_scopes": {"key": "properties.assignableScopes", "type": "[str]"}, + "permissions": {"key": "properties.permissions", "type": "[Permission]"}, } def __init__( @@ -13278,7 +12627,7 @@ def __init__( database account. :paramtype role_name: str :keyword type: Indicates whether the Role Definition was built-in or user created. Known values - are: "BuiltInRole", "CustomRole". + are: "BuiltInRole" and "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 @@ -13289,7 +12638,7 @@ def __init__( :keyword permissions: The set of operations allowed through this Role Definition. :paramtype permissions: list[~azure.mgmt.cosmosdb.models.Permission] """ - super(SqlRoleDefinitionCreateUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.role_name = role_name self.type = type self.assignable_scopes = assignable_scopes @@ -13311,7 +12660,7 @@ class SqlRoleDefinitionGetResults(ARMProxyResource): account. :vartype role_name: str :ivar type_properties_type: Indicates whether the Role Definition was built-in or user created. - Known values are: "BuiltInRole", "CustomRole". + Known values are: "BuiltInRole" and "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 @@ -13324,19 +12673,19 @@ class SqlRoleDefinitionGetResults(ARMProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'role_name': {'key': 'properties.roleName', 'type': 'str'}, - 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, - 'assignable_scopes': {'key': 'properties.assignableScopes', 'type': '[str]'}, - 'permissions': {'key': 'properties.permissions', 'type': '[Permission]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "role_name": {"key": "properties.roleName", "type": "str"}, + "type_properties_type": {"key": "properties.type", "type": "str"}, + "assignable_scopes": {"key": "properties.assignableScopes", "type": "[str]"}, + "permissions": {"key": "properties.permissions", "type": "[Permission]"}, } def __init__( @@ -13353,7 +12702,7 @@ def __init__( database account. :paramtype role_name: str :keyword type_properties_type: Indicates whether the Role Definition was built-in or user - created. Known values are: "BuiltInRole", "CustomRole". + created. Known values are: "BuiltInRole" and "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 @@ -13364,14 +12713,14 @@ def __init__( :keyword permissions: The set of operations allowed through this Role Definition. :paramtype permissions: list[~azure.mgmt.cosmosdb.models.Permission] """ - super(SqlRoleDefinitionGetResults, self).__init__(**kwargs) + super().__init__(**kwargs) self.role_name = role_name self.type_properties_type = type_properties_type self.assignable_scopes = assignable_scopes self.permissions = permissions -class SqlRoleDefinitionListResult(msrest.serialization.Model): +class SqlRoleDefinitionListResult(_serialization.Model): """The relevant Role Definitions. Variables are only populated by the server, and will be ignored when sending a request. @@ -13381,20 +12730,16 @@ class SqlRoleDefinitionListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SqlRoleDefinitionGetResults]'}, + "value": {"key": "value", "type": "[SqlRoleDefinitionGetResults]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SqlRoleDefinitionListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -13413,16 +12758,16 @@ class SqlStoredProcedureCreateUpdateParameters(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :ivar resource: Required. The standard JSON format of a storedProcedure. + :ivar resource: The standard JSON format of a storedProcedure. Required. :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. @@ -13430,21 +12775,21 @@ class SqlStoredProcedureCreateUpdateParameters(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'SqlStoredProcedureResource'}, - 'options': {'key': 'properties.options', 'type': 'CreateUpdateOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "SqlStoredProcedureResource"}, + "options": {"key": "properties.options", "type": "CreateUpdateOptions"}, } def __init__( @@ -13460,75 +12805,65 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :keyword resource: Required. The standard JSON format of a storedProcedure. + :keyword resource: The standard JSON format of a storedProcedure. Required. :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, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options -class SqlStoredProcedureResource(msrest.serialization.Model): +class SqlStoredProcedureResource(_serialization.Model): """Cosmos DB SQL storedProcedure resource object. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Name of the Cosmos DB SQL storedProcedure. + :ivar id: Name of the Cosmos DB SQL storedProcedure. Required. :vartype id: str :ivar body: Body of the Stored Procedure. :vartype body: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'body': {'key': 'body', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "body": {"key": "body", "type": "str"}, } - def __init__( - self, - *, - id: str, - body: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: str, body: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Name of the Cosmos DB SQL storedProcedure. + :keyword id: Name of the Cosmos DB SQL storedProcedure. Required. :paramtype id: str :keyword body: Body of the Stored Procedure. :paramtype body: str """ - super(SqlStoredProcedureResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.body = body -class SqlStoredProcedureGetPropertiesResource(ExtendedResourceProperties, SqlStoredProcedureResource): +class SqlStoredProcedureGetPropertiesResource(SqlStoredProcedureResource, ExtendedResourceProperties): """SqlStoredProcedureGetPropertiesResource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :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. @@ -13536,42 +12871,40 @@ class SqlStoredProcedureGetPropertiesResource(ExtendedResourceProperties, SqlSto :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str + :ivar id: Name of the Cosmos DB SQL storedProcedure. Required. + :vartype id: str + :ivar body: Body of the Stored Procedure. + :vartype body: str """ _validation = { - 'id': {'required': True}, - 'rid': {'readonly': True}, - 'ts': {'readonly': True}, - 'etag': {'readonly': True}, + "rid": {"readonly": True}, + "ts": {"readonly": True}, + "etag": {"readonly": True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'body': {'key': 'body', 'type': 'str'}, - 'rid': {'key': '_rid', 'type': 'str'}, - 'ts': {'key': '_ts', 'type': 'float'}, - 'etag': {'key': '_etag', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "body": {"key": "body", "type": "str"}, } - def __init__( - self, - *, - id: str, - body: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: str, body: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Name of the Cosmos DB SQL storedProcedure. + :keyword id: Name of the Cosmos DB SQL storedProcedure. Required. :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 + super().__init__(id=id, body=body, **kwargs) self.rid = None self.ts = None self.etag = None + self.id = id + self.body = body class SqlStoredProcedureGetResults(ARMResourceProperties): @@ -13587,12 +12920,12 @@ class SqlStoredProcedureGetResults(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -13601,19 +12934,19 @@ class SqlStoredProcedureGetResults(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'SqlStoredProcedureGetPropertiesResource'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "SqlStoredProcedureGetPropertiesResource"}, } def __init__( @@ -13628,23 +12961,23 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword resource: :paramtype resource: ~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetPropertiesResource """ - super(SqlStoredProcedureGetResults, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource -class SqlStoredProcedureListResult(msrest.serialization.Model): +class SqlStoredProcedureListResult(_serialization.Model): """The List operation response, that contains the storedProcedures and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -13654,20 +12987,16 @@ class SqlStoredProcedureListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SqlStoredProcedureGetResults]'}, + "value": {"key": "value", "type": "[SqlStoredProcedureGetResults]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SqlStoredProcedureListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -13686,16 +13015,16 @@ class SqlTriggerCreateUpdateParameters(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :ivar resource: Required. The standard JSON format of a trigger. + :ivar resource: The standard JSON format of a trigger. Required. :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. @@ -13703,21 +13032,21 @@ class SqlTriggerCreateUpdateParameters(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'SqlTriggerResource'}, - 'options': {'key': 'properties.options', 'type': 'CreateUpdateOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "SqlTriggerResource"}, + "options": {"key": "properties.options", "type": "CreateUpdateOptions"}, } def __init__( @@ -13733,96 +13062,87 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :keyword resource: Required. The standard JSON format of a trigger. + :keyword resource: The standard JSON format of a trigger. Required. :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, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options -class SqlTriggerResource(msrest.serialization.Model): +class SqlTriggerResource(_serialization.Model): """Cosmos DB SQL trigger resource object. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Name of the Cosmos DB SQL trigger. + :ivar id: Name of the Cosmos DB SQL trigger. Required. :vartype id: str :ivar body: Body of the Trigger. :vartype body: str - :ivar trigger_type: Type of the Trigger. Known values are: "Pre", "Post". + :ivar trigger_type: Type of the Trigger. Known values are: "Pre" and "Post". :vartype trigger_type: str or ~azure.mgmt.cosmosdb.models.TriggerType :ivar trigger_operation: The operation the trigger is associated with. Known values are: "All", - "Create", "Update", "Delete", "Replace". + "Create", "Update", "Delete", and "Replace". :vartype trigger_operation: str or ~azure.mgmt.cosmosdb.models.TriggerOperation """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'body': {'key': 'body', 'type': 'str'}, - 'trigger_type': {'key': 'triggerType', 'type': 'str'}, - 'trigger_operation': {'key': 'triggerOperation', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "body": {"key": "body", "type": "str"}, + "trigger_type": {"key": "triggerType", "type": "str"}, + "trigger_operation": {"key": "triggerOperation", "type": "str"}, } def __init__( self, *, - id: str, + id: str, # pylint: disable=redefined-builtin body: Optional[str] = None, trigger_type: Optional[Union[str, "_models.TriggerType"]] = None, trigger_operation: Optional[Union[str, "_models.TriggerOperation"]] = None, **kwargs ): """ - :keyword id: Required. Name of the Cosmos DB SQL trigger. + :keyword id: Name of the Cosmos DB SQL trigger. Required. :paramtype id: str :keyword body: Body of the Trigger. :paramtype body: str - :keyword trigger_type: Type of the Trigger. Known values are: "Pre", "Post". + :keyword trigger_type: Type of the Trigger. Known values are: "Pre" and "Post". :paramtype trigger_type: str or ~azure.mgmt.cosmosdb.models.TriggerType :keyword trigger_operation: The operation the trigger is associated with. Known values are: - "All", "Create", "Update", "Delete", "Replace". + "All", "Create", "Update", "Delete", and "Replace". :paramtype trigger_operation: str or ~azure.mgmt.cosmosdb.models.TriggerOperation """ - super(SqlTriggerResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.body = body self.trigger_type = trigger_type self.trigger_operation = trigger_operation -class SqlTriggerGetPropertiesResource(ExtendedResourceProperties, SqlTriggerResource): +class SqlTriggerGetPropertiesResource(SqlTriggerResource, ExtendedResourceProperties): """SqlTriggerGetPropertiesResource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :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. Known values are: "Pre", "Post". - :vartype trigger_type: str or ~azure.mgmt.cosmosdb.models.TriggerType - :ivar trigger_operation: The operation the trigger is associated with. Known values are: "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. @@ -13830,53 +13150,62 @@ class SqlTriggerGetPropertiesResource(ExtendedResourceProperties, SqlTriggerReso :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str + :ivar id: Name of the Cosmos DB SQL trigger. Required. + :vartype id: str + :ivar body: Body of the Trigger. + :vartype body: str + :ivar trigger_type: Type of the Trigger. Known values are: "Pre" and "Post". + :vartype trigger_type: str or ~azure.mgmt.cosmosdb.models.TriggerType + :ivar trigger_operation: The operation the trigger is associated with. Known values are: "All", + "Create", "Update", "Delete", and "Replace". + :vartype trigger_operation: str or ~azure.mgmt.cosmosdb.models.TriggerOperation """ _validation = { - 'id': {'required': True}, - 'rid': {'readonly': True}, - 'ts': {'readonly': True}, - 'etag': {'readonly': True}, + "rid": {"readonly": True}, + "ts": {"readonly": True}, + "etag": {"readonly": True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'body': {'key': 'body', 'type': 'str'}, - 'trigger_type': {'key': 'triggerType', 'type': 'str'}, - 'trigger_operation': {'key': 'triggerOperation', 'type': 'str'}, - 'rid': {'key': '_rid', 'type': 'str'}, - 'ts': {'key': '_ts', 'type': 'float'}, - 'etag': {'key': '_etag', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "body": {"key": "body", "type": "str"}, + "trigger_type": {"key": "triggerType", "type": "str"}, + "trigger_operation": {"key": "triggerOperation", "type": "str"}, } def __init__( self, *, - id: str, + id: str, # pylint: disable=redefined-builtin body: Optional[str] = None, trigger_type: Optional[Union[str, "_models.TriggerType"]] = None, trigger_operation: Optional[Union[str, "_models.TriggerOperation"]] = None, **kwargs ): """ - :keyword id: Required. Name of the Cosmos DB SQL trigger. + :keyword id: Name of the Cosmos DB SQL trigger. Required. :paramtype id: str :keyword body: Body of the Trigger. :paramtype body: str - :keyword trigger_type: Type of the Trigger. Known values are: "Pre", "Post". + :keyword trigger_type: Type of the Trigger. Known values are: "Pre" and "Post". :paramtype trigger_type: str or ~azure.mgmt.cosmosdb.models.TriggerType :keyword trigger_operation: The operation the trigger is associated with. Known values are: - "All", "Create", "Update", "Delete", "Replace". + "All", "Create", "Update", "Delete", and "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) + super().__init__(id=id, body=body, trigger_type=trigger_type, trigger_operation=trigger_operation, **kwargs) + self.rid = None + self.ts = None + self.etag = None self.id = id self.body = body self.trigger_type = trigger_type self.trigger_operation = trigger_operation - self.rid = None - self.ts = None - self.etag = None class SqlTriggerGetResults(ARMResourceProperties): @@ -13892,12 +13221,12 @@ class SqlTriggerGetResults(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -13906,19 +13235,19 @@ class SqlTriggerGetResults(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'SqlTriggerGetPropertiesResource'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "SqlTriggerGetPropertiesResource"}, } def __init__( @@ -13933,23 +13262,23 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword resource: :paramtype resource: ~azure.mgmt.cosmosdb.models.SqlTriggerGetPropertiesResource """ - super(SqlTriggerGetResults, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource -class SqlTriggerListResult(msrest.serialization.Model): +class SqlTriggerListResult(_serialization.Model): """The List operation response, that contains the triggers and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -13959,20 +13288,16 @@ class SqlTriggerListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SqlTriggerGetResults]'}, + "value": {"key": "value", "type": "[SqlTriggerGetResults]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SqlTriggerListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -13991,16 +13316,16 @@ class SqlUserDefinedFunctionCreateUpdateParameters(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :ivar resource: Required. The standard JSON format of a userDefinedFunction. + :ivar resource: The standard JSON format of a userDefinedFunction. Required. :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. @@ -14008,21 +13333,21 @@ class SqlUserDefinedFunctionCreateUpdateParameters(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'SqlUserDefinedFunctionResource'}, - 'options': {'key': 'properties.options', 'type': 'CreateUpdateOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "SqlUserDefinedFunctionResource"}, + "options": {"key": "properties.options", "type": "CreateUpdateOptions"}, } def __init__( @@ -14038,75 +13363,65 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :keyword resource: Required. The standard JSON format of a userDefinedFunction. + :keyword resource: The standard JSON format of a userDefinedFunction. Required. :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, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options -class SqlUserDefinedFunctionResource(msrest.serialization.Model): +class SqlUserDefinedFunctionResource(_serialization.Model): """Cosmos DB SQL userDefinedFunction resource object. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Name of the Cosmos DB SQL userDefinedFunction. + :ivar id: Name of the Cosmos DB SQL userDefinedFunction. Required. :vartype id: str :ivar body: Body of the User Defined Function. :vartype body: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'body': {'key': 'body', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "body": {"key": "body", "type": "str"}, } - def __init__( - self, - *, - id: str, - body: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: str, body: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Name of the Cosmos DB SQL userDefinedFunction. + :keyword id: Name of the Cosmos DB SQL userDefinedFunction. Required. :paramtype id: str :keyword body: Body of the User Defined Function. :paramtype body: str """ - super(SqlUserDefinedFunctionResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.body = body -class SqlUserDefinedFunctionGetPropertiesResource(ExtendedResourceProperties, SqlUserDefinedFunctionResource): +class SqlUserDefinedFunctionGetPropertiesResource(SqlUserDefinedFunctionResource, ExtendedResourceProperties): """SqlUserDefinedFunctionGetPropertiesResource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :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. @@ -14114,42 +13429,40 @@ class SqlUserDefinedFunctionGetPropertiesResource(ExtendedResourceProperties, Sq :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str + :ivar id: Name of the Cosmos DB SQL userDefinedFunction. Required. + :vartype id: str + :ivar body: Body of the User Defined Function. + :vartype body: str """ _validation = { - 'id': {'required': True}, - 'rid': {'readonly': True}, - 'ts': {'readonly': True}, - 'etag': {'readonly': True}, + "rid": {"readonly": True}, + "ts": {"readonly": True}, + "etag": {"readonly": True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'body': {'key': 'body', 'type': 'str'}, - 'rid': {'key': '_rid', 'type': 'str'}, - 'ts': {'key': '_ts', 'type': 'float'}, - 'etag': {'key': '_etag', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "body": {"key": "body", "type": "str"}, } - def __init__( - self, - *, - id: str, - body: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: str, body: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Name of the Cosmos DB SQL userDefinedFunction. + :keyword id: Name of the Cosmos DB SQL userDefinedFunction. Required. :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 + super().__init__(id=id, body=body, **kwargs) self.rid = None self.ts = None self.etag = None + self.id = id + self.body = body class SqlUserDefinedFunctionGetResults(ARMResourceProperties): @@ -14165,12 +13478,12 @@ class SqlUserDefinedFunctionGetResults(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -14179,19 +13492,19 @@ class SqlUserDefinedFunctionGetResults(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'SqlUserDefinedFunctionGetPropertiesResource'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "SqlUserDefinedFunctionGetPropertiesResource"}, } def __init__( @@ -14206,23 +13519,23 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword resource: :paramtype resource: ~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionGetPropertiesResource """ - super(SqlUserDefinedFunctionGetResults, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource -class SqlUserDefinedFunctionListResult(msrest.serialization.Model): +class SqlUserDefinedFunctionListResult(_serialization.Model): """The List operation response, that contains the userDefinedFunctions and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -14232,49 +13545,45 @@ class SqlUserDefinedFunctionListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SqlUserDefinedFunctionGetResults]'}, + "value": {"key": "value", "type": "[SqlUserDefinedFunctionGetResults]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SqlUserDefinedFunctionListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. :ivar created_by: The identity that created the resource. :vartype created_by: str :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "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. Known values - are: "User", "Application", "ManagedIdentity", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :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 = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( @@ -14292,19 +13601,19 @@ def __init__( :keyword created_by: The identity that created the resource. :paramtype created_by: str :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", "Key". + "User", "Application", "ManagedIdentity", and "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. Known - values are: "User", "Application", "ManagedIdentity", "Key". + values are: "User", "Application", "ManagedIdentity", and "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) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -14328,16 +13637,16 @@ class TableCreateUpdateParameters(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :ivar resource: Required. The standard JSON format of a Table. + :ivar resource: The standard JSON format of a Table. Required. :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. @@ -14345,21 +13654,21 @@ class TableCreateUpdateParameters(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'TableResource'}, - 'options': {'key': 'properties.options', 'type': 'CreateUpdateOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "TableResource"}, + "options": {"key": "properties.options", "type": "CreateUpdateOptions"}, } def __init__( @@ -14375,22 +13684,22 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :keyword resource: Required. The standard JSON format of a Table. + :keyword resource: The standard JSON format of a Table. Required. :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, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options @@ -14406,8 +13715,8 @@ class TableGetPropertiesOptions(OptionsResource): """ _attribute_map = { - 'throughput': {'key': 'throughput', 'type': 'int'}, - 'autoscale_settings': {'key': 'autoscaleSettings', 'type': 'AutoscaleSettings'}, + "throughput": {"key": "throughput", "type": "int"}, + "autoscale_settings": {"key": "autoscaleSettings", "type": "AutoscaleSettings"}, } def __init__( @@ -14424,49 +13733,42 @@ def __init__( :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) + super().__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) -class TableResource(msrest.serialization.Model): +class TableResource(_serialization.Model): """Cosmos DB table resource object. All required parameters must be populated in order to send to Azure. - :ivar id: Required. Name of the Cosmos DB table. + :ivar id: Name of the Cosmos DB table. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Name of the Cosmos DB table. + :keyword id: Name of the Cosmos DB table. Required. :paramtype id: str """ - super(TableResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class TableGetPropertiesResource(ExtendedResourceProperties, TableResource): +class TableGetPropertiesResource(TableResource, ExtendedResourceProperties): """TableGetPropertiesResource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :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. @@ -14474,37 +13776,34 @@ class TableGetPropertiesResource(ExtendedResourceProperties, TableResource): :ivar etag: A system generated property representing the resource etag required for optimistic concurrency control. :vartype etag: str + :ivar id: Name of the Cosmos DB table. Required. + :vartype id: str """ _validation = { - 'id': {'required': True}, - 'rid': {'readonly': True}, - 'ts': {'readonly': True}, - 'etag': {'readonly': True}, + "rid": {"readonly": True}, + "ts": {"readonly": True}, + "etag": {"readonly": True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'rid': {'key': '_rid', 'type': 'str'}, - 'ts': {'key': '_ts', 'type': 'float'}, - 'etag': {'key': '_etag', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. Name of the Cosmos DB table. + :keyword id: Name of the Cosmos DB table. Required. :paramtype id: str """ - super(TableGetPropertiesResource, self).__init__(id=id, **kwargs) - self.id = id + super().__init__(id=id, **kwargs) self.rid = None self.ts = None self.etag = None + self.id = id class TableGetResults(ARMResourceProperties): @@ -14520,12 +13819,12 @@ class TableGetResults(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -14536,20 +13835,20 @@ class TableGetResults(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'TableGetPropertiesResource'}, - 'options': {'key': 'properties.options', 'type': 'TableGetPropertiesOptions'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "TableGetPropertiesResource"}, + "options": {"key": "properties.options", "type": "TableGetPropertiesOptions"}, } def __init__( @@ -14565,12 +13864,12 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -14579,12 +13878,12 @@ def __init__( :keyword options: :paramtype options: ~azure.mgmt.cosmosdb.models.TableGetPropertiesOptions """ - super(TableGetResults, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource self.options = options -class TableListResult(msrest.serialization.Model): +class TableListResult(_serialization.Model): """The List operation response, that contains the Table and their properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -14594,24 +13893,20 @@ class TableListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TableGetResults]'}, + "value": {"key": "value", "type": "[TableGetResults]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TableListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class ThroughputPolicyResource(msrest.serialization.Model): +class ThroughputPolicyResource(_serialization.Model): """Cosmos DB resource throughput policy. :ivar is_enabled: Determines whether the ThroughputPolicy is active or not. @@ -14622,17 +13917,11 @@ class ThroughputPolicyResource(msrest.serialization.Model): """ _attribute_map = { - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, - 'increment_percent': {'key': 'incrementPercent', 'type': 'int'}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "increment_percent": {"key": "incrementPercent", "type": "int"}, } - def __init__( - self, - *, - is_enabled: Optional[bool] = None, - increment_percent: Optional[int] = None, - **kwargs - ): + def __init__(self, *, is_enabled: Optional[bool] = None, increment_percent: Optional[int] = None, **kwargs): """ :keyword is_enabled: Determines whether the ThroughputPolicy is active or not. :paramtype is_enabled: bool @@ -14640,12 +13929,12 @@ def __init__( time throughput policy kicks in. :paramtype increment_percent: int """ - super(ThroughputPolicyResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_enabled = is_enabled self.increment_percent = increment_percent -class ThroughputSettingsResource(msrest.serialization.Model): +class ThroughputSettingsResource(_serialization.Model): """Cosmos DB resource throughput object. Either throughput is required or autoscaleSettings is required, but not both. Variables are only populated by the server, and will be ignored when sending a request. @@ -14663,15 +13952,15 @@ class ThroughputSettingsResource(msrest.serialization.Model): """ _validation = { - 'minimum_throughput': {'readonly': True}, - 'offer_replace_pending': {'readonly': True}, + "minimum_throughput": {"readonly": True}, + "offer_replace_pending": {"readonly": True}, } _attribute_map = { - 'throughput': {'key': 'throughput', 'type': 'int'}, - 'autoscale_settings': {'key': 'autoscaleSettings', 'type': 'AutoscaleSettingsResource'}, - 'minimum_throughput': {'key': 'minimumThroughput', 'type': 'str'}, - 'offer_replace_pending': {'key': 'offerReplacePending', 'type': 'str'}, + "throughput": {"key": "throughput", "type": "int"}, + "autoscale_settings": {"key": "autoscaleSettings", "type": "AutoscaleSettingsResource"}, + "minimum_throughput": {"key": "minimumThroughput", "type": "str"}, + "offer_replace_pending": {"key": "offerReplacePending", "type": "str"}, } def __init__( @@ -14689,18 +13978,25 @@ def __init__( required or autoscaleSettings is required, but not both. :paramtype autoscale_settings: ~azure.mgmt.cosmosdb.models.AutoscaleSettingsResource """ - super(ThroughputSettingsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.throughput = throughput self.autoscale_settings = autoscale_settings self.minimum_throughput = None self.offer_replace_pending = None -class ThroughputSettingsGetPropertiesResource(ExtendedResourceProperties, ThroughputSettingsResource): +class ThroughputSettingsGetPropertiesResource(ThroughputSettingsResource, ExtendedResourceProperties): """ThroughputSettingsGetPropertiesResource. Variables are only populated by the server, and will be ignored when sending a request. + :ivar rid: A system generated property. A unique identifier. + :vartype rid: str + :ivar ts: A system generated property that denotes the last updated timestamp of the resource. + :vartype ts: float + :ivar etag: A system generated property representing the resource etag required for optimistic + concurrency control. + :vartype etag: str :ivar throughput: Value of the Cosmos DB resource throughput. Either throughput is required or autoscaleSettings is required, but not both. :vartype throughput: int @@ -14711,31 +14007,24 @@ class ThroughputSettingsGetPropertiesResource(ExtendedResourceProperties, Throug :vartype minimum_throughput: str :ivar offer_replace_pending: The throughput replace is pending. :vartype offer_replace_pending: 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. - :vartype ts: float - :ivar etag: A system generated property representing the resource etag required for optimistic - concurrency control. - :vartype etag: str """ _validation = { - 'minimum_throughput': {'readonly': True}, - 'offer_replace_pending': {'readonly': True}, - 'rid': {'readonly': True}, - 'ts': {'readonly': True}, - 'etag': {'readonly': True}, + "rid": {"readonly": True}, + "ts": {"readonly": True}, + "etag": {"readonly": True}, + "minimum_throughput": {"readonly": True}, + "offer_replace_pending": {"readonly": True}, } _attribute_map = { - 'throughput': {'key': 'throughput', 'type': 'int'}, - 'autoscale_settings': {'key': 'autoscaleSettings', 'type': 'AutoscaleSettingsResource'}, - 'minimum_throughput': {'key': 'minimumThroughput', 'type': 'str'}, - 'offer_replace_pending': {'key': 'offerReplacePending', 'type': 'str'}, - 'rid': {'key': '_rid', 'type': 'str'}, - 'ts': {'key': '_ts', 'type': 'float'}, - 'etag': {'key': '_etag', 'type': 'str'}, + "rid": {"key": "_rid", "type": "str"}, + "ts": {"key": "_ts", "type": "float"}, + "etag": {"key": "_etag", "type": "str"}, + "throughput": {"key": "throughput", "type": "int"}, + "autoscale_settings": {"key": "autoscaleSettings", "type": "AutoscaleSettingsResource"}, + "minimum_throughput": {"key": "minimumThroughput", "type": "str"}, + "offer_replace_pending": {"key": "offerReplacePending", "type": "str"}, } def __init__( @@ -14753,14 +14042,14 @@ def __init__( 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) + super().__init__(throughput=throughput, autoscale_settings=autoscale_settings, **kwargs) + self.rid = None + self.ts = None + self.etag = None self.throughput = throughput self.autoscale_settings = autoscale_settings self.minimum_throughput = None self.offer_replace_pending = None - self.rid = None - self.ts = None - self.etag = None class ThroughputSettingsGetResults(ARMResourceProperties): @@ -14776,12 +14065,12 @@ class ThroughputSettingsGetResults(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity @@ -14790,19 +14079,19 @@ class ThroughputSettingsGetResults(ARMResourceProperties): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'ThroughputSettingsGetPropertiesResource'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "ThroughputSettingsGetPropertiesResource"}, } def __init__( @@ -14817,19 +14106,19 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity :keyword resource: :paramtype resource: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetPropertiesResource """ - super(ThroughputSettingsGetResults, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource @@ -14848,34 +14137,34 @@ class ThroughputSettingsUpdateParameters(ARMResourceProperties): :vartype type: 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". + :ivar tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :vartype tags: dict[str, str] :ivar identity: Identity for the resource. :vartype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :ivar resource: Required. The standard JSON format of a resource throughput. + :ivar resource: The standard JSON format of a resource throughput. Required. :vartype resource: ~azure.mgmt.cosmosdb.models.ThroughputSettingsResource """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'resource': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "resource": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'resource': {'key': 'properties.resource', 'type': 'ThroughputSettingsResource'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "resource": {"key": "properties.resource", "type": "ThroughputSettingsResource"}, } def __init__( @@ -14890,23 +14179,23 @@ def __init__( """ :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". + :keyword tags: Tags are a list of key-value pairs that describe the resource. These tags can be + used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can + be provided for a resource. Each tag must have a key no greater than 128 characters and value + no greater than 256 characters. For example, the default experience for a template type is set + with "defaultExperience": "Cassandra". Current "defaultExperience" values also include "Table", + "Graph", "DocumentDB", and "MongoDB". :paramtype tags: dict[str, str] :keyword identity: Identity for the resource. :paramtype identity: ~azure.mgmt.cosmosdb.models.ManagedServiceIdentity - :keyword resource: Required. The standard JSON format of a resource throughput. + :keyword resource: The standard JSON format of a resource throughput. Required. :paramtype resource: ~azure.mgmt.cosmosdb.models.ThroughputSettingsResource """ - super(ThroughputSettingsUpdateParameters, self).__init__(location=location, tags=tags, identity=identity, **kwargs) + super().__init__(location=location, tags=tags, identity=identity, **kwargs) self.resource = resource -class UniqueKey(msrest.serialization.Model): +class UniqueKey(_serialization.Model): """The unique key on that enforces uniqueness constraint on documents in the collection in the Azure Cosmos DB service. :ivar paths: List of paths must be unique for each document in the Azure Cosmos DB service. @@ -14914,24 +14203,19 @@ class UniqueKey(msrest.serialization.Model): """ _attribute_map = { - 'paths': {'key': 'paths', 'type': '[str]'}, + "paths": {"key": "paths", "type": "[str]"}, } - def __init__( - self, - *, - paths: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, 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) + super().__init__(**kwargs) self.paths = paths -class UniqueKeyPolicy(msrest.serialization.Model): +class UniqueKeyPolicy(_serialization.Model): """The unique key policy configuration for specifying uniqueness constraints on documents in the collection in the Azure Cosmos DB service. :ivar unique_keys: List of unique keys on that enforces uniqueness constraint on documents in @@ -14940,25 +14224,20 @@ class UniqueKeyPolicy(msrest.serialization.Model): """ _attribute_map = { - 'unique_keys': {'key': 'uniqueKeys', 'type': '[UniqueKey]'}, + "unique_keys": {"key": "uniqueKeys", "type": "[UniqueKey]"}, } - def __init__( - self, - *, - unique_keys: Optional[List["_models.UniqueKey"]] = None, - **kwargs - ): + def __init__(self, *, unique_keys: Optional[List["_models.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) + super().__init__(**kwargs) self.unique_keys = unique_keys -class UsagesResult(msrest.serialization.Model): +class UsagesResult(_serialization.Model): """The response to a list usage request. Variables are only populated by the server, and will be ignored when sending a request. @@ -14968,24 +14247,20 @@ class UsagesResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, + "value": {"key": "value", "type": "[Usage]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UsagesResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual Network ACL Rule object. :ivar id: Resource ID of a subnet, for example: @@ -14997,14 +14272,14 @@ class VirtualNetworkRule(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'ignore_missing_v_net_service_endpoint': {'key': 'ignoreMissingVNetServiceEndpoint', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "ignore_missing_v_net_service_endpoint": {"key": "ignoreMissingVNetServiceEndpoint", "type": "bool"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin ignore_missing_v_net_service_endpoint: Optional[bool] = None, **kwargs ): @@ -15016,6 +14291,6 @@ def __init__( has vnet service endpoint enabled. :paramtype ignore_missing_v_net_service_endpoint: bool """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__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/models/_patch.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/_patch.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/__init__.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/__init__.py index f93c597154b4..b9aee75bbc64 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/__init__.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/__init__.py @@ -49,46 +49,47 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'DatabaseAccountsOperations', - 'Operations', - 'DatabaseOperations', - 'CollectionOperations', - 'CollectionRegionOperations', - 'DatabaseAccountRegionOperations', - 'PercentileSourceTargetOperations', - 'PercentileTargetOperations', - 'PercentileOperations', - 'CollectionPartitionRegionOperations', - 'CollectionPartitionOperations', - 'PartitionKeyRangeIdOperations', - 'PartitionKeyRangeIdRegionOperations', - 'GraphResourcesOperations', - 'SqlResourcesOperations', - 'MongoDBResourcesOperations', - 'TableResourcesOperations', - 'CassandraResourcesOperations', - 'GremlinResourcesOperations', - 'LocationsOperations', - 'DataTransferJobsOperations', - 'CassandraClustersOperations', - 'CassandraDataCentersOperations', - 'NotebookWorkspacesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'RestorableDatabaseAccountsOperations', - 'RestorableSqlDatabasesOperations', - 'RestorableSqlContainersOperations', - 'RestorableSqlResourcesOperations', - 'RestorableMongodbDatabasesOperations', - 'RestorableMongodbCollectionsOperations', - 'RestorableMongodbResourcesOperations', - 'RestorableGremlinDatabasesOperations', - 'RestorableGremlinGraphsOperations', - 'RestorableGremlinResourcesOperations', - 'RestorableTablesOperations', - 'RestorableTableResourcesOperations', - 'ServiceOperations', + "DatabaseAccountsOperations", + "Operations", + "DatabaseOperations", + "CollectionOperations", + "CollectionRegionOperations", + "DatabaseAccountRegionOperations", + "PercentileSourceTargetOperations", + "PercentileTargetOperations", + "PercentileOperations", + "CollectionPartitionRegionOperations", + "CollectionPartitionOperations", + "PartitionKeyRangeIdOperations", + "PartitionKeyRangeIdRegionOperations", + "GraphResourcesOperations", + "SqlResourcesOperations", + "MongoDBResourcesOperations", + "TableResourcesOperations", + "CassandraResourcesOperations", + "GremlinResourcesOperations", + "LocationsOperations", + "DataTransferJobsOperations", + "CassandraClustersOperations", + "CassandraDataCentersOperations", + "NotebookWorkspacesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "RestorableDatabaseAccountsOperations", + "RestorableSqlDatabasesOperations", + "RestorableSqlContainersOperations", + "RestorableSqlResourcesOperations", + "RestorableMongodbDatabasesOperations", + "RestorableMongodbCollectionsOperations", + "RestorableMongodbResourcesOperations", + "RestorableGremlinDatabasesOperations", + "RestorableGremlinGraphsOperations", + "RestorableGremlinResourcesOperations", + "RestorableTablesOperations", + "RestorableTableResourcesOperations", + "ServiceOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() 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 964498e0d327..d017f252df61 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 @@ -6,11 +6,16 @@ # 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 Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,475 +27,429 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/cassandraClusters") + _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), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters", + ) # pylint: disable=line-too-long 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), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - **kwargs: Any -) -> HttpRequest: + +def build_get_request(resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}", + ) # pylint: disable=line-too-long 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]+)*$'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}", + ) # pylint: disable=line-too-long 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]+)*$'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_request_initial( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - *, - json: Optional[_models.ClusterResource] = None, - content: Any = None, - **kwargs: Any +def build_create_update_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}", + ) # pylint: disable=line-too-long 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]+)*$'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - *, - json: Optional[_models.ClusterResource] = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}", + ) # pylint: disable=line-too-long 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]+)*$'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_invoke_command_request_initial( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - *, - json: Optional[_models.CommandPostBody] = None, - content: Any = None, - **kwargs: Any + +def build_invoke_command_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/invokeCommand") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/invokeCommand", + ) # pylint: disable=line-too-long 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]+)*$'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_backups_request( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/backups") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/backups", + ) # pylint: disable=line-too-long 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]+)*$'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_backup_request( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - backup_id: str, - **kwargs: Any + resource_group_name: str, cluster_name: str, backup_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/backups/{backupId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/backups/{backupId}", + ) # pylint: disable=line-too-long 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]+)*$'), - "backupId": _SERIALIZER.url("backup_id", backup_id, 'str', max_length=15, min_length=1, pattern=r'^[0-9]+$'), + "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]+)*$" + ), + "backupId": _SERIALIZER.url("backup_id", backup_id, "str", max_length=15, min_length=1, pattern=r"^[0-9]+$"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deallocate_request_initial( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - **kwargs: Any +def build_deallocate_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/deallocate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/deallocate", + ) # pylint: disable=line-too-long 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]+)*$'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_start_request_initial( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + +def build_start_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/start") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/start", + ) # pylint: disable=line-too-long 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]+)*$'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_status_request( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/status") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/status", + ) # pylint: disable=line-too-long 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]+)*$'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class CassandraClustersOperations: """ @@ -511,36 +470,31 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable[_models.ListClusters]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ClusterResource"]: """List all managed Cassandra clusters in this subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListClusters or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.ListClusters] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ClusterResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.ClusterResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListClusters] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListClusters] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -548,14 +502,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -571,10 +522,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -584,45 +533,39 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/cassandraClusters"} # type: ignore + 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, - **kwargs: Any - ) -> Iterable[_models.ListClusters]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.ClusterResource"]: """List all managed Cassandra clusters in this resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :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 ListClusters or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.ListClusters] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ClusterResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.ClusterResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListClusters] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListClusters] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -630,15 +573,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -654,10 +593,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -667,48 +604,39 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> _models.ClusterResource: + def get(self, 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. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ClusterResource, or the result of cls(response) + :return: ClusterResource or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ClusterResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ClusterResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -716,50 +644,42 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ClusterResource', pipeline_response) + deserialized = self._deserialize("ClusterResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, cluster_name=cluster_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -767,10 +687,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -780,21 +699,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a managed Cassandra cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :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. @@ -806,85 +720,79 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore def _create_update_initial( - self, - resource_group_name: str, - cluster_name: str, - body: _models.ClusterResource, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, body: Union[_models.ClusterResource, IO], **kwargs: Any ) -> _models.ClusterResource: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ClusterResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterResource] - _json = self._serialize.body(body, 'ClusterResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = self._serialize.body(body, "ClusterResource") - request = build_create_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_initial.metadata['url'], + content=_content, + template_url=self._create_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -892,10 +800,9 @@ def _create_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -903,36 +810,112 @@ def _create_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ClusterResource', pipeline_response) + deserialized = self._deserialize("ClusterResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ClusterResource', pipeline_response) + deserialized = self._deserialize("ClusterResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore - + _create_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore - @distributed_trace + @overload def begin_create_update( self, resource_group_name: str, cluster_name: str, body: _models.ClusterResource, + *, + content_type: str = "application/json", **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. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str :param body: The properties specifying the desired state of the managed Cassandra cluster. + Required. :type body: ~azure.mgmt.cosmosdb.models.ClusterResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ClusterResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_update( + self, + resource_group_name: str, + cluster_name: str, + body: IO, + *, + content_type: str = "application/json", + **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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: The properties specifying the desired state of the managed Cassandra cluster. + Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ClusterResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_update( + self, resource_group_name: str, cluster_name: str, body: Union[_models.ClusterResource, IO], **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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: The properties specifying the desired state of the managed Cassandra cluster. Is + either a model type or a IO type. Required. + :type body: ~azure.mgmt.cosmosdb.models.ClusterResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -944,20 +927,17 @@ def begin_create_update( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ClusterResource] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -965,69 +945,66 @@ def begin_create_update( body=body, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ClusterResource', pipeline_response) + deserialized = self._deserialize("ClusterResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_create_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore def _update_initial( - self, - resource_group_name: str, - cluster_name: str, - body: _models.ClusterResource, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, body: Union[_models.ClusterResource, IO], **kwargs: Any ) -> _models.ClusterResource: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ClusterResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterResource] - _json = self._serialize.body(body, 'ClusterResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = self._serialize.body(body, "ClusterResource") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1035,10 +1012,9 @@ def _update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1046,35 +1022,107 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ClusterResource', pipeline_response) + deserialized = self._deserialize("ClusterResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ClusterResource', pipeline_response) + deserialized = self._deserialize("ClusterResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore - @distributed_trace + @overload def begin_update( self, resource_group_name: str, cluster_name: str, body: _models.ClusterResource, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :param body: Parameters to provide for specifying the managed Cassandra cluster. + :param body: Parameters to provide for specifying the managed Cassandra cluster. Required. :type body: ~azure.mgmt.cosmosdb.models.ClusterResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ClusterResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_name: str, + body: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: Parameters to provide for specifying the managed Cassandra cluster. Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ClusterResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, resource_group_name: str, cluster_name: str, body: Union[_models.ClusterResource, IO], **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. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: Parameters to provide for specifying the managed Cassandra cluster. Is either a + model type or a IO type. Required. + :type body: ~azure.mgmt.cosmosdb.models.ClusterResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -1086,20 +1134,17 @@ def begin_update( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ClusterResource] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, @@ -1107,69 +1152,66 @@ def begin_update( body=body, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ClusterResource', pipeline_response) + deserialized = self._deserialize("ClusterResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}"} # type: ignore def _invoke_command_initial( - self, - resource_group_name: str, - cluster_name: str, - body: _models.CommandPostBody, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, body: Union[_models.CommandPostBody, IO], **kwargs: Any ) -> _models.CommandOutput: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CommandOutput] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CommandOutput] - _json = self._serialize.body(body, 'CommandPostBody') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = self._serialize.body(body, "CommandPostBody") - request = build_invoke_command_request_initial( - subscription_id=self._config.subscription_id, + request = build_invoke_command_request( resource_group_name=resource_group_name, cluster_name=cluster_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._invoke_command_initial.metadata['url'], + content=_content, + template_url=self._invoke_command_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1177,42 +1219,46 @@ def _invoke_command_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CommandOutput', pipeline_response) + deserialized = self._deserialize("CommandOutput", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _invoke_command_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/invokeCommand"} # type: ignore - + _invoke_command_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/invokeCommand"} # type: ignore - @distributed_trace + @overload def begin_invoke_command( self, resource_group_name: str, cluster_name: str, body: _models.CommandPostBody, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.CommandOutput]: """Invoke a command like nodetool for cassandra maintenance. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :param body: Specification which command to run where. + :param body: Specification which command to run where. Required. :type body: ~azure.mgmt.cosmosdb.models.CommandPostBody + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :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 @@ -1224,20 +1270,84 @@ def begin_invoke_command( :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: + """ + + @overload + def begin_invoke_command( + self, + resource_group_name: str, + cluster_name: str, + body: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CommandOutput]: + """Invoke a command like nodetool for cassandra maintenance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: Specification which command to run where. Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CommandOutput] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_invoke_command( + self, resource_group_name: str, cluster_name: str, body: Union[_models.CommandPostBody, IO], **kwargs: Any + ) -> LROPoller[_models.CommandOutput]: + """Invoke a command like nodetool for cassandra maintenance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param body: Specification which command to run where. Is either a model type or a IO type. + Required. + :type body: ~azure.mgmt.cosmosdb.models.CommandPostBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CommandOutput] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CommandOutput] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CommandOutput] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._invoke_command_initial( # type: ignore resource_group_name=resource_group_name, @@ -1245,77 +1355,70 @@ def begin_invoke_command( body=body, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('CommandOutput', pipeline_response) + deserialized = self._deserialize("CommandOutput", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_invoke_command.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/invokeCommand"} # type: ignore @distributed_trace def list_backups( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> Iterable[_models.ListBackups]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.BackupResource"]: """List the backups of this cluster that are available to restore. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListBackups or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.ListBackups] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BackupResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.BackupResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBackups] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBackups] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_backups_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_backups.metadata['url'], + template_url=self.list_backups.metadata["url"], headers=_headers, params=_params, ) @@ -1323,16 +1426,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_backups_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1348,10 +1446,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1361,52 +1457,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_backups.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/backups"} # type: ignore + list_backups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/backups"} # type: ignore @distributed_trace def get_backup( - self, - resource_group_name: str, - cluster_name: str, - backup_id: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, backup_id: str, **kwargs: Any ) -> _models.BackupResource: """Get the properties of an individual backup of this cluster that is available to restore. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :param backup_id: Id of a restorable backup of a Cassandra cluster. + :param backup_id: Id of a restorable backup of a Cassandra cluster. Required. :type backup_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BackupResource, or the result of cls(response) + :return: BackupResource or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.BackupResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BackupResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupResource] - request = build_get_backup_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, backup_id=backup_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_backup.metadata['url'], + template_url=self.get_backup.metadata["url"], headers=_headers, params=_params, ) @@ -1414,50 +1502,42 @@ def get_backup( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BackupResource', pipeline_response) + deserialized = self._deserialize("BackupResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_backup.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/backups/{backupId}"} # type: ignore - + get_backup.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/backups/{backupId}"} # type: ignore def _deallocate_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_deallocate_request_initial( - subscription_id=self._config.subscription_id, + request = build_deallocate_request( resource_group_name=resource_group_name, cluster_name=cluster_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._deallocate_initial.metadata['url'], + template_url=self._deallocate_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1465,10 +1545,9 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202]: @@ -1478,23 +1557,18 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _deallocate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/deallocate"} # type: ignore - + _deallocate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/deallocate"} # type: ignore @distributed_trace - def begin_deallocate( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_deallocate(self, 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. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :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. @@ -1506,80 +1580,67 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_deallocate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/deallocate"} # type: ignore def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + request = build_start_request( resource_group_name=resource_group_name, cluster_name=cluster_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1587,10 +1648,9 @@ def _start_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202]: @@ -1600,23 +1660,18 @@ def _start_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/start"} # type: ignore @distributed_trace - def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_start(self, 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. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :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. @@ -1628,92 +1683,80 @@ def begin_start( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/start"} # type: ignore @distributed_trace def status( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + self, 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. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CassandraClusterPublicStatus, or the result of cls(response) + :return: CassandraClusterPublicStatus or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.CassandraClusterPublicStatus - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.CassandraClusterPublicStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CassandraClusterPublicStatus] - request = build_status_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.status.metadata['url'], + template_url=self.status.metadata["url"], headers=_headers, params=_params, ) @@ -1721,22 +1764,20 @@ def status( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CassandraClusterPublicStatus', pipeline_response) + deserialized = self._deserialize("CassandraClusterPublicStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - status.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/status"} # type: ignore - + 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 cae4873ccf7d..cc8d546e10bf 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 @@ -6,11 +6,16 @@ # 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 Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,220 +27,226 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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, - resource_group_name: str, - cluster_name: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_request(resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters", + ) # pylint: disable=line-too-long 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]+)*$'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - data_center_name: str, - **kwargs: Any + resource_group_name: str, cluster_name: str, data_center_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}", + ) # pylint: disable=line-too-long 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]+)*$'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - data_center_name: str, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, cluster_name: str, data_center_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}", + ) # pylint: disable=line-too-long 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]+)*$'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_create_update_request_initial( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - data_center_name: str, - *, - json: Optional[_models.DataCenterResource] = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_update_request( + resource_group_name: str, cluster_name: str, data_center_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}", + ) # pylint: disable=line-too-long 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]+)*$'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - 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: Optional[_models.DataCenterResource] = None, - content: Any = None, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, cluster_name: str, data_center_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}", + ) # pylint: disable=line-too-long 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]+)*$'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + class CassandraDataCentersOperations: """ @@ -256,44 +267,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> Iterable[_models.ListDataCenters]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.DataCenterResource"]: """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. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListDataCenters or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.ListDataCenters] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataCenterResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.DataCenterResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListDataCenters] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListDataCenters] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -301,16 +308,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -326,10 +328,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -339,52 +339,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - cluster_name: str, - data_center_name: str, - **kwargs: Any + self, 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. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :param data_center_name: Data center name in a managed Cassandra cluster. + :param data_center_name: Data center name in a managed Cassandra cluster. Required. :type data_center_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataCenterResource, or the result of cls(response) + :return: DataCenterResource or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DataCenterResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCenterResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCenterResource] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -392,52 +384,43 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataCenterResource', pipeline_response) + deserialized = self._deserialize("DataCenterResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - cluster_name: str, - data_center_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, data_center_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, cluster_name=cluster_name, data_center_name=data_center_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -445,10 +428,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -458,24 +440,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - cluster_name: str, - data_center_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, cluster_name: str, data_center_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete a managed Cassandra data center. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :param data_center_name: Data center name in a managed Cassandra cluster. + :param data_center_name: Data center name in a managed Cassandra cluster. Required. :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. @@ -487,88 +465,86 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, data_center_name=data_center_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, cluster_name: str, data_center_name: str, - body: _models.DataCenterResource, + body: Union[_models.DataCenterResource, IO], **kwargs: Any ) -> _models.DataCenterResource: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCenterResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCenterResource] - _json = self._serialize.body(body, 'DataCenterResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = self._serialize.body(body, "DataCenterResource") - request = build_create_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, data_center_name=data_center_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_initial.metadata['url'], + content=_content, + template_url=self._create_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -576,10 +552,9 @@ def _create_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -587,39 +562,84 @@ def _create_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataCenterResource', pipeline_response) + deserialized = self._deserialize("DataCenterResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataCenterResource', pipeline_response) + deserialized = self._deserialize("DataCenterResource", pipeline_response) if cls: 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 - + _create_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}"} # type: ignore - @distributed_trace + @overload def begin_create_update( self, resource_group_name: str, cluster_name: str, data_center_name: str, body: _models.DataCenterResource, + *, + content_type: str = "application/json", **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. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :param data_center_name: Data center name in a managed Cassandra cluster. + :param data_center_name: Data center name in a managed Cassandra cluster. Required. :type data_center_name: str - :param body: Parameters specifying the managed Cassandra data center. + :param body: Parameters specifying the managed Cassandra data center. Required. :type body: ~azure.mgmt.cosmosdb.models.DataCenterResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.DataCenterResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_update( + self, + resource_group_name: str, + cluster_name: str, + data_center_name: str, + body: IO, + *, + content_type: str = "application/json", + **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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param data_center_name: Data center name in a managed Cassandra cluster. Required. + :type data_center_name: str + :param body: Parameters specifying the managed Cassandra data center. Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -631,20 +651,56 @@ def begin_create_update( :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: + """ + + @distributed_trace + def begin_create_update( + self, + resource_group_name: str, + cluster_name: str, + data_center_name: str, + body: Union[_models.DataCenterResource, IO], + **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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param data_center_name: Data center name in a managed Cassandra cluster. Required. + :type data_center_name: str + :param body: Parameters specifying the managed Cassandra data center. Is either a model type or + a IO type. Required. + :type body: ~azure.mgmt.cosmosdb.models.DataCenterResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.DataCenterResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCenterResource] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCenterResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -653,71 +709,72 @@ def begin_create_update( body=body, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataCenterResource', pipeline_response) + deserialized = self._deserialize("DataCenterResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, cluster_name: str, data_center_name: str, - body: _models.DataCenterResource, + body: Union[_models.DataCenterResource, IO], **kwargs: Any ) -> _models.DataCenterResource: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCenterResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCenterResource] - _json = self._serialize.body(body, 'DataCenterResource') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = self._serialize.body(body, "DataCenterResource") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, data_center_name=data_center_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -725,10 +782,9 @@ def _update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -736,38 +792,82 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataCenterResource', pipeline_response) + deserialized = self._deserialize("DataCenterResource", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DataCenterResource', pipeline_response) + deserialized = self._deserialize("DataCenterResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/cassandraClusters/{clusterName}/dataCenters/{dataCenterName}"} # type: ignore - - @distributed_trace + @overload def begin_update( self, resource_group_name: str, cluster_name: str, data_center_name: str, body: _models.DataCenterResource, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param cluster_name: Managed Cassandra cluster name. + :param cluster_name: Managed Cassandra cluster name. Required. :type cluster_name: str - :param data_center_name: Data center name in a managed Cassandra cluster. + :param data_center_name: Data center name in a managed Cassandra cluster. Required. :type data_center_name: str - :param body: Parameters to provide for specifying the managed Cassandra data center. + :param body: Parameters to provide for specifying the managed Cassandra data center. Required. :type body: ~azure.mgmt.cosmosdb.models.DataCenterResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.DataCenterResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_name: str, + data_center_name: str, + body: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param data_center_name: Data center name in a managed Cassandra cluster. Required. + :type data_center_name: str + :param body: Parameters to provide for specifying the managed Cassandra data center. Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -779,20 +879,55 @@ def begin_update( :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: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + cluster_name: str, + data_center_name: str, + body: Union[_models.DataCenterResource, IO], + **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. + Required. + :type resource_group_name: str + :param cluster_name: Managed Cassandra cluster name. Required. + :type cluster_name: str + :param data_center_name: Data center name in a managed Cassandra cluster. Required. + :type data_center_name: str + :param body: Parameters to provide for specifying the managed Cassandra data center. Is either + a model type or a IO type. Required. + :type body: ~azure.mgmt.cosmosdb.models.DataCenterResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.DataCenterResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataCenterResource] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCenterResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, @@ -801,36 +936,32 @@ def begin_update( body=body, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DataCenterResource', pipeline_response) + deserialized = self._deserialize("DataCenterResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 75f6cc82eb08..5313f58d1156 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 @@ -6,11 +6,16 @@ # 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 Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,1000 +27,927 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_cassandra_keyspace_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - keyspace_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, keyspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_cassandra_keyspace_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - keyspace_name: str, - *, - json: Optional[_models.CassandraKeyspaceCreateUpdateParameters] = None, - content: Any = None, - **kwargs: Any +def build_create_update_cassandra_keyspace_request( + resource_group_name: str, account_name: str, keyspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_cassandra_keyspace_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - keyspace_name: str, - **kwargs: Any +def build_delete_cassandra_keyspace_request( + resource_group_name: str, account_name: str, keyspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_cassandra_keyspace_throughput_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - keyspace_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, keyspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_cassandra_keyspace_throughput_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - keyspace_name: str, - *, - json: Optional[_models.ThroughputSettingsUpdateParameters] = None, - content: Any = None, - **kwargs: Any +def build_update_cassandra_keyspace_throughput_request( + resource_group_name: str, account_name: str, keyspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **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 +def build_migrate_cassandra_keyspace_to_autoscale_request( + resource_group_name: str, account_name: str, keyspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default/migrateToAutoscale") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default/migrateToAutoscale", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **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 +def build_migrate_cassandra_keyspace_to_manual_throughput_request( + resource_group_name: str, account_name: str, keyspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default/migrateToManualThroughput") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default/migrateToManualThroughput", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_cassandra_tables_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - keyspace_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, keyspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_cassandra_table_request( - subscription_id: str, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_cassandra_table_request_initial( - subscription_id: str, +def build_create_update_cassandra_table_request( resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, - *, - json: Optional[_models.CassandraTableCreateUpdateParameters] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_cassandra_table_request_initial( - subscription_id: str, +def build_delete_cassandra_table_request( resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_cassandra_table_throughput_request( - subscription_id: str, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_cassandra_table_throughput_request_initial( - subscription_id: str, +def build_update_cassandra_table_throughput_request( resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, - *, - json: Optional[_models.ThroughputSettingsUpdateParameters] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_cassandra_table_to_autoscale_request_initial( - subscription_id: str, +def build_migrate_cassandra_table_to_autoscale_request( resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_cassandra_table_to_manual_throughput_request_initial( - subscription_id: str, +def build_migrate_cassandra_table_to_manual_throughput_request( resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_cassandra_views_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - keyspace_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, keyspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_cassandra_view_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}", + ) # pylint: disable=line-too-long 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'), - "viewName": _SERIALIZER.url("view_name", view_name, '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]+)*" + ), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), + "viewName": _SERIALIZER.url("view_name", view_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_cassandra_view_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - *, - json: Optional[_models.CassandraViewCreateUpdateParameters] = None, - content: Any = None, - **kwargs: Any +def build_create_update_cassandra_view_request( + resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}", + ) # pylint: disable=line-too-long 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'), - "viewName": _SERIALIZER.url("view_name", view_name, '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]+)*" + ), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), + "viewName": _SERIALIZER.url("view_name", view_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_cassandra_view_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - **kwargs: Any +def build_delete_cassandra_view_request( + resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}", + ) # pylint: disable=line-too-long 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'), - "viewName": _SERIALIZER.url("view_name", view_name, '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]+)*" + ), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), + "viewName": _SERIALIZER.url("view_name", view_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_cassandra_view_throughput_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default", + ) # pylint: disable=line-too-long 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'), - "viewName": _SERIALIZER.url("view_name", view_name, '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]+)*" + ), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), + "viewName": _SERIALIZER.url("view_name", view_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_cassandra_view_throughput_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - *, - json: Optional[_models.ThroughputSettingsUpdateParameters] = None, - content: Any = None, - **kwargs: Any +def build_update_cassandra_view_throughput_request( + resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default", + ) # pylint: disable=line-too-long 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'), - "viewName": _SERIALIZER.url("view_name", view_name, '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]+)*" + ), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), + "viewName": _SERIALIZER.url("view_name", view_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_cassandra_view_to_autoscale_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - **kwargs: Any +def build_migrate_cassandra_view_to_autoscale_request( + resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToAutoscale") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToAutoscale", + ) # pylint: disable=line-too-long 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'), - "viewName": _SERIALIZER.url("view_name", view_name, '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]+)*" + ), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), + "viewName": _SERIALIZER.url("view_name", view_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_cassandra_view_to_manual_throughput_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - **kwargs: Any +def build_migrate_cassandra_view_to_manual_throughput_request( + resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToManualThroughput") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToManualThroughput", + ) # pylint: disable=line-too-long 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'), - "viewName": _SERIALIZER.url("view_name", view_name, '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]+)*" + ), + "keyspaceName": _SERIALIZER.url("keyspace_name", keyspace_name, "str"), + "viewName": _SERIALIZER.url("view_name", view_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class CassandraResourcesOperations: # pylint: disable=too-many-public-methods """ @@ -1036,45 +968,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_cassandra_keyspaces( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.CassandraKeyspaceListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.CassandraKeyspaceGetResults"]: """Lists the Cassandra keyspaces under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 + :return: An iterator like instance of either CassandraKeyspaceGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.CassandraKeyspaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.CassandraKeyspaceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CassandraKeyspaceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_cassandra_keyspaces_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_cassandra_keyspaces.metadata['url'], + template_url=self.list_cassandra_keyspaces.metadata["url"], headers=_headers, params=_params, ) @@ -1082,16 +1010,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_cassandra_keyspaces_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1107,10 +1030,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1120,53 +1041,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_cassandra_keyspaces.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces"} # type: ignore + 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: str, - account_name: str, - keyspace_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any ) -> _models.CassandraKeyspaceGetResults: """Gets the Cassandra keyspaces under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CassandraKeyspaceGetResults, or the result of cls(response) + :return: CassandraKeyspaceGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.CassandraKeyspaceGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CassandraKeyspaceGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_cassandra_keyspace.metadata['url'], + template_url=self.get_cassandra_keyspace.metadata["url"], headers=_headers, params=_params, ) @@ -1174,57 +1087,62 @@ def get_cassandra_keyspace( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CassandraKeyspaceGetResults', pipeline_response) + deserialized = self._deserialize("CassandraKeyspaceGetResults", pipeline_response) if cls: 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 - + 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: str, account_name: str, keyspace_name: str, - create_update_cassandra_keyspace_parameters: _models.CassandraKeyspaceCreateUpdateParameters, + create_update_cassandra_keyspace_parameters: Union[_models.CassandraKeyspaceCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.CassandraKeyspaceGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.CassandraKeyspaceGetResults]] - - _json = self._serialize.body(create_update_cassandra_keyspace_parameters, 'CassandraKeyspaceCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.CassandraKeyspaceGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_cassandra_keyspace_parameters, (IO, bytes)): + _content = create_update_cassandra_keyspace_parameters + else: + _json = self._serialize.body( + create_update_cassandra_keyspace_parameters, "CassandraKeyspaceCreateUpdateParameters" + ) - request = build_create_update_cassandra_keyspace_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_cassandra_keyspace_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_cassandra_keyspace_initial.metadata['url'], + content=_content, + template_url=self._create_update_cassandra_keyspace_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1232,10 +1150,9 @@ def _create_update_cassandra_keyspace_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1244,37 +1161,121 @@ def _create_update_cassandra_keyspace_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('CassandraKeyspaceGetResults', pipeline_response) + deserialized = self._deserialize("CassandraKeyspaceGetResults", pipeline_response) if cls: 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 - + _create_update_cassandra_keyspace_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}"} # type: ignore - @distributed_trace + @overload def begin_create_update_cassandra_keyspace( self, resource_group_name: str, account_name: str, keyspace_name: str, create_update_cassandra_keyspace_parameters: _models.CassandraKeyspaceCreateUpdateParameters, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str :param create_update_cassandra_keyspace_parameters: The parameters to provide for the current - Cassandra keyspace. + Cassandra keyspace. Required. :type create_update_cassandra_keyspace_parameters: ~azure.mgmt.cosmosdb.models.CassandraKeyspaceCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_update_cassandra_keyspace( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + create_update_cassandra_keyspace_parameters: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param create_update_cassandra_keyspace_parameters: The parameters to provide for the current + Cassandra keyspace. Required. + :type create_update_cassandra_keyspace_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraKeyspaceGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_update_cassandra_keyspace( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + create_update_cassandra_keyspace_parameters: Union[_models.CassandraKeyspaceCreateUpdateParameters, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param create_update_cassandra_keyspace_parameters: The parameters to provide for the current + Cassandra keyspace. Is either a model type or a IO type. Required. + :type create_update_cassandra_keyspace_parameters: + ~azure.mgmt.cosmosdb.models.CassandraKeyspaceCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -1286,20 +1287,17 @@ def begin_create_update_cassandra_keyspace( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CassandraKeyspaceGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CassandraKeyspaceGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_update_cassandra_keyspace_initial( # type: ignore resource_group_name=resource_group_name, @@ -1308,66 +1306,55 @@ def begin_create_update_cassandra_keyspace( create_update_cassandra_keyspace_parameters=create_update_cassandra_keyspace_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('CassandraKeyspaceGetResults', pipeline_response) + deserialized = self._deserialize("CassandraKeyspaceGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_cassandra_keyspace_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_cassandra_keyspace_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_cassandra_keyspace_initial.metadata['url'], + template_url=self._delete_cassandra_keyspace_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1375,10 +1362,9 @@ def _delete_cassandra_keyspace_initial( # pylint: disable=inconsistent-return-s request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1388,24 +1374,20 @@ def _delete_cassandra_keyspace_initial( # pylint: disable=inconsistent-return-s if cls: return cls(pipeline_response, None, {}) - _delete_cassandra_keyspace_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - **kwargs: Any + def begin_delete_cassandra_keyspace( + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an existing Azure Cosmos DB Cassandra keyspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :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. @@ -1417,98 +1399,85 @@ def begin_delete_cassandra_keyspace( # pylint: disable=inconsistent-return-stat 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_cassandra_keyspace_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - keyspace_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: """Gets the RUs per second of the Cassandra Keyspace under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ThroughputSettingsGetResults, or the result of cls(response) + :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_cassandra_keyspace_throughput.metadata['url'], + template_url=self.get_cassandra_keyspace_throughput.metadata["url"], headers=_headers, params=_params, ) @@ -1516,57 +1485,60 @@ def get_cassandra_keyspace_throughput( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + 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: str, account_name: str, keyspace_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IO, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - request = build_update_cassandra_keyspace_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_cassandra_keyspace_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_cassandra_keyspace_throughput_initial.metadata['url'], + content=_content, + template_url=self._update_cassandra_keyspace_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1574,10 +1546,9 @@ def _update_cassandra_keyspace_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1586,37 +1557,42 @@ def _update_cassandra_keyspace_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _update_cassandra_keyspace_throughput_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/throughputSettings/default"} # type: ignore - @distributed_trace + @overload def begin_update_cassandra_keyspace_throughput( self, resource_group_name: str, account_name: str, keyspace_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Update RUs per second of an Azure Cosmos DB Cassandra Keyspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Cassandra Keyspace. + current Cassandra Keyspace. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :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 @@ -1628,88 +1604,153 @@ def begin_update_cassandra_keyspace_throughput( :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: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._update_cassandra_keyspace_throughput_initial( # type: ignore - resource_group_name=resource_group_name, - account_name=account_name, - keyspace_name=keyspace_name, - update_throughput_parameters=update_throughput_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) + @overload + def begin_update_cassandra_keyspace_throughput( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + update_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Cassandra Keyspace. - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Cassandra Keyspace. Required. + :type update_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_cassandra_keyspace_throughput( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Cassandra Keyspace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Cassandra Keyspace. Is either a model type or a IO type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_cassandra_keyspace_throughput_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + keyspace_name=keyspace_name, + update_throughput_parameters=update_throughput_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) + if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - keyspace_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_cassandra_keyspace_to_autoscale_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_cassandra_keyspace_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_cassandra_keyspace_to_autoscale_initial.metadata['url'], + template_url=self._migrate_cassandra_keyspace_to_autoscale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1717,10 +1758,9 @@ def _migrate_cassandra_keyspace_to_autoscale_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1729,31 +1769,27 @@ def _migrate_cassandra_keyspace_to_autoscale_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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: str, - account_name: str, - keyspace_name: str, - **kwargs: Any + self, 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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :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. @@ -1766,85 +1802,71 @@ def begin_migrate_cassandra_keyspace_to_autoscale( :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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._migrate_cassandra_keyspace_to_autoscale_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - keyspace_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_cassandra_keyspace_to_manual_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_cassandra_keyspace_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_cassandra_keyspace_to_manual_throughput_initial.metadata['url'], + template_url=self._migrate_cassandra_keyspace_to_manual_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1852,10 +1874,9 @@ def _migrate_cassandra_keyspace_to_manual_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1864,31 +1885,27 @@ def _migrate_cassandra_keyspace_to_manual_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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: str, - account_name: str, - keyspace_name: str, - **kwargs: Any + self, 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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :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. @@ -1901,101 +1918,90 @@ def begin_migrate_cassandra_keyspace_to_manual_throughput( :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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._migrate_cassandra_keyspace_to_manual_throughput_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - account_name: str, - keyspace_name: str, - **kwargs: Any - ) -> Iterable[_models.CassandraTableListResult]: + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any + ) -> Iterable["_models.CassandraTableGetResults"]: """Lists the Cassandra table under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :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 + :return: An iterator like instance of either CassandraTableGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.CassandraTableListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.CassandraTableListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CassandraTableListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_cassandra_tables.metadata['url'], + template_url=self.list_cassandra_tables.metadata["url"], headers=_headers, params=_params, ) @@ -2003,17 +2009,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -2029,10 +2029,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2042,56 +2040,47 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + 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: str, - account_name: str, - keyspace_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> _models.CassandraTableGetResults: """Gets the Cassandra table under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CassandraTableGetResults, or the result of cls(response) + :return: CassandraTableGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.CassandraTableGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.CassandraTableGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CassandraTableGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_cassandra_table.metadata['url'], + template_url=self.get_cassandra_table.metadata["url"], headers=_headers, params=_params, ) @@ -2099,25 +2088,23 @@ def get_cassandra_table( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CassandraTableGetResults', pipeline_response) + deserialized = self._deserialize("CassandraTableGetResults", pipeline_response) if cls: 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 - + 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, @@ -2125,33 +2112,40 @@ def _create_update_cassandra_table_initial( account_name: str, keyspace_name: str, table_name: str, - create_update_cassandra_table_parameters: _models.CassandraTableCreateUpdateParameters, + create_update_cassandra_table_parameters: Union[_models.CassandraTableCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.CassandraTableGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.CassandraTableGetResults]] - - _json = self._serialize.body(create_update_cassandra_table_parameters, 'CassandraTableCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.CassandraTableGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_cassandra_table_parameters, (IO, bytes)): + _content = create_update_cassandra_table_parameters + else: + _json = self._serialize.body( + create_update_cassandra_table_parameters, "CassandraTableCreateUpdateParameters" + ) - request = build_create_update_cassandra_table_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_cassandra_table_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_cassandra_table_initial.metadata['url'], + content=_content, + template_url=self._create_update_cassandra_table_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2159,10 +2153,9 @@ def _create_update_cassandra_table_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2171,17 +2164,16 @@ def _create_update_cassandra_table_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('CassandraTableGetResults', pipeline_response) + deserialized = self._deserialize("CassandraTableGetResults", pipeline_response) if cls: 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 - + _create_update_cassandra_table_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}"} # type: ignore - @distributed_trace + @overload def begin_create_update_cassandra_table( self, resource_group_name: str, @@ -2189,22 +2181,113 @@ def begin_create_update_cassandra_table( keyspace_name: str, table_name: str, create_update_cassandra_table_parameters: _models.CassandraTableCreateUpdateParameters, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :type table_name: str :param create_update_cassandra_table_parameters: The parameters to provide for the current - Cassandra Table. + Cassandra Table. Required. :type create_update_cassandra_table_parameters: ~azure.mgmt.cosmosdb.models.CassandraTableCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_update_cassandra_table( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + create_update_cassandra_table_parameters: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param create_update_cassandra_table_parameters: The parameters to provide for the current + Cassandra Table. Required. + :type create_update_cassandra_table_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraTableGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_update_cassandra_table( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + create_update_cassandra_table_parameters: Union[_models.CassandraTableCreateUpdateParameters, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param create_update_cassandra_table_parameters: The parameters to provide for the current + Cassandra Table. Is either a model type or a IO type. Required. + :type create_update_cassandra_table_parameters: + ~azure.mgmt.cosmosdb.models.CassandraTableCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -2216,20 +2299,17 @@ def begin_create_update_cassandra_table( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CassandraTableGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CassandraTableGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_update_cassandra_table_initial( # type: ignore resource_group_name=resource_group_name, @@ -2239,68 +2319,56 @@ def begin_create_update_cassandra_table( create_update_cassandra_table_parameters=create_update_cassandra_table_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('CassandraTableGetResults', pipeline_response) + deserialized = self._deserialize("CassandraTableGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_cassandra_table_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_cassandra_table_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_cassandra_table_initial.metadata['url'], + template_url=self._delete_cassandra_table_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2308,10 +2376,9 @@ def _delete_cassandra_table_initial( # pylint: disable=inconsistent-return-stat request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2321,27 +2388,22 @@ def _delete_cassandra_table_initial( # pylint: disable=inconsistent-return-stat if cls: return cls(pipeline_response, None, {}) - _delete_cassandra_table_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/tables/{tableName}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - table_name: str, - **kwargs: Any + def begin_delete_cassandra_table( + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an existing Azure Cosmos DB Cassandra table. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :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. @@ -2353,19 +2415,16 @@ def begin_delete_cassandra_table( # pylint: disable=inconsistent-return-stateme 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_cassandra_table_initial( # type: ignore resource_group_name=resource_group_name, @@ -2373,83 +2432,72 @@ def begin_delete_cassandra_table( # pylint: disable=inconsistent-return-stateme keyspace_name=keyspace_name, table_name=table_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - keyspace_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: """Gets the RUs per second of the Cassandra table under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ThroughputSettingsGetResults, or the result of cls(response) + :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_cassandra_table_throughput.metadata['url'], + template_url=self.get_cassandra_table_throughput.metadata["url"], headers=_headers, params=_params, ) @@ -2457,25 +2505,23 @@ def get_cassandra_table_throughput( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + 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, @@ -2483,33 +2529,38 @@ def _update_cassandra_table_throughput_initial( account_name: str, keyspace_name: str, table_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IO, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - request = build_update_cassandra_table_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_cassandra_table_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_cassandra_table_throughput_initial.metadata['url'], + content=_content, + template_url=self._update_cassandra_table_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2517,10 +2568,9 @@ def _update_cassandra_table_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2529,17 +2579,16 @@ def _update_cassandra_table_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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 + @overload def begin_update_cassandra_table_throughput( self, resource_group_name: str, @@ -2547,22 +2596,28 @@ def begin_update_cassandra_table_throughput( keyspace_name: str, table_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Update RUs per second of an Azure Cosmos DB Cassandra table. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :type table_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Cassandra table. + current Cassandra table. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :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 @@ -2574,20 +2629,102 @@ def begin_update_cassandra_table_throughput( :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: + """ + + @overload + def begin_update_cassandra_table_throughput( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + update_throughput_parameters: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Cassandra table. Required. + :type update_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_cassandra_table_throughput( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + table_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Cassandra table. Is either a model type or a IO type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._update_cassandra_table_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -2597,68 +2734,56 @@ def begin_update_cassandra_table_throughput( update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - keyspace_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_cassandra_table_to_autoscale_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_cassandra_table_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_cassandra_table_to_autoscale_initial.metadata['url'], + template_url=self._migrate_cassandra_table_to_autoscale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2666,10 +2791,9 @@ def _migrate_cassandra_table_to_autoscale_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2678,34 +2802,29 @@ def _migrate_cassandra_table_to_autoscale_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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: str, - account_name: str, - keyspace_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB Cassandra table from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :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. @@ -2718,19 +2837,16 @@ def begin_migrate_cassandra_table_to_autoscale( :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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._migrate_cassandra_table_to_autoscale_initial( # type: ignore resource_group_name=resource_group_name, @@ -2738,68 +2854,56 @@ def begin_migrate_cassandra_table_to_autoscale( keyspace_name=keyspace_name, table_name=table_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - keyspace_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_cassandra_table_to_manual_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_cassandra_table_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_cassandra_table_to_manual_throughput_initial.metadata['url'], + template_url=self._migrate_cassandra_table_to_manual_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2807,10 +2911,9 @@ def _migrate_cassandra_table_to_manual_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2819,34 +2922,29 @@ def _migrate_cassandra_table_to_manual_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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: str, - account_name: str, - keyspace_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, table_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB Cassandra table from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :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. @@ -2859,19 +2957,16 @@ def begin_migrate_cassandra_table_to_manual_throughput( :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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._migrate_cassandra_table_to_manual_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -2879,82 +2974,74 @@ def begin_migrate_cassandra_table_to_manual_throughput( keyspace_name=keyspace_name, table_name=table_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 @distributed_trace def list_cassandra_views( - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - **kwargs: Any - ) -> Iterable[_models.CassandraViewListResult]: + self, resource_group_name: str, account_name: str, keyspace_name: str, **kwargs: Any + ) -> Iterable["_models.CassandraViewGetResults"]: """Lists the Cassandra materialized views under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :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 CassandraViewListResult or the result of + :return: An iterator like instance of either CassandraViewGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.CassandraViewListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.CassandraViewListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CassandraViewListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_cassandra_views_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_cassandra_views.metadata['url'], + template_url=self.list_cassandra_views.metadata["url"], headers=_headers, params=_params, ) @@ -2962,17 +3049,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_cassandra_views_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - keyspace_name=keyspace_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -2988,10 +3069,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3001,56 +3080,47 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_cassandra_views.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views"} # type: ignore + list_cassandra_views.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views"} # type: ignore @distributed_trace def get_cassandra_view( - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> _models.CassandraViewGetResults: """Gets the Cassandra view under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param view_name: Cosmos DB view name. + :param view_name: Cosmos DB view name. Required. :type view_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CassandraViewGetResults, or the result of cls(response) + :return: CassandraViewGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.CassandraViewGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.CassandraViewGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CassandraViewGetResults] - request = build_get_cassandra_view_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, view_name=view_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_cassandra_view.metadata['url'], + template_url=self.get_cassandra_view.metadata["url"], headers=_headers, params=_params, ) @@ -3058,25 +3128,23 @@ def get_cassandra_view( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CassandraViewGetResults', pipeline_response) + deserialized = self._deserialize("CassandraViewGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_cassandra_view.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}"} # type: ignore - + get_cassandra_view.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}"} # type: ignore def _create_update_cassandra_view_initial( self, @@ -3084,33 +3152,38 @@ def _create_update_cassandra_view_initial( account_name: str, keyspace_name: str, view_name: str, - create_update_cassandra_view_parameters: _models.CassandraViewCreateUpdateParameters, + create_update_cassandra_view_parameters: Union[_models.CassandraViewCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.CassandraViewGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.CassandraViewGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.CassandraViewGetResults]] - _json = self._serialize.body(create_update_cassandra_view_parameters, 'CassandraViewCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_cassandra_view_parameters, (IO, bytes)): + _content = create_update_cassandra_view_parameters + else: + _json = self._serialize.body(create_update_cassandra_view_parameters, "CassandraViewCreateUpdateParameters") - request = build_create_update_cassandra_view_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_cassandra_view_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, view_name=view_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_cassandra_view_initial.metadata['url'], + content=_content, + template_url=self._create_update_cassandra_view_initial.metadata["url"], headers=_headers, params=_params, ) @@ -3118,10 +3191,9 @@ def _create_update_cassandra_view_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3130,17 +3202,16 @@ def _create_update_cassandra_view_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('CassandraViewGetResults', pipeline_response) + deserialized = self._deserialize("CassandraViewGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_update_cassandra_view_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}"} # type: ignore + _create_update_cassandra_view_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}"} # type: ignore - - @distributed_trace + @overload def begin_create_update_cassandra_view( self, resource_group_name: str, @@ -3148,22 +3219,113 @@ def begin_create_update_cassandra_view( keyspace_name: str, view_name: str, create_update_cassandra_view_parameters: _models.CassandraViewCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.CassandraViewGetResults]: """Create or update an Azure Cosmos DB Cassandra View. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param view_name: Cosmos DB view name. + :param view_name: Cosmos DB view name. Required. :type view_name: str :param create_update_cassandra_view_parameters: The parameters to provide for the current - Cassandra View. + Cassandra View. Required. :type create_update_cassandra_view_parameters: ~azure.mgmt.cosmosdb.models.CassandraViewCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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 CassandraViewGetResults or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_update_cassandra_view( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + view_name: str, + create_update_cassandra_view_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CassandraViewGetResults]: + """Create or update an Azure Cosmos DB Cassandra View. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param view_name: Cosmos DB view name. Required. + :type view_name: str + :param create_update_cassandra_view_parameters: The parameters to provide for the current + Cassandra View. Required. + :type create_update_cassandra_view_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 CassandraViewGetResults or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_update_cassandra_view( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + view_name: str, + create_update_cassandra_view_parameters: Union[_models.CassandraViewCreateUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.CassandraViewGetResults]: + """Create or update an Azure Cosmos DB Cassandra View. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param view_name: Cosmos DB view name. Required. + :type view_name: str + :param create_update_cassandra_view_parameters: The parameters to provide for the current + Cassandra View. Is either a model type or a IO type. Required. + :type create_update_cassandra_view_parameters: + ~azure.mgmt.cosmosdb.models.CassandraViewCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -3175,20 +3337,17 @@ def begin_create_update_cassandra_view( :return: An instance of LROPoller that returns either CassandraViewGetResults or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.CassandraViewGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CassandraViewGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CassandraViewGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_update_cassandra_view_initial( # type: ignore resource_group_name=resource_group_name, @@ -3198,68 +3357,56 @@ def begin_create_update_cassandra_view( create_update_cassandra_view_parameters=create_update_cassandra_view_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('CassandraViewGetResults', pipeline_response) + deserialized = self._deserialize("CassandraViewGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_update_cassandra_view.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}"} # type: ignore + begin_create_update_cassandra_view.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}"} # type: ignore def _delete_cassandra_view_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_cassandra_view_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_cassandra_view_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, view_name=view_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_cassandra_view_initial.metadata['url'], + template_url=self._delete_cassandra_view_initial.metadata["url"], headers=_headers, params=_params, ) @@ -3267,10 +3414,9 @@ def _delete_cassandra_view_initial( # pylint: disable=inconsistent-return-state request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -3280,27 +3426,22 @@ def _delete_cassandra_view_initial( # pylint: disable=inconsistent-return-state if cls: return cls(pipeline_response, None, {}) - _delete_cassandra_view_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}"} # type: ignore - + _delete_cassandra_view_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}"} # type: ignore @distributed_trace - def begin_delete_cassandra_view( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - **kwargs: Any + def begin_delete_cassandra_view( + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an existing Azure Cosmos DB Cassandra view. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param view_name: Cosmos DB view name. + :param view_name: Cosmos DB view name. Required. :type view_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. @@ -3312,19 +3453,16 @@ def begin_delete_cassandra_view( # pylint: disable=inconsistent-return-statemen 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_cassandra_view_initial( # type: ignore resource_group_name=resource_group_name, @@ -3332,83 +3470,72 @@ def begin_delete_cassandra_view( # pylint: disable=inconsistent-return-statemen keyspace_name=keyspace_name, view_name=view_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_cassandra_view.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}"} # type: ignore + begin_delete_cassandra_view.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}"} # type: ignore @distributed_trace def get_cassandra_view_throughput( - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: """Gets the RUs per second of the Cassandra view under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param view_name: Cosmos DB view name. + :param view_name: Cosmos DB view name. Required. :type view_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ThroughputSettingsGetResults, or the result of cls(response) + :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] - request = build_get_cassandra_view_throughput_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, view_name=view_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_cassandra_view_throughput.metadata['url'], + template_url=self.get_cassandra_view_throughput.metadata["url"], headers=_headers, params=_params, ) @@ -3416,25 +3543,23 @@ def get_cassandra_view_throughput( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_cassandra_view_throughput.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default"} # type: ignore - + get_cassandra_view_throughput.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default"} # type: ignore def _update_cassandra_view_throughput_initial( self, @@ -3442,33 +3567,38 @@ def _update_cassandra_view_throughput_initial( account_name: str, keyspace_name: str, view_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IO, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - request = build_update_cassandra_view_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_cassandra_view_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, view_name=view_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_cassandra_view_throughput_initial.metadata['url'], + content=_content, + template_url=self._update_cassandra_view_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -3476,10 +3606,9 @@ def _update_cassandra_view_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3488,17 +3617,16 @@ def _update_cassandra_view_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_cassandra_view_throughput_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default"} # type: ignore - + _update_cassandra_view_throughput_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default"} # type: ignore - @distributed_trace + @overload def begin_update_cassandra_view_throughput( self, resource_group_name: str, @@ -3506,22 +3634,113 @@ def begin_update_cassandra_view_throughput( keyspace_name: str, view_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Update RUs per second of an Azure Cosmos DB Cassandra view. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param view_name: Cosmos DB view name. + :param view_name: Cosmos DB view name. Required. :type view_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Cassandra view. + current Cassandra view. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_cassandra_view_throughput( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + view_name: str, + update_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Cassandra view. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param view_name: Cosmos DB view name. Required. + :type view_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Cassandra view. Required. + :type update_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_cassandra_view_throughput( + self, + resource_group_name: str, + account_name: str, + keyspace_name: str, + view_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB Cassandra view. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param keyspace_name: Cosmos DB keyspace name. Required. + :type keyspace_name: str + :param view_name: Cosmos DB view name. Required. + :type view_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Cassandra view. Is either a model type or a IO type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -3533,20 +3752,17 @@ def begin_update_cassandra_view_throughput( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._update_cassandra_view_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -3556,68 +3772,56 @@ def begin_update_cassandra_view_throughput( update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_cassandra_view_throughput.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default"} # type: ignore + begin_update_cassandra_view_throughput.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default"} # type: ignore def _migrate_cassandra_view_to_autoscale_initial( - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_cassandra_view_to_autoscale_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_cassandra_view_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, view_name=view_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_cassandra_view_to_autoscale_initial.metadata['url'], + template_url=self._migrate_cassandra_view_to_autoscale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -3625,10 +3829,9 @@ def _migrate_cassandra_view_to_autoscale_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3637,34 +3840,29 @@ def _migrate_cassandra_view_to_autoscale_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _migrate_cassandra_view_to_autoscale_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToAutoscale"} # type: ignore - + _migrate_cassandra_view_to_autoscale_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToAutoscale"} # type: ignore @distributed_trace def begin_migrate_cassandra_view_to_autoscale( - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB Cassandra view from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param view_name: Cosmos DB view name. + :param view_name: Cosmos DB view name. Required. :type view_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. @@ -3677,19 +3875,16 @@ def begin_migrate_cassandra_view_to_autoscale( :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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._migrate_cassandra_view_to_autoscale_initial( # type: ignore resource_group_name=resource_group_name, @@ -3697,68 +3892,56 @@ def begin_migrate_cassandra_view_to_autoscale( keyspace_name=keyspace_name, view_name=view_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_migrate_cassandra_view_to_autoscale.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToAutoscale"} # type: ignore + begin_migrate_cassandra_view_to_autoscale.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToAutoscale"} # type: ignore def _migrate_cassandra_view_to_manual_throughput_initial( - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_cassandra_view_to_manual_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_cassandra_view_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, keyspace_name=keyspace_name, view_name=view_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_cassandra_view_to_manual_throughput_initial.metadata['url'], + template_url=self._migrate_cassandra_view_to_manual_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -3766,10 +3949,9 @@ def _migrate_cassandra_view_to_manual_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3778,34 +3960,29 @@ def _migrate_cassandra_view_to_manual_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _migrate_cassandra_view_to_manual_throughput_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToManualThroughput"} # type: ignore - + _migrate_cassandra_view_to_manual_throughput_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToManualThroughput"} # type: ignore @distributed_trace def begin_migrate_cassandra_view_to_manual_throughput( - self, - resource_group_name: str, - account_name: str, - keyspace_name: str, - view_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, keyspace_name: str, view_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB Cassandra view from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param keyspace_name: Cosmos DB keyspace name. + :param keyspace_name: Cosmos DB keyspace name. Required. :type keyspace_name: str - :param view_name: Cosmos DB view name. + :param view_name: Cosmos DB view name. Required. :type view_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. @@ -3818,19 +3995,16 @@ def begin_migrate_cassandra_view_to_manual_throughput( :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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._migrate_cassandra_view_to_manual_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -3838,36 +4012,32 @@ def begin_migrate_cassandra_view_to_manual_throughput( keyspace_name=keyspace_name, view_name=view_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_migrate_cassandra_view_to_manual_throughput.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/throughputSettings/default/migrateToManualThroughput"} # type: ignore + begin_migrate_cassandra_view_to_manual_throughput.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/cassandraKeyspaces/{keyspaceName}/views/{viewName}/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 acd9f95134f7..59b51fa4b6ad 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,19 +25,22 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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, + subscription_id: str, *, filter: str, **kwargs: Any @@ -40,43 +48,44 @@ def build_list_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/metrics") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/metrics", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_usages_request( - subscription_id: str, resource_group_name: str, account_name: str, database_rid: str, collection_rid: str, + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any @@ -84,77 +93,80 @@ def build_list_usages_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/usages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/usages", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_metric_definitions_request( - subscription_id: str, resource_group_name: str, account_name: str, database_rid: str, collection_rid: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/metricDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/metricDefinitions", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class CollectionOperations: """ @@ -175,7 +187,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( self, @@ -185,49 +196,49 @@ def list_metrics( collection_rid: str, filter: str, **kwargs: Any - ) -> Iterable[_models.MetricListResult]: + ) -> Iterable["_models.Metric"]: """Retrieves the metrics determined by the given filter for the given database account and collection. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param collection_rid: Cosmos DB collection rid. + :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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 MetricListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MetricListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Metric or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.Metric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -235,19 +246,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -263,10 +266,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -276,11 +277,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + 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( @@ -291,48 +290,48 @@ def list_usages( collection_rid: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.UsagesResult]: + ) -> Iterable["_models.Usage"]: """Retrieves the usages (most recent storage data) for the given collection. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param collection_rid: Cosmos DB collection rid. + :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str :param filter: An OData filter expression that describes a subset of usages to return. The supported parameter is name.value (name of the metric, can have an or of multiple names). Default value is None. :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 UsagesResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.UsagesResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsagesResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsagesResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_usages.metadata['url'], + api_version=api_version, + template_url=self.list_usages.metadata["url"], headers=_headers, params=_params, ) @@ -340,19 +339,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -368,10 +359,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -381,58 +370,50 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + 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, - account_name: str, - database_rid: str, - collection_rid: str, - **kwargs: Any - ) -> Iterable[_models.MetricDefinitionsListResult]: + self, resource_group_name: str, account_name: str, database_rid: str, collection_rid: str, **kwargs: Any + ) -> Iterable["_models.MetricDefinition"]: """Retrieves metric definitions for the given collection. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param collection_rid: Cosmos DB collection rid. + :param collection_rid: Cosmos DB collection rid. Required. :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.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinitionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MetricDefinition or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricDefinitionsListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_metric_definitions.metadata['url'], + template_url=self.list_metric_definitions.metadata["url"], headers=_headers, params=_params, ) @@ -440,18 +421,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -467,10 +441,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -480,8 +452,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_metric_definitions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/metricDefinitions"} # type: ignore + list_metric_definitions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/metricDefinitions"} # type: ignore 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 52c206f6e150..a395c51b274c 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,19 +25,22 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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, + subscription_id: str, *, filter: str, **kwargs: Any @@ -40,43 +48,44 @@ def build_list_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitions/metrics") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitions/metrics", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_usages_request( - subscription_id: str, resource_group_name: str, account_name: str, database_rid: str, collection_rid: str, + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any @@ -84,36 +93,38 @@ def build_list_usages_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitions/usages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitions/usages", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class CollectionPartitionOperations: """ @@ -134,7 +145,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( self, @@ -144,50 +154,49 @@ def list_metrics( collection_rid: str, filter: str, **kwargs: Any - ) -> Iterable[_models.PartitionMetricListResult]: + ) -> Iterable["_models.PartitionMetric"]: """Retrieves the metrics determined by the given filter for the given collection, split by partition. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param collection_rid: Cosmos DB collection rid. + :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetricListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PartitionMetric or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PartitionMetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartitionMetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -195,19 +204,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -223,10 +224,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -236,11 +235,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + 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( @@ -251,49 +248,48 @@ def list_usages( collection_rid: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.PartitionUsagesResult]: + ) -> Iterable["_models.PartitionUsage"]: """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param collection_rid: Cosmos DB collection rid. + :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str :param filter: An OData filter expression that describes a subset of usages to return. The supported parameter is name.value (name of the metric, can have an or of multiple names). Default value is None. :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.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PartitionUsagesResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PartitionUsage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PartitionUsage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PartitionUsagesResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartitionUsagesResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_usages.metadata['url'], + api_version=api_version, + template_url=self.list_usages.metadata["url"], headers=_headers, params=_params, ) @@ -301,19 +297,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -329,10 +317,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -342,8 +328,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitions/usages"} # type: ignore + list_usages.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitions/usages"} # type: ignore 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 be294a07a9a5..ae7aebc7d331 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,20 +25,23 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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, + subscription_id: str, *, filter: str, **kwargs: Any @@ -41,36 +49,38 @@ def build_list_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("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") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/partitions/metrics", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class CollectionPartitionRegionOperations: """ @@ -91,7 +101,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( self, @@ -102,53 +111,52 @@ def list_metrics( collection_rid: str, filter: str, **kwargs: Any - ) -> Iterable[_models.PartitionMetricListResult]: + ) -> Iterable["_models.PartitionMetric"]: """Retrieves the metrics determined by the given filter for the given collection and region, split by partition. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param region: Cosmos DB region, with spaces between words and each word capitalized. + :param region: Cosmos DB region, with spaces between words and each word capitalized. Required. :type region: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param collection_rid: Cosmos DB collection rid. + :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetricListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PartitionMetric or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PartitionMetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartitionMetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -156,20 +164,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -185,10 +184,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -198,8 +195,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_metrics.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/partitions/metrics"} # type: ignore + list_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/partitions/metrics"} # type: ignore 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 9129ba3afe06..6206b9785b16 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,20 +25,23 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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, + subscription_id: str, *, filter: str, **kwargs: Any @@ -41,36 +49,38 @@ def build_list_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("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") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/metrics", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class CollectionRegionOperations: """ @@ -91,7 +101,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( self, @@ -102,52 +111,52 @@ def list_metrics( collection_rid: str, filter: str, **kwargs: Any - ) -> Iterable[_models.MetricListResult]: + ) -> Iterable["_models.Metric"]: """Retrieves the metrics determined by the given filter for the given database account, collection and region. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param region: Cosmos DB region, with spaces between words and each word capitalized. + :param region: Cosmos DB region, with spaces between words and each word capitalized. Required. :type region: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param collection_rid: Cosmos DB collection rid. + :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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 MetricListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MetricListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Metric or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.Metric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -155,20 +164,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -184,10 +184,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -197,8 +195,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_metrics.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/metrics"} # type: ignore + list_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/metrics"} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_data_transfer_jobs_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_data_transfer_jobs_operations.py index f947d66d7bf3..c50d2da46470 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_data_transfer_jobs_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_data_transfer_jobs_operations.py @@ -6,11 +6,16 @@ # 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 Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,251 +25,233 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - job_name: str, - *, - json: Optional[_models.CreateJobRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, job_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}", + ) # pylint: disable=line-too-long 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]+)*'), - "jobName": _SERIALIZER.url("job_name", job_name, '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]+)*" + ), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - job_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, job_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}", + ) # pylint: disable=line-too-long 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]+)*'), - "jobName": _SERIALIZER.url("job_name", job_name, '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]+)*" + ), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_pause_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - job_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, job_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/pause") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/pause", + ) # pylint: disable=line-too-long 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]+)*'), - "jobName": _SERIALIZER.url("job_name", job_name, '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]+)*" + ), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_resume_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - job_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, job_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/resume") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/resume", + ) # pylint: disable=line-too-long 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]+)*'), - "jobName": _SERIALIZER.url("job_name", job_name, '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]+)*" + ), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_cancel_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - job_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, job_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/cancel") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/cancel", + ) # pylint: disable=line-too-long 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]+)*'), - "jobName": _SERIALIZER.url("job_name", job_name, '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]+)*" + ), + "jobName": _SERIALIZER.url("job_name", job_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_database_account_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DataTransferJobsOperations: """ @@ -285,54 +272,124 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, job_name: str, job_create_parameters: _models.CreateJobRequest, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.DataTransferJobGetResults: """Creates a Data Transfer Job. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param job_name: Name of the Data Transfer Job. + :param job_name: Name of the Data Transfer Job. Required. :type job_name: str - :param job_create_parameters: + :param job_create_parameters: Required. :type job_create_parameters: ~azure.mgmt.cosmosdb.models.CreateJobRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataTransferJobGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.DataTransferJobGetResults + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + job_name: str, + job_create_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataTransferJobGetResults: + """Creates a Data Transfer Job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param job_name: Name of the Data Transfer Job. Required. + :type job_name: str + :param job_create_parameters: Required. + :type job_create_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataTransferJobGetResults or the result of cls(response) + :rtype: ~azure.mgmt.cosmosdb.models.DataTransferJobGetResults + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + job_name: str, + job_create_parameters: Union[_models.CreateJobRequest, IO], + **kwargs: Any + ) -> _models.DataTransferJobGetResults: + """Creates a Data Transfer Job. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param job_name: Name of the Data Transfer Job. Required. + :type job_name: str + :param job_create_parameters: Is either a model type or a IO type. Required. + :type job_create_parameters: ~azure.mgmt.cosmosdb.models.CreateJobRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataTransferJobGetResults, or the result of cls(response) + :return: DataTransferJobGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DataTransferJobGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataTransferJobGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataTransferJobGetResults] - _json = self._serialize.body(job_create_parameters, 'CreateJobRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(job_create_parameters, (IO, bytes)): + _content = job_create_parameters + else: + _json = self._serialize.body(job_create_parameters, "CreateJobRequest") request = build_create_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -340,66 +397,58 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataTransferJobGetResults', pipeline_response) + deserialized = self._deserialize("DataTransferJobGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - job_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.DataTransferJobGetResults: """Get a Data Transfer Job. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param job_name: Name of the Data Transfer Job. + :param job_name: Name of the Data Transfer Job. Required. :type job_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataTransferJobGetResults, or the result of cls(response) + :return: DataTransferJobGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DataTransferJobGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataTransferJobGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataTransferJobGetResults] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -407,66 +456,58 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataTransferJobGetResults', pipeline_response) + deserialized = self._deserialize("DataTransferJobGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}"} # type: ignore @distributed_trace def pause( - self, - resource_group_name: str, - account_name: str, - job_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.DataTransferJobGetResults: """Pause a Data Transfer Job. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param job_name: Name of the Data Transfer Job. + :param job_name: Name of the Data Transfer Job. Required. :type job_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataTransferJobGetResults, or the result of cls(response) + :return: DataTransferJobGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DataTransferJobGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataTransferJobGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataTransferJobGetResults] - request = build_pause_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.pause.metadata['url'], + template_url=self.pause.metadata["url"], headers=_headers, params=_params, ) @@ -474,66 +515,58 @@ def pause( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataTransferJobGetResults', pipeline_response) + deserialized = self._deserialize("DataTransferJobGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - pause.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/pause"} # type: ignore - + pause.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/pause"} # type: ignore @distributed_trace def resume( - self, - resource_group_name: str, - account_name: str, - job_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.DataTransferJobGetResults: """Resumes a Data Transfer Job. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param job_name: Name of the Data Transfer Job. + :param job_name: Name of the Data Transfer Job. Required. :type job_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataTransferJobGetResults, or the result of cls(response) + :return: DataTransferJobGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DataTransferJobGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataTransferJobGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataTransferJobGetResults] - request = build_resume_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.resume.metadata['url'], + template_url=self.resume.metadata["url"], headers=_headers, params=_params, ) @@ -541,66 +574,58 @@ def resume( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataTransferJobGetResults', pipeline_response) + deserialized = self._deserialize("DataTransferJobGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - resume.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/resume"} # type: ignore - + resume.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/resume"} # type: ignore @distributed_trace def cancel( - self, - resource_group_name: str, - account_name: str, - job_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, job_name: str, **kwargs: Any ) -> _models.DataTransferJobGetResults: """Cancels a Data Transfer Job. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param job_name: Name of the Data Transfer Job. + :param job_name: Name of the Data Transfer Job. Required. :type job_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataTransferJobGetResults, or the result of cls(response) + :return: DataTransferJobGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DataTransferJobGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataTransferJobGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataTransferJobGetResults] - request = build_cancel_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, job_name=job_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata['url'], + template_url=self.cancel.metadata["url"], headers=_headers, params=_params, ) @@ -608,64 +633,59 @@ def cancel( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataTransferJobGetResults', pipeline_response) + deserialized = self._deserialize("DataTransferJobGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/cancel"} # type: ignore - + cancel.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs/{jobName}/cancel"} # type: ignore @distributed_trace def list_by_database_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.DataTransferJobFeedResults]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.DataTransferJobGetResults"]: """Get a list of Data Transfer jobs. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 DataTransferJobFeedResults or the result of + :return: An iterator like instance of either DataTransferJobGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.DataTransferJobFeedResults] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.DataTransferJobGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DataTransferJobFeedResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataTransferJobFeedResults] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_database_account_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_database_account.metadata['url'], + template_url=self.list_by_database_account.metadata["url"], headers=_headers, params=_params, ) @@ -673,16 +693,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_database_account_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -698,10 +713,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -711,8 +724,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_database_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs"} # type: ignore + list_by_database_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/dataTransferJobs"} # type: ignore 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 f4d04003bd5a..43f970613355 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,53 +25,52 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 + resource_group_name: str, account_name: str, region: str, subscription_id: str, *, filter: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/metrics") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/metrics", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DatabaseAccountRegionOperations: """ @@ -87,54 +91,48 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( - self, - resource_group_name: str, - account_name: str, - region: str, - filter: str, - **kwargs: Any - ) -> Iterable[_models.MetricListResult]: + self, resource_group_name: str, account_name: str, region: str, filter: str, **kwargs: Any + ) -> Iterable["_models.Metric"]: """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param region: Cosmos DB region, with spaces between words and each word capitalized. + :param region: Cosmos DB region, with spaces between words and each word capitalized. Required. :type region: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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 MetricListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MetricListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Metric or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.Metric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, region=region, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -142,18 +140,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - region=region, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -169,10 +160,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -182,8 +171,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_metrics.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/metrics"} # type: ignore + list_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/metrics"} # type: ignore 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 8c974bde529a..a2367dd63ebc 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 @@ -6,11 +6,16 @@ # 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 Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,702 +27,621 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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: + +def build_get_request(resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - *, - json: Optional[_models.DatabaseAccountUpdateParameters] = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - *, - json: Optional[_models.DatabaseAccountCreateUpdateParameters] = None, - content: Any = None, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) - - -def build_failover_priority_change_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - *, - json: Optional[_models.FailoverPolicies] = None, - content: Any = None, - **kwargs: Any + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_failover_priority_change_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/failoverPriorityChange") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/failoverPriorityChange", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("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), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts", + ) # pylint: disable=line-too-long 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), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_connection_strings_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listConnectionStrings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listConnectionStrings", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_offline_region_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - *, - json: Optional[_models.RegionForOnlineOffline] = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_offline_region_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/offlineRegion") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/offlineRegion", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_online_region_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - *, - json: Optional[_models.RegionForOnlineOffline] = None, - content: Any = None, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_online_region_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/onlineRegion") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/onlineRegion", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_read_only_keys_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_read_only_keys_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_regenerate_key_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - *, - json: Optional[_models.DatabaseAccountRegenerateKeyParameters] = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_regenerate_key_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_check_name_exists_request( - account_name: str, - **kwargs: Any -) -> HttpRequest: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_name_exists_request(account_name: str, **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str # 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="HEAD", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) def build_list_metrics_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - *, - filter: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, *, filter: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metrics") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metrics", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_usages_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - *, - filter: Optional[str] = None, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/usages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/usages", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_metric_definitions_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metricDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metricDefinitions", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DatabaseAccountsOperations: # pylint: disable=too-many-public-methods """ @@ -738,43 +662,35 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.DatabaseAccountGetResults: + def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.DatabaseAccountGetResults: """Retrieves the properties of an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DatabaseAccountGetResults, or the result of cls(response) + :return: DatabaseAccountGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountGetResults] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -782,55 +698,58 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatabaseAccountGetResults', pipeline_response) + deserialized = self._deserialize("DatabaseAccountGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore def _update_initial( self, resource_group_name: str, account_name: str, - update_parameters: _models.DatabaseAccountUpdateParameters, + update_parameters: Union[_models.DatabaseAccountUpdateParameters, IO], **kwargs: Any ) -> _models.DatabaseAccountGetResults: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountGetResults] - _json = self._serialize.body(update_parameters, 'DatabaseAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_parameters, (IO, bytes)): + _content = update_parameters + else: + _json = self._serialize.body(update_parameters, "DatabaseAccountUpdateParameters") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -838,42 +757,117 @@ def _update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatabaseAccountGetResults', pipeline_response) + deserialized = self._deserialize("DatabaseAccountGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore - - @distributed_trace + @overload def begin_update( self, resource_group_name: str, account_name: str, update_parameters: _models.DatabaseAccountUpdateParameters, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param update_parameters: The parameters to provide for the current database account. + :param update_parameters: The parameters to provide for the current database account. Required. :type update_parameters: ~azure.mgmt.cosmosdb.models.DatabaseAccountUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + account_name: str, + update_parameters: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param update_parameters: The parameters to provide for the current database account. Required. + :type update_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + account_name: str, + update_parameters: Union[_models.DatabaseAccountUpdateParameters, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param update_parameters: The parameters to provide for the current database account. Is either + a model type or a IO type. Required. + :type update_parameters: ~azure.mgmt.cosmosdb.models.DatabaseAccountUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -885,20 +879,17 @@ def begin_update( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, @@ -906,69 +897,70 @@ def begin_update( update_parameters=update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DatabaseAccountGetResults', pipeline_response) + deserialized = self._deserialize("DatabaseAccountGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, account_name: str, - create_update_parameters: _models.DatabaseAccountCreateUpdateParameters, + create_update_parameters: Union[_models.DatabaseAccountCreateUpdateParameters, IO], **kwargs: Any ) -> _models.DatabaseAccountGetResults: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountGetResults] - _json = self._serialize.body(create_update_parameters, 'DatabaseAccountCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_parameters, (IO, bytes)): + _content = create_update_parameters + else: + _json = self._serialize.body(create_update_parameters, "DatabaseAccountCreateUpdateParameters") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -976,44 +968,124 @@ def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatabaseAccountGetResults', pipeline_response) + deserialized = self._deserialize("DatabaseAccountGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, account_name: str, create_update_parameters: _models.DatabaseAccountCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DatabaseAccountGetResults]: """Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when performing updates on an account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param create_update_parameters: The parameters to provide for the current database account. + Required. :type create_update_parameters: ~azure.mgmt.cosmosdb.models.DatabaseAccountCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + create_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DatabaseAccountGetResults]: + """Creates or updates an Azure Cosmos DB database account. The "Update" method is preferred when + performing updates on an account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param create_update_parameters: The parameters to provide for the current database account. + Required. + :type create_update_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + create_update_parameters: Union[_models.DatabaseAccountCreateUpdateParameters, IO], + **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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param create_update_parameters: The parameters to provide for the current database account. Is + either a model type or a IO type. Required. + :type create_update_parameters: + ~azure.mgmt.cosmosdb.models.DatabaseAccountCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -1025,20 +1097,17 @@ def begin_create_or_update( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -1046,64 +1115,54 @@ def begin_create_or_update( create_update_parameters=create_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('DatabaseAccountGetResults', pipeline_response) + deserialized = self._deserialize("DatabaseAccountGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1111,10 +1170,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1124,21 +1182,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, 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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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. @@ -1150,85 +1203,83 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}"} # type: ignore def _failover_priority_change_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - failover_parameters: _models.FailoverPolicies, + failover_parameters: Union[_models.FailoverPolicies, IO], **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(failover_parameters, 'FailoverPolicies') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(failover_parameters, (IO, bytes)): + _content = failover_parameters + else: + _json = self._serialize.body(failover_parameters, "FailoverPolicies") - request = build_failover_priority_change_request_initial( - subscription_id=self._config.subscription_id, + request = build_failover_priority_change_request( resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._failover_priority_change_initial.metadata['url'], + content=_content, + template_url=self._failover_priority_change_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1236,10 +1287,9 @@ def _failover_priority_change_initial( # pylint: disable=inconsistent-return-st request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1249,15 +1299,16 @@ def _failover_priority_change_initial( # pylint: disable=inconsistent-return-st if cls: return cls(pipeline_response, None, {}) - _failover_priority_change_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/failoverPriorityChange"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements + @overload + def begin_failover_priority_change( self, resource_group_name: str, account_name: str, failover_parameters: _models.FailoverPolicies, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Changes the failover priority for the Azure Cosmos DB database account. A failover priority of @@ -1266,11 +1317,90 @@ def begin_failover_priority_change( # pylint: disable=inconsistent-return-state database account exists. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param failover_parameters: The new failover policies for the database account. + :param failover_parameters: The new failover policies for the database account. Required. :type failover_parameters: ~azure.mgmt.cosmosdb.models.FailoverPolicies + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_failover_priority_change( + self, + resource_group_name: str, + account_name: str, + failover_parameters: IO, + *, + content_type: str = "application/json", + **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 + database account exists. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param failover_parameters: The new failover policies for the database account. Required. + :type failover_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_failover_priority_change( + self, + resource_group_name: str, + account_name: str, + failover_parameters: Union[_models.FailoverPolicies, IO], + **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 + database account exists. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param failover_parameters: The new failover policies for the database account. Is either a + model type or a IO type. Required. + :type failover_parameters: ~azure.mgmt.cosmosdb.models.FailoverPolicies or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -1281,20 +1411,17 @@ def begin_failover_priority_change( # pylint: disable=inconsistent-return-state 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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._failover_priority_change_initial( # type: ignore resource_group_name=resource_group_name, @@ -1302,68 +1429,60 @@ def begin_failover_priority_change( # pylint: disable=inconsistent-return-state failover_parameters=failover_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 - ) -> Iterable[_models.DatabaseAccountsListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.DatabaseAccountGetResults"]: """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 + :return: An iterator like instance of either DatabaseAccountGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountsListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -1371,14 +1490,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1394,10 +1510,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1407,46 +1521,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/databaseAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/databaseAccounts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.DatabaseAccountsListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.DatabaseAccountGetResults"]: """Lists all the Azure Cosmos DB database accounts available under the given resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :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 + :return: An iterator like instance of either DatabaseAccountGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.DatabaseAccountGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountsListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1454,15 +1564,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1478,10 +1584,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1491,48 +1595,41 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts"} # type: ignore + 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: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.DatabaseAccountListKeysResult: """Lists the access keys for the specified Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DatabaseAccountListKeysResult, or the result of cls(response) + :return: DatabaseAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DatabaseAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountListKeysResult] - request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1540,62 +1637,55 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatabaseAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("DatabaseAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listKeys"} # type: ignore - + 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: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.DatabaseAccountListConnectionStringsResult: """Lists the connection strings for the specified Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DatabaseAccountListConnectionStringsResult, or the result of cls(response) + :return: DatabaseAccountListConnectionStringsResult or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DatabaseAccountListConnectionStringsResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountListConnectionStringsResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountListConnectionStringsResult] - request = build_list_connection_strings_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_connection_strings.metadata['url'], + template_url=self.list_connection_strings.metadata["url"], headers=_headers, params=_params, ) @@ -1603,55 +1693,58 @@ def list_connection_strings( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatabaseAccountListConnectionStringsResult', pipeline_response) + deserialized = self._deserialize("DatabaseAccountListConnectionStringsResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_connection_strings.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listConnectionStrings"} # type: ignore - + list_connection_strings.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listConnectionStrings"} # type: ignore def _offline_region_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - region_parameter_for_offline: _models.RegionForOnlineOffline, + region_parameter_for_offline: Union[_models.RegionForOnlineOffline, IO], **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(region_parameter_for_offline, 'RegionForOnlineOffline') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(region_parameter_for_offline, (IO, bytes)): + _content = region_parameter_for_offline + else: + _json = self._serialize.body(region_parameter_for_offline, "RegionForOnlineOffline") - request = build_offline_region_request_initial( - subscription_id=self._config.subscription_id, + request = build_offline_region_request( resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._offline_region_initial.metadata['url'], + content=_content, + template_url=self._offline_region_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1659,38 +1752,114 @@ def _offline_region_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _offline_region_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/offlineRegion"} # type: ignore - + _offline_region_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/offlineRegion"} # type: ignore - @distributed_trace - def begin_offline_region( # pylint: disable=inconsistent-return-statements + @overload + def begin_offline_region( self, resource_group_name: str, account_name: str, region_parameter_for_offline: _models.RegionForOnlineOffline, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param region_parameter_for_offline: Cosmos DB region to offline for the database account. + Required. :type region_parameter_for_offline: ~azure.mgmt.cosmosdb.models.RegionForOnlineOffline + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_offline_region( + self, + resource_group_name: str, + account_name: str, + region_parameter_for_offline: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param region_parameter_for_offline: Cosmos DB region to offline for the database account. + Required. + :type region_parameter_for_offline: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_offline_region( + self, + resource_group_name: str, + account_name: str, + region_parameter_for_offline: Union[_models.RegionForOnlineOffline, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param region_parameter_for_offline: Cosmos DB region to offline for the database account. Is + either a model type or a IO type. Required. + :type region_parameter_for_offline: ~azure.mgmt.cosmosdb.models.RegionForOnlineOffline or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -1701,20 +1870,17 @@ def begin_offline_region( # pylint: disable=inconsistent-return-statements 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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._offline_region_initial( # type: ignore resource_group_name=resource_group_name, @@ -1722,67 +1888,68 @@ def begin_offline_region( # pylint: disable=inconsistent-return-statements region_parameter_for_offline=region_parameter_for_offline, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_offline_region.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/offlineRegion"} # type: ignore def _online_region_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - region_parameter_for_online: _models.RegionForOnlineOffline, + region_parameter_for_online: Union[_models.RegionForOnlineOffline, IO], **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(region_parameter_for_online, 'RegionForOnlineOffline') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(region_parameter_for_online, (IO, bytes)): + _content = region_parameter_for_online + else: + _json = self._serialize.body(region_parameter_for_online, "RegionForOnlineOffline") - request = build_online_region_request_initial( - subscription_id=self._config.subscription_id, + request = build_online_region_request( resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._online_region_initial.metadata['url'], + content=_content, + template_url=self._online_region_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1790,38 +1957,80 @@ def _online_region_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _online_region_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/onlineRegion"} # type: ignore - + _online_region_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/onlineRegion"} # type: ignore - @distributed_trace - def begin_online_region( # pylint: disable=inconsistent-return-statements + @overload + def begin_online_region( self, resource_group_name: str, account_name: str, region_parameter_for_online: _models.RegionForOnlineOffline, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param region_parameter_for_online: Cosmos DB region to online for the database account. + Required. :type region_parameter_for_online: ~azure.mgmt.cosmosdb.models.RegionForOnlineOffline + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_online_region( + self, + resource_group_name: str, + account_name: str, + region_parameter_for_online: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param region_parameter_for_online: Cosmos DB region to online for the database account. + Required. + :type region_parameter_for_online: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -1832,20 +2041,51 @@ def begin_online_region( # pylint: disable=inconsistent-return-statements 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: + """ + + @distributed_trace + def begin_online_region( + self, + resource_group_name: str, + account_name: str, + region_parameter_for_online: Union[_models.RegionForOnlineOffline, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param region_parameter_for_online: Cosmos DB region to online for the database account. Is + either a model type or a IO type. Required. + :type region_parameter_for_online: ~azure.mgmt.cosmosdb.models.RegionForOnlineOffline or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._online_region_initial( # type: ignore resource_group_name=resource_group_name, @@ -1853,74 +2093,65 @@ def begin_online_region( # pylint: disable=inconsistent-return-statements region_parameter_for_online=region_parameter_for_online, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - **kwargs: Any + self, 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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DatabaseAccountListReadOnlyKeysResult, or the result of cls(response) + :return: DatabaseAccountListReadOnlyKeysResult or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DatabaseAccountListReadOnlyKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountListReadOnlyKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountListReadOnlyKeysResult] - request = build_get_read_only_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_read_only_keys.metadata['url'], + template_url=self.get_read_only_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1928,62 +2159,55 @@ def get_read_only_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatabaseAccountListReadOnlyKeysResult', pipeline_response) + deserialized = self._deserialize("DatabaseAccountListReadOnlyKeysResult", pipeline_response) if cls: 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 - + 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: str, - account_name: str, - **kwargs: Any + self, 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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DatabaseAccountListReadOnlyKeysResult, or the result of cls(response) + :return: DatabaseAccountListReadOnlyKeysResult or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.DatabaseAccountListReadOnlyKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatabaseAccountListReadOnlyKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseAccountListReadOnlyKeysResult] - request = build_list_read_only_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_read_only_keys.metadata['url'], + template_url=self.list_read_only_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1991,55 +2215,58 @@ def list_read_only_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatabaseAccountListReadOnlyKeysResult', pipeline_response) + deserialized = self._deserialize("DatabaseAccountListReadOnlyKeysResult", pipeline_response) if cls: 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 - + list_read_only_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys"} # type: ignore def _regenerate_key_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - key_to_regenerate: _models.DatabaseAccountRegenerateKeyParameters, + key_to_regenerate: Union[_models.DatabaseAccountRegenerateKeyParameters, IO], **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(key_to_regenerate, 'DatabaseAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(key_to_regenerate, (IO, bytes)): + _content = key_to_regenerate + else: + _json = self._serialize.body(key_to_regenerate, "DatabaseAccountRegenerateKeyParameters") - request = build_regenerate_key_request_initial( - subscription_id=self._config.subscription_id, + request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._regenerate_key_initial.metadata['url'], + content=_content, + template_url=self._regenerate_key_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2047,10 +2274,9 @@ def _regenerate_key_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2060,25 +2286,65 @@ def _regenerate_key_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _regenerate_key_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/regenerateKey"} # type: ignore + _regenerate_key_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/regenerateKey"} # type: ignore - - @distributed_trace - def begin_regenerate_key( # pylint: disable=inconsistent-return-statements + @overload + def begin_regenerate_key( self, resource_group_name: str, account_name: str, key_to_regenerate: _models.DatabaseAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param key_to_regenerate: The name of the key to regenerate. + :param key_to_regenerate: The name of the key to regenerate. Required. :type key_to_regenerate: ~azure.mgmt.cosmosdb.models.DatabaseAccountRegenerateKeyParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_regenerate_key( + self, + resource_group_name: str, + account_name: str, + key_to_regenerate: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param key_to_regenerate: The name of the key to regenerate. Required. + :type key_to_regenerate: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -2089,20 +2355,52 @@ def begin_regenerate_key( # pylint: disable=inconsistent-return-statements 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: + """ + + @distributed_trace + def begin_regenerate_key( + self, + resource_group_name: str, + account_name: str, + key_to_regenerate: Union[_models.DatabaseAccountRegenerateKeyParameters, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param key_to_regenerate: The name of the key to regenerate. Is either a model type or a IO + type. Required. + :type key_to_regenerate: ~azure.mgmt.cosmosdb.models.DatabaseAccountRegenerateKeyParameters or + IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._regenerate_key_initial( # type: ignore resource_group_name=resource_group_name, @@ -2110,71 +2408,60 @@ def begin_regenerate_key( # pylint: disable=inconsistent-return-statements key_to_regenerate=key_to_regenerate, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - **kwargs: Any - ) -> bool: + def check_name_exists(self, account_name: str, **kwargs: Any) -> bool: """Checks that the Azure Cosmos DB account name already exists. A valid account name may contain only lowercase letters, numbers, and the '-' character, and must be between 3 and 50 characters. - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) + :return: bool or the result of cls(response) :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_check_name_exists_request( account_name=account_name, api_version=api_version, - template_url=self.check_name_exists.metadata['url'], + template_url=self.check_name_exists.metadata["url"], headers=_headers, params=_params, ) @@ -2182,10 +2469,9 @@ def check_name_exists( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 404]: @@ -2196,52 +2482,47 @@ def check_name_exists( return cls(pipeline_response, None, {}) return 200 <= response.status_code <= 299 - check_name_exists.metadata = {'url': "/providers/Microsoft.DocumentDB/databaseAccountNames/{accountName}"} # type: ignore - + check_name_exists.metadata = {"url": "/providers/Microsoft.DocumentDB/databaseAccountNames/{accountName}"} # type: ignore @distributed_trace def list_metrics( - self, - resource_group_name: str, - account_name: str, - filter: str, - **kwargs: Any - ) -> Iterable[_models.MetricListResult]: + self, resource_group_name: str, account_name: str, filter: str, **kwargs: Any + ) -> Iterable["_models.Metric"]: """Retrieves the metrics determined by the given filter for the given database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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 MetricListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MetricListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Metric or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.Metric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -2249,17 +2530,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -2275,10 +2550,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2288,55 +2561,49 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_metrics.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metrics"} # type: ignore + 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, - account_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable[_models.UsagesResult]: + self, resource_group_name: str, account_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Usage"]: """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param filter: An OData filter expression that describes a subset of usages to return. The supported parameter is name.value (name of the metric, can have an or of multiple names). Default value is None. :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 UsagesResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.UsagesResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsagesResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsagesResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_usages_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_usages.metadata['url'], + api_version=api_version, + template_url=self.list_usages.metadata["url"], headers=_headers, params=_params, ) @@ -2344,17 +2611,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_usages_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -2370,10 +2631,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2383,50 +2642,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/usages"} # type: ignore + 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, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.MetricDefinitionsListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.MetricDefinition"]: """Retrieves metric definitions for the given database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinitionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MetricDefinition or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricDefinitionsListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_metric_definitions_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_metric_definitions.metadata['url'], + template_url=self.list_metric_definitions.metadata["url"], headers=_headers, params=_params, ) @@ -2434,16 +2687,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_metric_definitions_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -2459,10 +2707,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2472,8 +2718,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_metric_definitions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metricDefinitions"} # type: ignore + list_metric_definitions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metricDefinitions"} # type: ignore 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 d34edb940a75..8ecffd1da98a 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,60 +25,58 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 + resource_group_name: str, account_name: str, database_rid: str, subscription_id: str, *, filter: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metrics") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metrics", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_usages_request( - subscription_id: str, resource_group_name: str, account_name: str, database_rid: str, + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any @@ -81,74 +84,73 @@ def build_list_usages_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/usages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/usages", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_metric_definitions_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - database_rid: str, - **kwargs: Any + resource_group_name: str, account_name: str, database_rid: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metricDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metricDefinitions", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DatabaseOperations: """ @@ -169,55 +171,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( - self, - resource_group_name: str, - account_name: str, - database_rid: str, - filter: str, - **kwargs: Any - ) -> Iterable[_models.MetricListResult]: + self, resource_group_name: str, account_name: str, database_rid: str, filter: str, **kwargs: Any + ) -> Iterable["_models.Metric"]: """Retrieves the metrics determined by the given filter for the given database account and database. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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 MetricListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MetricListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Metric or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.Metric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -225,18 +221,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -252,10 +241,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -265,11 +252,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_metrics.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metrics"} # type: ignore + list_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metrics"} # type: ignore @distributed_trace def list_usages( @@ -279,45 +264,45 @@ def list_usages( database_rid: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.UsagesResult]: + ) -> Iterable["_models.Usage"]: """Retrieves the usages (most recent data) for the given database. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str :param filter: An OData filter expression that describes a subset of usages to return. The supported parameter is name.value (name of the metric, can have an or of multiple names). Default value is None. :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 UsagesResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.UsagesResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsagesResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsagesResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_usages.metadata['url'], + api_version=api_version, + template_url=self.list_usages.metadata["url"], headers=_headers, params=_params, ) @@ -325,18 +310,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -352,10 +330,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -365,54 +341,47 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_usages.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/usages"} # type: ignore + 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, - account_name: str, - database_rid: str, - **kwargs: Any - ) -> Iterable[_models.MetricDefinitionsListResult]: + self, resource_group_name: str, account_name: str, database_rid: str, **kwargs: Any + ) -> Iterable["_models.MetricDefinition"]: """Retrieves metric definitions for the given database. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :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.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinitionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MetricDefinition or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MetricDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MetricDefinitionsListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_metric_definitions.metadata['url'], + template_url=self.list_metric_definitions.metadata["url"], headers=_headers, params=_params, ) @@ -420,17 +389,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -446,10 +409,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -459,8 +420,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_metric_definitions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metricDefinitions"} # type: ignore + list_metric_definitions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/metricDefinitions"} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_graph_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_graph_resources_operations.py index e75668084c4e..ab585814024b 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_graph_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_graph_resources_operations.py @@ -6,11 +6,16 @@ # 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 Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,166 +27,155 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_graphs_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_graph_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - graph_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, graph_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}", + ) # pylint: disable=line-too-long 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]+)*'), - "graphName": _SERIALIZER.url("graph_name", graph_name, '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]+)*" + ), + "graphName": _SERIALIZER.url("graph_name", graph_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_create_update_graph_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - graph_name: str, - *, - json: Optional[_models.GraphResourceCreateUpdateParameters] = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_update_graph_request( + resource_group_name: str, account_name: str, graph_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}", + ) # pylint: disable=line-too-long 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]+)*'), - "graphName": _SERIALIZER.url("graph_name", graph_name, '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]+)*" + ), + "graphName": _SERIALIZER.url("graph_name", graph_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_graph_resource_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - graph_name: str, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_graph_resource_request( + resource_group_name: str, account_name: str, graph_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}", + ) # pylint: disable=line-too-long 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]+)*'), - "graphName": _SERIALIZER.url("graph_name", graph_name, '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]+)*" + ), + "graphName": _SERIALIZER.url("graph_name", graph_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) class GraphResourcesOperations: """ @@ -202,45 +196,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_graphs( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.GraphResourcesListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.GraphResourceGetResults"]: """Lists the graphs under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 GraphResourcesListResult or the result of + :return: An iterator like instance of either GraphResourceGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.GraphResourcesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.GraphResourceGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GraphResourcesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GraphResourcesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_graphs_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_graphs.metadata['url'], + template_url=self.list_graphs.metadata["url"], headers=_headers, params=_params, ) @@ -248,16 +238,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_graphs_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -273,10 +258,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -286,53 +269,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_graphs.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs"} # type: ignore + list_graphs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs"} # type: ignore @distributed_trace def get_graph( - self, - resource_group_name: str, - account_name: str, - graph_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, graph_name: str, **kwargs: Any ) -> _models.GraphResourceGetResults: """Gets the Graph resource under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param graph_name: Cosmos DB graph resource name. + :param graph_name: Cosmos DB graph resource name. Required. :type graph_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GraphResourceGetResults, or the result of cls(response) + :return: GraphResourceGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.GraphResourceGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GraphResourceGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GraphResourceGetResults] - request = build_get_graph_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, graph_name=graph_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_graph.metadata['url'], + template_url=self.get_graph.metadata["url"], headers=_headers, params=_params, ) @@ -340,57 +315,60 @@ def get_graph( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GraphResourceGetResults', pipeline_response) + deserialized = self._deserialize("GraphResourceGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_graph.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}"} # type: ignore - + get_graph.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}"} # type: ignore def _create_update_graph_initial( self, resource_group_name: str, account_name: str, graph_name: str, - create_update_graph_parameters: _models.GraphResourceCreateUpdateParameters, + create_update_graph_parameters: Union[_models.GraphResourceCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.GraphResourceGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.GraphResourceGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GraphResourceGetResults]] - _json = self._serialize.body(create_update_graph_parameters, 'GraphResourceCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_graph_parameters, (IO, bytes)): + _content = create_update_graph_parameters + else: + _json = self._serialize.body(create_update_graph_parameters, "GraphResourceCreateUpdateParameters") - request = build_create_update_graph_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_graph_request( resource_group_name=resource_group_name, account_name=account_name, graph_name=graph_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_graph_initial.metadata['url'], + content=_content, + template_url=self._create_update_graph_initial.metadata["url"], headers=_headers, params=_params, ) @@ -398,10 +376,9 @@ def _create_update_graph_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -410,36 +387,42 @@ def _create_update_graph_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GraphResourceGetResults', pipeline_response) + deserialized = self._deserialize("GraphResourceGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_update_graph_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}"} # type: ignore + _create_update_graph_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}"} # type: ignore - - @distributed_trace + @overload def begin_create_update_graph( self, resource_group_name: str, account_name: str, graph_name: str, create_update_graph_parameters: _models.GraphResourceCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GraphResourceGetResults]: """Create or update an Azure Cosmos DB Graph. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param graph_name: Cosmos DB graph resource name. + :param graph_name: Cosmos DB graph resource name. Required. :type graph_name: str :param create_update_graph_parameters: The parameters to provide for the current graph. + Required. :type create_update_graph_parameters: ~azure.mgmt.cosmosdb.models.GraphResourceCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 @@ -451,20 +434,96 @@ def begin_create_update_graph( :return: An instance of LROPoller that returns either GraphResourceGetResults or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GraphResourceGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_update_graph( + self, + resource_group_name: str, + account_name: str, + graph_name: str, + create_update_graph_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GraphResourceGetResults]: + """Create or update an Azure Cosmos DB Graph. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param graph_name: Cosmos DB graph resource name. Required. + :type graph_name: str + :param create_update_graph_parameters: The parameters to provide for the current graph. + Required. + :type create_update_graph_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 GraphResourceGetResults or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GraphResourceGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_update_graph( + self, + resource_group_name: str, + account_name: str, + graph_name: str, + create_update_graph_parameters: Union[_models.GraphResourceCreateUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.GraphResourceGetResults]: + """Create or update an Azure Cosmos DB Graph. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param graph_name: Cosmos DB graph resource name. Required. + :type graph_name: str + :param create_update_graph_parameters: The parameters to provide for the current graph. Is + either a model type or a IO type. Required. + :type create_update_graph_parameters: + ~azure.mgmt.cosmosdb.models.GraphResourceCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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 GraphResourceGetResults or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GraphResourceGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.GraphResourceGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GraphResourceGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_update_graph_initial( # type: ignore resource_group_name=resource_group_name, @@ -473,66 +532,55 @@ def begin_create_update_graph( create_update_graph_parameters=create_update_graph_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('GraphResourceGetResults', pipeline_response) + deserialized = self._deserialize("GraphResourceGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_update_graph.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}"} # type: ignore + begin_create_update_graph.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}"} # type: ignore def _delete_graph_resource_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - graph_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, graph_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_graph_resource_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_graph_resource_request( resource_group_name=resource_group_name, account_name=account_name, graph_name=graph_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_graph_resource_initial.metadata['url'], + template_url=self._delete_graph_resource_initial.metadata["url"], headers=_headers, params=_params, ) @@ -540,10 +588,9 @@ def _delete_graph_resource_initial( # pylint: disable=inconsistent-return-state request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -553,24 +600,20 @@ def _delete_graph_resource_initial( # pylint: disable=inconsistent-return-state if cls: return cls(pipeline_response, None, {}) - _delete_graph_resource_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}"} # type: ignore - + _delete_graph_resource_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}"} # type: ignore @distributed_trace - def begin_delete_graph_resource( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - graph_name: str, - **kwargs: Any + def begin_delete_graph_resource( + self, resource_group_name: str, account_name: str, graph_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an existing Azure Cosmos DB Graph Resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param graph_name: Cosmos DB graph resource name. + :param graph_name: Cosmos DB graph resource name. Required. :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. @@ -582,53 +625,46 @@ def begin_delete_graph_resource( # pylint: disable=inconsistent-return-statemen 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_graph_resource_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, graph_name=graph_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_graph_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}"} # type: ignore + begin_delete_graph_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/graphs/{graphName}"} # type: ignore 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 ad152232b53b..6f736849c394 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 @@ -6,11 +6,16 @@ # 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 Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,714 +27,677 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_gremlin_database_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_gremlin_database_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - database_name: str, - *, - json: Optional[_models.GremlinDatabaseCreateUpdateParameters] = None, - content: Any = None, - **kwargs: Any +def build_create_update_gremlin_database_request( + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_gremlin_database_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any +def build_delete_gremlin_database_request( + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_gremlin_database_throughput_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_gremlin_database_throughput_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - database_name: str, - *, - json: Optional[_models.ThroughputSettingsUpdateParameters] = None, - content: Any = None, - **kwargs: Any +def build_update_gremlin_database_throughput_request( + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **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 +def build_migrate_gremlin_database_to_autoscale_request( + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **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 +def build_migrate_gremlin_database_to_manual_throughput_request( + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_gremlin_graphs_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_gremlin_graph_request( - subscription_id: str, resource_group_name: str, account_name: str, database_name: str, graph_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_gremlin_graph_request_initial( - subscription_id: str, +def build_create_update_gremlin_graph_request( resource_group_name: str, account_name: str, database_name: str, graph_name: str, - *, - json: Optional[_models.GremlinGraphCreateUpdateParameters] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_gremlin_graph_request_initial( - subscription_id: str, +def build_delete_gremlin_graph_request( resource_group_name: str, account_name: str, database_name: str, graph_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_gremlin_graph_throughput_request( - subscription_id: str, resource_group_name: str, account_name: str, database_name: str, graph_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_gremlin_graph_throughput_request_initial( - subscription_id: str, +def build_update_gremlin_graph_throughput_request( resource_group_name: str, account_name: str, database_name: str, graph_name: str, - *, - json: Optional[_models.ThroughputSettingsUpdateParameters] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_gremlin_graph_to_autoscale_request_initial( - subscription_id: str, +def build_migrate_gremlin_graph_to_autoscale_request( resource_group_name: str, account_name: str, database_name: str, graph_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToAutoscale") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToAutoscale", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_gremlin_graph_to_manual_throughput_request_initial( - subscription_id: str, +def build_migrate_gremlin_graph_to_manual_throughput_request( resource_group_name: str, account_name: str, database_name: str, graph_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToManualThroughput") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/throughputSettings/default/migrateToManualThroughput", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_retrieve_continuous_backup_information_request_initial( - subscription_id: str, +def build_retrieve_continuous_backup_information_request( resource_group_name: str, account_name: str, database_name: str, graph_name: str, - *, - json: Optional[_models.ContinuousBackupRestoreLocation] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/retrieveContinuousBackupInformation") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/retrieveContinuousBackupInformation", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class GremlinResourcesOperations: # pylint: disable=too-many-public-methods """ @@ -750,45 +718,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_gremlin_databases( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.GremlinDatabaseListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.GremlinDatabaseGetResults"]: """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 + :return: An iterator like instance of either GremlinDatabaseGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.GremlinDatabaseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.GremlinDatabaseGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GremlinDatabaseListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GremlinDatabaseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_gremlin_databases_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_gremlin_databases.metadata['url'], + template_url=self.list_gremlin_databases.metadata["url"], headers=_headers, params=_params, ) @@ -796,16 +760,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_gremlin_databases_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -821,10 +780,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -834,53 +791,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_gremlin_databases.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases"} # type: ignore + 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: str, - account_name: str, - database_name: str, - **kwargs: Any + self, 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. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GremlinDatabaseGetResults, or the result of cls(response) + :return: GremlinDatabaseGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.GremlinDatabaseGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GremlinDatabaseGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GremlinDatabaseGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_gremlin_database.metadata['url'], + template_url=self.get_gremlin_database.metadata["url"], headers=_headers, params=_params, ) @@ -888,57 +837,62 @@ def get_gremlin_database( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GremlinDatabaseGetResults', pipeline_response) + deserialized = self._deserialize("GremlinDatabaseGetResults", pipeline_response) if cls: 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 - + 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: str, account_name: str, database_name: str, - create_update_gremlin_database_parameters: _models.GremlinDatabaseCreateUpdateParameters, + create_update_gremlin_database_parameters: Union[_models.GremlinDatabaseCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.GremlinDatabaseGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.GremlinDatabaseGetResults]] - - _json = self._serialize.body(create_update_gremlin_database_parameters, 'GremlinDatabaseCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GremlinDatabaseGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_gremlin_database_parameters, (IO, bytes)): + _content = create_update_gremlin_database_parameters + else: + _json = self._serialize.body( + create_update_gremlin_database_parameters, "GremlinDatabaseCreateUpdateParameters" + ) - request = build_create_update_gremlin_database_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_gremlin_database_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_gremlin_database_initial.metadata['url'], + content=_content, + template_url=self._create_update_gremlin_database_initial.metadata["url"], headers=_headers, params=_params, ) @@ -946,10 +900,9 @@ def _create_update_gremlin_database_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -958,37 +911,121 @@ def _create_update_gremlin_database_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GremlinDatabaseGetResults', pipeline_response) + deserialized = self._deserialize("GremlinDatabaseGetResults", pipeline_response) if cls: 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 + _create_update_gremlin_database_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}"} # type: ignore - - @distributed_trace + @overload def begin_create_update_gremlin_database( self, resource_group_name: str, account_name: str, database_name: str, create_update_gremlin_database_parameters: _models.GremlinDatabaseCreateUpdateParameters, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :param create_update_gremlin_database_parameters: The parameters to provide for the current - Gremlin database. + Gremlin database. Required. :type create_update_gremlin_database_parameters: ~azure.mgmt.cosmosdb.models.GremlinDatabaseCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinDatabaseGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_update_gremlin_database( + self, + resource_group_name: str, + account_name: str, + database_name: str, + create_update_gremlin_database_parameters: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param create_update_gremlin_database_parameters: The parameters to provide for the current + Gremlin database. Required. + :type create_update_gremlin_database_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinDatabaseGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_update_gremlin_database( + self, + resource_group_name: str, + account_name: str, + database_name: str, + create_update_gremlin_database_parameters: Union[_models.GremlinDatabaseCreateUpdateParameters, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param create_update_gremlin_database_parameters: The parameters to provide for the current + Gremlin database. Is either a model type or a IO type. Required. + :type create_update_gremlin_database_parameters: + ~azure.mgmt.cosmosdb.models.GremlinDatabaseCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -1000,20 +1037,17 @@ def begin_create_update_gremlin_database( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.GremlinDatabaseGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GremlinDatabaseGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_update_gremlin_database_initial( # type: ignore resource_group_name=resource_group_name, @@ -1022,66 +1056,55 @@ def begin_create_update_gremlin_database( create_update_gremlin_database_parameters=create_update_gremlin_database_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('GremlinDatabaseGetResults', pipeline_response) + deserialized = self._deserialize("GremlinDatabaseGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_gremlin_database_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_gremlin_database_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_gremlin_database_initial.metadata['url'], + template_url=self._delete_gremlin_database_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1089,10 +1112,9 @@ def _delete_gremlin_database_initial( # pylint: disable=inconsistent-return-sta request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1102,24 +1124,20 @@ def _delete_gremlin_database_initial( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - _delete_gremlin_database_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + def begin_delete_gremlin_database( + self, 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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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. @@ -1131,98 +1149,85 @@ def begin_delete_gremlin_database( # pylint: disable=inconsistent-return-statem 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_gremlin_database_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: """Gets the RUs per second of the Gremlin database under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ThroughputSettingsGetResults, or the result of cls(response) + :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_gremlin_database_throughput.metadata['url'], + template_url=self.get_gremlin_database_throughput.metadata["url"], headers=_headers, params=_params, ) @@ -1230,57 +1235,60 @@ def get_gremlin_database_throughput( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + 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: str, account_name: str, database_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IO, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - request = build_update_gremlin_database_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_gremlin_database_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_gremlin_database_throughput_initial.metadata['url'], + content=_content, + template_url=self._update_gremlin_database_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1288,10 +1296,9 @@ def _update_gremlin_database_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1300,37 +1307,121 @@ def _update_gremlin_database_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 + _update_gremlin_database_throughput_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/throughputSettings/default"} # type: ignore - - @distributed_trace + @overload def begin_update_gremlin_database_throughput( self, resource_group_name: str, account_name: str, database_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Update RUs per second of an Azure Cosmos DB Gremlin database. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Gremlin database. + current Gremlin database. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_gremlin_database_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + update_throughput_parameters: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Gremlin database. Required. + :type update_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_gremlin_database_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Gremlin database. Is either a model type or a IO type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -1342,20 +1433,17 @@ def begin_update_gremlin_database_throughput( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._update_gremlin_database_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -1364,66 +1452,55 @@ def begin_update_gremlin_database_throughput( update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_gremlin_database_to_autoscale_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_gremlin_database_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_gremlin_database_to_autoscale_initial.metadata['url'], + template_url=self._migrate_gremlin_database_to_autoscale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1431,10 +1508,9 @@ def _migrate_gremlin_database_to_autoscale_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1443,31 +1519,27 @@ def _migrate_gremlin_database_to_autoscale_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB Gremlin database from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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. @@ -1480,85 +1552,71 @@ def begin_migrate_gremlin_database_to_autoscale( :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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._migrate_gremlin_database_to_autoscale_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_gremlin_database_to_manual_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_gremlin_database_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_gremlin_database_to_manual_throughput_initial.metadata['url'], + template_url=self._migrate_gremlin_database_to_manual_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1566,10 +1624,9 @@ def _migrate_gremlin_database_to_manual_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1578,31 +1635,27 @@ def _migrate_gremlin_database_to_manual_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB Gremlin database from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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. @@ -1615,101 +1668,90 @@ def begin_migrate_gremlin_database_to_manual_throughput( :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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._migrate_gremlin_database_to_manual_throughput_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - account_name: str, - database_name: str, - **kwargs: Any - ) -> Iterable[_models.GremlinGraphListResult]: + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.GremlinGraphGetResults"]: """Lists the Gremlin graph under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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 + :return: An iterator like instance of either GremlinGraphGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.GremlinGraphListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GremlinGraphListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GremlinGraphListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_gremlin_graphs.metadata['url'], + template_url=self.list_gremlin_graphs.metadata["url"], headers=_headers, params=_params, ) @@ -1717,17 +1759,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1743,10 +1779,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1756,56 +1790,47 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + 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: str, - account_name: str, - database_name: str, - graph_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any ) -> _models.GremlinGraphGetResults: """Gets the Gremlin graph under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. + :param graph_name: Cosmos DB graph name. Required. :type graph_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GremlinGraphGetResults, or the result of cls(response) + :return: GremlinGraphGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.GremlinGraphGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GremlinGraphGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GremlinGraphGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_gremlin_graph.metadata['url'], + template_url=self.get_gremlin_graph.metadata["url"], headers=_headers, params=_params, ) @@ -1813,25 +1838,23 @@ def get_gremlin_graph( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GremlinGraphGetResults', pipeline_response) + deserialized = self._deserialize("GremlinGraphGetResults", pipeline_response) if cls: 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 - + 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, @@ -1839,33 +1862,38 @@ def _create_update_gremlin_graph_initial( account_name: str, database_name: str, graph_name: str, - create_update_gremlin_graph_parameters: _models.GremlinGraphCreateUpdateParameters, + create_update_gremlin_graph_parameters: Union[_models.GremlinGraphCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.GremlinGraphGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.GremlinGraphGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.GremlinGraphGetResults]] - _json = self._serialize.body(create_update_gremlin_graph_parameters, 'GremlinGraphCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_gremlin_graph_parameters, (IO, bytes)): + _content = create_update_gremlin_graph_parameters + else: + _json = self._serialize.body(create_update_gremlin_graph_parameters, "GremlinGraphCreateUpdateParameters") - request = build_create_update_gremlin_graph_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_gremlin_graph_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, graph_name=graph_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_gremlin_graph_initial.metadata['url'], + content=_content, + template_url=self._create_update_gremlin_graph_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1873,10 +1901,9 @@ def _create_update_gremlin_graph_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1885,17 +1912,16 @@ def _create_update_gremlin_graph_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GremlinGraphGetResults', pipeline_response) + deserialized = self._deserialize("GremlinGraphGetResults", pipeline_response) if cls: 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 - + _create_update_gremlin_graph_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}"} # type: ignore - @distributed_trace + @overload def begin_create_update_gremlin_graph( self, resource_group_name: str, @@ -1903,22 +1929,28 @@ def begin_create_update_gremlin_graph( database_name: str, graph_name: str, create_update_gremlin_graph_parameters: _models.GremlinGraphCreateUpdateParameters, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. + :param graph_name: Cosmos DB graph name. Required. :type graph_name: str :param create_update_gremlin_graph_parameters: The parameters to provide for the current - Gremlin graph. + Gremlin graph. Required. :type create_update_gremlin_graph_parameters: ~azure.mgmt.cosmosdb.models.GremlinGraphCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :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 @@ -1930,20 +1962,102 @@ def begin_create_update_gremlin_graph( :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: + """ + + @overload + def begin_create_update_gremlin_graph( + self, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + create_update_gremlin_graph_parameters: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param create_update_gremlin_graph_parameters: The parameters to provide for the current + Gremlin graph. Required. + :type create_update_gremlin_graph_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_update_gremlin_graph( + self, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + create_update_gremlin_graph_parameters: Union[_models.GremlinGraphCreateUpdateParameters, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param create_update_gremlin_graph_parameters: The parameters to provide for the current + Gremlin graph. Is either a model type or a IO type. Required. + :type create_update_gremlin_graph_parameters: + ~azure.mgmt.cosmosdb.models.GremlinGraphCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.GremlinGraphGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.GremlinGraphGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GremlinGraphGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_update_gremlin_graph_initial( # type: ignore resource_group_name=resource_group_name, @@ -1953,68 +2067,56 @@ def begin_create_update_gremlin_graph( create_update_gremlin_graph_parameters=create_update_gremlin_graph_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('GremlinGraphGetResults', pipeline_response) + deserialized = self._deserialize("GremlinGraphGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - graph_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_gremlin_graph_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_gremlin_graph_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, graph_name=graph_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_gremlin_graph_initial.metadata['url'], + template_url=self._delete_gremlin_graph_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2022,10 +2124,9 @@ def _delete_gremlin_graph_initial( # pylint: disable=inconsistent-return-statem request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2035,27 +2136,22 @@ def _delete_gremlin_graph_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _delete_gremlin_graph_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - graph_name: str, - **kwargs: Any + def begin_delete_gremlin_graph( + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an existing Azure Cosmos DB Gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. + :param graph_name: Cosmos DB graph name. Required. :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. @@ -2067,19 +2163,16 @@ def begin_delete_gremlin_graph( # pylint: disable=inconsistent-return-statement 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_gremlin_graph_initial( # type: ignore resource_group_name=resource_group_name, @@ -2087,83 +2180,72 @@ def begin_delete_gremlin_graph( # pylint: disable=inconsistent-return-statement database_name=database_name, graph_name=graph_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - database_name: str, - graph_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: """Gets the Gremlin graph throughput under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. + :param graph_name: Cosmos DB graph name. Required. :type graph_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ThroughputSettingsGetResults, or the result of cls(response) + :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_gremlin_graph_throughput.metadata['url'], + template_url=self.get_gremlin_graph_throughput.metadata["url"], headers=_headers, params=_params, ) @@ -2171,25 +2253,23 @@ def get_gremlin_graph_throughput( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + 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, @@ -2197,33 +2277,38 @@ def _update_gremlin_graph_throughput_initial( account_name: str, database_name: str, graph_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IO, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - request = build_update_gremlin_graph_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_gremlin_graph_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, graph_name=graph_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_gremlin_graph_throughput_initial.metadata['url'], + content=_content, + template_url=self._update_gremlin_graph_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2231,10 +2316,9 @@ def _update_gremlin_graph_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2243,17 +2327,16 @@ def _update_gremlin_graph_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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 + @overload def begin_update_gremlin_graph_throughput( self, resource_group_name: str, @@ -2261,22 +2344,28 @@ def begin_update_gremlin_graph_throughput( database_name: str, graph_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Update RUs per second of an Azure Cosmos DB Gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. + :param graph_name: Cosmos DB graph name. Required. :type graph_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current Gremlin graph. + current Gremlin graph. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :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 @@ -2288,20 +2377,102 @@ def begin_update_gremlin_graph_throughput( :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: + """ + + @overload + def begin_update_gremlin_graph_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + update_throughput_parameters: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Gremlin graph. Required. + :type update_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_gremlin_graph_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current Gremlin graph. Is either a model type or a IO type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._update_gremlin_graph_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -2311,68 +2482,56 @@ def begin_update_gremlin_graph_throughput( update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - database_name: str, - graph_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_gremlin_graph_to_autoscale_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_gremlin_graph_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, graph_name=graph_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_gremlin_graph_to_autoscale_initial.metadata['url'], + template_url=self._migrate_gremlin_graph_to_autoscale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2380,10 +2539,9 @@ def _migrate_gremlin_graph_to_autoscale_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2392,34 +2550,29 @@ def _migrate_gremlin_graph_to_autoscale_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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: str, - account_name: str, - database_name: str, - graph_name: str, - **kwargs: Any + self, 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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. + :param graph_name: Cosmos DB graph name. Required. :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. @@ -2432,19 +2585,16 @@ def begin_migrate_gremlin_graph_to_autoscale( :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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._migrate_gremlin_graph_to_autoscale_initial( # type: ignore resource_group_name=resource_group_name, @@ -2452,68 +2602,56 @@ def begin_migrate_gremlin_graph_to_autoscale( database_name=database_name, graph_name=graph_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - database_name: str, - graph_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, graph_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_gremlin_graph_to_manual_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_gremlin_graph_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, graph_name=graph_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_gremlin_graph_to_manual_throughput_initial.metadata['url'], + template_url=self._migrate_gremlin_graph_to_manual_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2521,10 +2659,9 @@ def _migrate_gremlin_graph_to_manual_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2533,34 +2670,29 @@ def _migrate_gremlin_graph_to_manual_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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: str, - account_name: str, - database_name: str, - graph_name: str, - **kwargs: Any + self, 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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. + :param graph_name: Cosmos DB graph name. Required. :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. @@ -2573,19 +2705,16 @@ def begin_migrate_gremlin_graph_to_manual_throughput( :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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._migrate_gremlin_graph_to_manual_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -2593,39 +2722,35 @@ def begin_migrate_gremlin_graph_to_manual_throughput( database_name=database_name, graph_name=graph_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 def _retrieve_continuous_backup_information_initial( self, @@ -2633,33 +2758,38 @@ def _retrieve_continuous_backup_information_initial( account_name: str, database_name: str, graph_name: str, - location: _models.ContinuousBackupRestoreLocation, + location: Union[_models.ContinuousBackupRestoreLocation, IO], **kwargs: Any ) -> Optional[_models.BackupInformation]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.BackupInformation]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.BackupInformation]] - _json = self._serialize.body(location, 'ContinuousBackupRestoreLocation') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(location, (IO, bytes)): + _content = location + else: + _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") - request = build_retrieve_continuous_backup_information_request_initial( - subscription_id=self._config.subscription_id, + request = build_retrieve_continuous_backup_information_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, graph_name=graph_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._retrieve_continuous_backup_information_initial.metadata['url'], + content=_content, + template_url=self._retrieve_continuous_backup_information_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2667,10 +2797,9 @@ def _retrieve_continuous_backup_information_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2679,17 +2808,16 @@ def _retrieve_continuous_backup_information_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BackupInformation', pipeline_response) + deserialized = self._deserialize("BackupInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _retrieve_continuous_backup_information_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/retrieveContinuousBackupInformation"} # type: ignore + _retrieve_continuous_backup_information_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/retrieveContinuousBackupInformation"} # type: ignore - - @distributed_trace + @overload def begin_retrieve_continuous_backup_information( self, resource_group_name: str, @@ -2697,20 +2825,26 @@ def begin_retrieve_continuous_backup_information( database_name: str, graph_name: str, location: _models.ContinuousBackupRestoreLocation, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.BackupInformation]: """Retrieves continuous backup information for a gremlin graph. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param graph_name: Cosmos DB graph name. + :param graph_name: Cosmos DB graph name. Required. :type graph_name: str - :param location: The name of the continuous backup restore location. + :param location: The name of the continuous backup restore location. Required. :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :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 @@ -2722,20 +2856,100 @@ def begin_retrieve_continuous_backup_information( :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: + """ + + @overload + def begin_retrieve_continuous_backup_information( + self, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + location: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a gremlin graph. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param location: The name of the continuous backup restore location. Required. + :type location: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_retrieve_continuous_backup_information( + self, + resource_group_name: str, + account_name: str, + database_name: str, + graph_name: str, + location: Union[_models.ContinuousBackupRestoreLocation, IO], + **kwargs: Any + ) -> LROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a gremlin graph. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param graph_name: Cosmos DB graph name. Required. + :type graph_name: str + :param location: The name of the continuous backup restore location. Is either a model type or + a IO type. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BackupInformation] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupInformation] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._retrieve_continuous_backup_information_initial( # type: ignore resource_group_name=resource_group_name, @@ -2745,36 +2959,34 @@ def begin_retrieve_continuous_backup_information( location=location, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BackupInformation', pipeline_response) + deserialized = self._deserialize("BackupInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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}/gremlinDatabases/{databaseName}/graphs/{graphName}/retrieveContinuousBackupInformation"} # type: ignore + begin_retrieve_continuous_backup_information.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/gremlinDatabases/{databaseName}/graphs/{graphName}/retrieveContinuousBackupInformation"} # 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 44ce57ec5766..a70a1e5e8b65 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,79 +25,66 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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: + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("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), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request( - subscription_id: str, - location: str, - **kwargs: Any -) -> HttpRequest: +def build_get_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}") + _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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + class LocationsOperations: """ @@ -113,36 +105,31 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.LocationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.LocationGetResult"]: """List Cosmos DB locations and their properties. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LocationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.LocationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either LocationGetResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.LocationGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -150,14 +137,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -173,10 +157,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -186,44 +168,36 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations"} # type: ignore @distributed_trace - def get( - self, - location: str, - **kwargs: Any - ) -> _models.LocationGetResult: + def get(self, 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. + Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocationGetResult, or the result of cls(response) + :return: LocationGetResult or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.LocationGetResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocationGetResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocationGetResult] - request = build_get_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -231,22 +205,20 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocationGetResult', pipeline_response) + deserialized = self._deserialize("LocationGetResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}"} # type: ignore - + 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 abc9a1891528..95d8093bf698 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 @@ -6,11 +6,16 @@ # 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 Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,1185 +27,1104 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_mongo_db_database_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_mongo_db_database_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - database_name: str, - *, - json: Optional[_models.MongoDBDatabaseCreateUpdateParameters] = None, - content: Any = None, - **kwargs: Any +def build_create_update_mongo_db_database_request( + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_mongo_db_database_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any +def build_delete_mongo_db_database_request( + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_mongo_db_database_throughput_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_mongo_db_database_throughput_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - database_name: str, - *, - json: Optional[_models.ThroughputSettingsUpdateParameters] = None, - content: Any = None, - **kwargs: Any +def build_update_mongo_db_database_throughput_request( + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **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 +def build_migrate_mongo_db_database_to_autoscale_request( + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **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 +def build_migrate_mongo_db_database_to_manual_throughput_request( + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_mongo_db_container_retrieve_throughput_distribution_request_initial( - subscription_id: str, +def build_mongo_db_container_retrieve_throughput_distribution_request( resource_group_name: str, account_name: str, database_name: str, collection_name: str, - *, - json: Optional[_models.RetrieveThroughputParameters] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/retrieveThroughputDistribution") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/retrieveThroughputDistribution", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_mongo_db_container_redistribute_throughput_request_initial( - subscription_id: str, +def build_mongo_db_container_redistribute_throughput_request( resource_group_name: str, account_name: str, database_name: str, collection_name: str, - *, - json: Optional[_models.RedistributeThroughputParameters] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/redistributeThroughput") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/redistributeThroughput", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_mongo_db_collections_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_mongo_db_collection_request( - subscription_id: str, resource_group_name: str, account_name: str, database_name: str, collection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_mongo_db_collection_request_initial( - subscription_id: str, +def build_create_update_mongo_db_collection_request( resource_group_name: str, account_name: str, database_name: str, collection_name: str, - *, - json: Optional[_models.MongoDBCollectionCreateUpdateParameters] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_mongo_db_collection_request_initial( - subscription_id: str, +def build_delete_mongo_db_collection_request( resource_group_name: str, account_name: str, database_name: str, collection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_list_mongo_db_collection_partition_merge_request_initial( - subscription_id: str, +def build_list_mongo_db_collection_partition_merge_request( resource_group_name: str, account_name: str, database_name: str, collection_name: str, - *, - json: Optional[_models.MergeParameters] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/partitionMerge") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/partitionMerge", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **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, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_mongo_db_collection_throughput_request_initial( - subscription_id: str, +def build_update_mongo_db_collection_throughput_request( resource_group_name: str, account_name: str, database_name: str, collection_name: str, - *, - json: Optional[_models.ThroughputSettingsUpdateParameters] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_mongo_db_collection_to_autoscale_request_initial( - subscription_id: str, +def build_migrate_mongo_db_collection_to_autoscale_request( resource_group_name: str, account_name: str, database_name: str, collection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToAutoscale") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToAutoscale", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_mongo_db_collection_to_manual_throughput_request_initial( - subscription_id: str, +def build_migrate_mongo_db_collection_to_manual_throughput_request( resource_group_name: str, account_name: str, database_name: str, collection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToManualThroughput") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/migrateToManualThroughput", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_mongo_role_definition_request( - mongo_role_definition_id: str, - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + mongo_role_definition_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "mongoRoleDefinitionId": _SERIALIZER.url("mongo_role_definition_id", mongo_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]+)*'), + "mongoRoleDefinitionId": _SERIALIZER.url("mongo_role_definition_id", mongo_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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_mongo_role_definition_request_initial( - mongo_role_definition_id: str, - subscription_id: str, - resource_group_name: str, - account_name: str, - *, - json: Optional[_models.MongoRoleDefinitionCreateUpdateParameters] = None, - content: Any = None, - **kwargs: Any +def build_create_update_mongo_role_definition_request( + mongo_role_definition_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "mongoRoleDefinitionId": _SERIALIZER.url("mongo_role_definition_id", mongo_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]+)*'), + "mongoRoleDefinitionId": _SERIALIZER.url("mongo_role_definition_id", mongo_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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_mongo_role_definition_request_initial( - mongo_role_definition_id: str, - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_mongo_role_definition_request( + mongo_role_definition_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "mongoRoleDefinitionId": _SERIALIZER.url("mongo_role_definition_id", mongo_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]+)*'), + "mongoRoleDefinitionId": _SERIALIZER.url("mongo_role_definition_id", mongo_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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_mongo_role_definitions_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_mongo_user_definition_request( - mongo_user_definition_id: str, - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + mongo_user_definition_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "mongoUserDefinitionId": _SERIALIZER.url("mongo_user_definition_id", mongo_user_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]+)*'), + "mongoUserDefinitionId": _SERIALIZER.url("mongo_user_definition_id", mongo_user_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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_mongo_user_definition_request_initial( - mongo_user_definition_id: str, - subscription_id: str, - resource_group_name: str, - account_name: str, - *, - json: Optional[_models.MongoUserDefinitionCreateUpdateParameters] = None, - content: Any = None, - **kwargs: Any +def build_create_update_mongo_user_definition_request( + mongo_user_definition_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "mongoUserDefinitionId": _SERIALIZER.url("mongo_user_definition_id", mongo_user_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]+)*'), + "mongoUserDefinitionId": _SERIALIZER.url("mongo_user_definition_id", mongo_user_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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) - - -def build_delete_mongo_user_definition_request_initial( - mongo_user_definition_id: str, - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_mongo_user_definition_request( + mongo_user_definition_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "mongoUserDefinitionId": _SERIALIZER.url("mongo_user_definition_id", mongo_user_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]+)*'), + "mongoUserDefinitionId": _SERIALIZER.url("mongo_user_definition_id", mongo_user_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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_mongo_user_definitions_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_retrieve_continuous_backup_information_request_initial( - subscription_id: str, +def build_retrieve_continuous_backup_information_request( resource_group_name: str, account_name: str, database_name: str, collection_name: str, - *, - json: Optional[_models.ContinuousBackupRestoreLocation] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/retrieveContinuousBackupInformation") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/retrieveContinuousBackupInformation", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class MongoDBResourcesOperations: # pylint: disable=too-many-public-methods """ @@ -1221,45 +1145,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_mongo_db_databases( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.MongoDBDatabaseListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.MongoDBDatabaseGetResults"]: """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 + :return: An iterator like instance of either MongoDBDatabaseGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MongoDBDatabaseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MongoDBDatabaseGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoDBDatabaseListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoDBDatabaseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_mongo_db_databases_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_mongo_db_databases.metadata['url'], + template_url=self.list_mongo_db_databases.metadata["url"], headers=_headers, params=_params, ) @@ -1267,16 +1187,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_mongo_db_databases_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1292,10 +1207,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1305,53 +1218,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_mongo_db_databases.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases"} # type: ignore + 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: str, - account_name: str, - database_name: str, - **kwargs: Any + self, 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. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MongoDBDatabaseGetResults, or the result of cls(response) + :return: MongoDBDatabaseGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.MongoDBDatabaseGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoDBDatabaseGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoDBDatabaseGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_mongo_db_database.metadata['url'], + template_url=self.get_mongo_db_database.metadata["url"], headers=_headers, params=_params, ) @@ -1359,57 +1264,62 @@ def get_mongo_db_database( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MongoDBDatabaseGetResults', pipeline_response) + deserialized = self._deserialize("MongoDBDatabaseGetResults", pipeline_response) if cls: 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 - + 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: str, account_name: str, database_name: str, - create_update_mongo_db_database_parameters: _models.MongoDBDatabaseCreateUpdateParameters, + create_update_mongo_db_database_parameters: Union[_models.MongoDBDatabaseCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.MongoDBDatabaseGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MongoDBDatabaseGetResults]] - - _json = self._serialize.body(create_update_mongo_db_database_parameters, 'MongoDBDatabaseCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MongoDBDatabaseGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_mongo_db_database_parameters, (IO, bytes)): + _content = create_update_mongo_db_database_parameters + else: + _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, + request = build_create_update_mongo_db_database_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_mongo_db_database_initial.metadata['url'], + content=_content, + template_url=self._create_update_mongo_db_database_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1417,10 +1327,9 @@ def _create_update_mongo_db_database_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1429,37 +1338,121 @@ def _create_update_mongo_db_database_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MongoDBDatabaseGetResults', pipeline_response) + deserialized = self._deserialize("MongoDBDatabaseGetResults", pipeline_response) if cls: 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 + _create_update_mongo_db_database_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}"} # type: ignore - - @distributed_trace + @overload def begin_create_update_mongo_db_database( self, resource_group_name: str, account_name: str, database_name: str, create_update_mongo_db_database_parameters: _models.MongoDBDatabaseCreateUpdateParameters, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :param create_update_mongo_db_database_parameters: The parameters to provide for the current - MongoDB database. + MongoDB database. Required. :type create_update_mongo_db_database_parameters: ~azure.mgmt.cosmosdb.models.MongoDBDatabaseCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoDBDatabaseGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_update_mongo_db_database( + self, + resource_group_name: str, + account_name: str, + database_name: str, + create_update_mongo_db_database_parameters: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param create_update_mongo_db_database_parameters: The parameters to provide for the current + MongoDB database. Required. + :type create_update_mongo_db_database_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoDBDatabaseGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_update_mongo_db_database( + self, + resource_group_name: str, + account_name: str, + database_name: str, + create_update_mongo_db_database_parameters: Union[_models.MongoDBDatabaseCreateUpdateParameters, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param create_update_mongo_db_database_parameters: The parameters to provide for the current + MongoDB database. Is either a model type or a IO type. Required. + :type create_update_mongo_db_database_parameters: + ~azure.mgmt.cosmosdb.models.MongoDBDatabaseCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -1471,20 +1464,17 @@ def begin_create_update_mongo_db_database( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoDBDatabaseGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoDBDatabaseGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_update_mongo_db_database_initial( # type: ignore resource_group_name=resource_group_name, @@ -1493,66 +1483,55 @@ def begin_create_update_mongo_db_database( create_update_mongo_db_database_parameters=create_update_mongo_db_database_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MongoDBDatabaseGetResults', pipeline_response) + deserialized = self._deserialize("MongoDBDatabaseGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_mongo_db_database_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_mongo_db_database_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_mongo_db_database_initial.metadata['url'], + template_url=self._delete_mongo_db_database_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1560,10 +1539,9 @@ def _delete_mongo_db_database_initial( # pylint: disable=inconsistent-return-st request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -1573,24 +1551,20 @@ def _delete_mongo_db_database_initial( # pylint: disable=inconsistent-return-st if cls: return cls(pipeline_response, None, {}) - _delete_mongo_db_database_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + def begin_delete_mongo_db_database( + self, 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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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. @@ -1602,98 +1576,85 @@ def begin_delete_mongo_db_database( # pylint: disable=inconsistent-return-state 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_mongo_db_database_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: """Gets the RUs per second of the MongoDB database under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ThroughputSettingsGetResults, or the result of cls(response) + :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_mongo_db_database_throughput.metadata['url'], + template_url=self.get_mongo_db_database_throughput.metadata["url"], headers=_headers, params=_params, ) @@ -1701,57 +1662,60 @@ def get_mongo_db_database_throughput( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + 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: str, account_name: str, database_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IO, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - request = build_update_mongo_db_database_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_mongo_db_database_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_mongo_db_database_throughput_initial.metadata['url'], + content=_content, + template_url=self._update_mongo_db_database_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1759,10 +1723,9 @@ def _update_mongo_db_database_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1771,37 +1734,42 @@ def _update_mongo_db_database_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 + _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 + @overload def begin_update_mongo_db_database_throughput( self, resource_group_name: str, account_name: str, database_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current MongoDB database. + current MongoDB database. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :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 @@ -1813,88 +1781,153 @@ def begin_update_mongo_db_database_throughput( :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: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._update_mongo_db_database_throughput_initial( # type: ignore - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - update_throughput_parameters=update_throughput_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) - if cls: + @overload + def begin_update_mongo_db_database_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + update_throughput_parameters: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current MongoDB database. Required. + :type update_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_mongo_db_database_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current MongoDB database. Is either a model type or a IO type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_mongo_db_database_throughput_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + update_throughput_parameters=update_throughput_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) + if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_mongo_db_database_to_autoscale_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_mongo_db_database_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_mongo_db_database_to_autoscale_initial.metadata['url'], + template_url=self._migrate_mongo_db_database_to_autoscale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1902,10 +1935,9 @@ def _migrate_mongo_db_database_to_autoscale_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1914,31 +1946,27 @@ def _migrate_mongo_db_database_to_autoscale_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB MongoDB database from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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. @@ -1951,85 +1979,71 @@ def begin_migrate_mongo_db_database_to_autoscale( :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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._migrate_mongo_db_database_to_autoscale_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_mongo_db_database_to_manual_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_mongo_db_database_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_mongo_db_database_to_manual_throughput_initial.metadata['url'], + template_url=self._migrate_mongo_db_database_to_manual_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2037,10 +2051,9 @@ def _migrate_mongo_db_database_to_manual_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2049,31 +2062,27 @@ def _migrate_mongo_db_database_to_manual_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB MongoDB database from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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. @@ -2086,58 +2095,51 @@ def begin_migrate_mongo_db_database_to_manual_throughput( :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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._migrate_mongo_db_database_to_manual_throughput_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 def _mongo_db_container_retrieve_throughput_distribution_initial( self, @@ -2145,33 +2147,38 @@ def _mongo_db_container_retrieve_throughput_distribution_initial( account_name: str, database_name: str, collection_name: str, - retrieve_throughput_parameters: _models.RetrieveThroughputParameters, + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO], **kwargs: Any ) -> Optional[_models.PhysicalPartitionThroughputInfoResult]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PhysicalPartitionThroughputInfoResult]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PhysicalPartitionThroughputInfoResult]] - _json = self._serialize.body(retrieve_throughput_parameters, 'RetrieveThroughputParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(retrieve_throughput_parameters, (IO, bytes)): + _content = retrieve_throughput_parameters + else: + _json = self._serialize.body(retrieve_throughput_parameters, "RetrieveThroughputParameters") - request = build_mongo_db_container_retrieve_throughput_distribution_request_initial( - subscription_id=self._config.subscription_id, + request = build_mongo_db_container_retrieve_throughput_distribution_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._mongo_db_container_retrieve_throughput_distribution_initial.metadata['url'], + content=_content, + template_url=self._mongo_db_container_retrieve_throughput_distribution_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2179,10 +2186,9 @@ def _mongo_db_container_retrieve_throughput_distribution_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2191,15 +2197,102 @@ def _mongo_db_container_retrieve_throughput_distribution_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PhysicalPartitionThroughputInfoResult', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _mongo_db_container_retrieve_throughput_distribution_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/retrieveThroughputDistribution"} # type: ignore + _mongo_db_container_retrieve_throughput_distribution_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/retrieveThroughputDistribution"} # type: ignore + + @overload + def begin_mongo_db_container_retrieve_throughput_distribution( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + retrieve_throughput_parameters: _models.RetrieveThroughputParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB MongoDB container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current MongoDB container. Required. + :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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 PhysicalPartitionThroughputInfoResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_mongo_db_container_retrieve_throughput_distribution( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + retrieve_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB MongoDB container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current MongoDB container. Required. + :type retrieve_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 PhysicalPartitionThroughputInfoResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_mongo_db_container_retrieve_throughput_distribution( @@ -2208,22 +2301,27 @@ def begin_mongo_db_container_retrieve_throughput_distribution( account_name: str, database_name: str, collection_name: str, - retrieve_throughput_parameters: _models.RetrieveThroughputParameters, + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO], **kwargs: Any ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: """Retrieve throughput distribution for an Azure Cosmos DB MongoDB container. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :type collection_name: str :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current MongoDB container. + distribution for the current MongoDB container. Is either a model type or a IO type. Required. :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -2236,20 +2334,17 @@ def begin_mongo_db_container_retrieve_throughput_distribution( the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PhysicalPartitionThroughputInfoResult] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhysicalPartitionThroughputInfoResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._mongo_db_container_retrieve_throughput_distribution_initial( # type: ignore resource_group_name=resource_group_name, @@ -2259,39 +2354,37 @@ def begin_mongo_db_container_retrieve_throughput_distribution( retrieve_throughput_parameters=retrieve_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PhysicalPartitionThroughputInfoResult', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_mongo_db_container_retrieve_throughput_distribution.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/retrieveThroughputDistribution"} # type: ignore + begin_mongo_db_container_retrieve_throughput_distribution.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/retrieveThroughputDistribution"} # type: ignore def _mongo_db_container_redistribute_throughput_initial( self, @@ -2299,33 +2392,38 @@ def _mongo_db_container_redistribute_throughput_initial( account_name: str, database_name: str, collection_name: str, - redistribute_throughput_parameters: _models.RedistributeThroughputParameters, + redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO], **kwargs: Any ) -> Optional[_models.PhysicalPartitionThroughputInfoResult]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PhysicalPartitionThroughputInfoResult]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PhysicalPartitionThroughputInfoResult]] - _json = self._serialize.body(redistribute_throughput_parameters, 'RedistributeThroughputParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(redistribute_throughput_parameters, (IO, bytes)): + _content = redistribute_throughput_parameters + else: + _json = self._serialize.body(redistribute_throughput_parameters, "RedistributeThroughputParameters") - request = build_mongo_db_container_redistribute_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_mongo_db_container_redistribute_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._mongo_db_container_redistribute_throughput_initial.metadata['url'], + content=_content, + template_url=self._mongo_db_container_redistribute_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2333,10 +2431,9 @@ def _mongo_db_container_redistribute_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2345,17 +2442,16 @@ def _mongo_db_container_redistribute_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PhysicalPartitionThroughputInfoResult', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _mongo_db_container_redistribute_throughput_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/redistributeThroughput"} # type: ignore - + _mongo_db_container_redistribute_throughput_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/redistributeThroughput"} # type: ignore - @distributed_trace + @overload def begin_mongo_db_container_redistribute_throughput( self, resource_group_name: str, @@ -2363,22 +2459,115 @@ def begin_mongo_db_container_redistribute_throughput( database_name: str, collection_name: str, redistribute_throughput_parameters: _models.RedistributeThroughputParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: """Redistribute throughput for an Azure Cosmos DB MongoDB container. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :type collection_name: str :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current MongoDB container. + throughput for the current MongoDB container. Required. :type redistribute_throughput_parameters: ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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 PhysicalPartitionThroughputInfoResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_mongo_db_container_redistribute_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + redistribute_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Redistribute throughput for an Azure Cosmos DB MongoDB container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current MongoDB container. Required. + :type redistribute_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 PhysicalPartitionThroughputInfoResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_mongo_db_container_redistribute_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Redistribute throughput for an Azure Cosmos DB MongoDB container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current MongoDB container. Is either a model type or a IO type. Required. + :type redistribute_throughput_parameters: + ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -2391,20 +2580,17 @@ def begin_mongo_db_container_redistribute_throughput( the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PhysicalPartitionThroughputInfoResult] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhysicalPartitionThroughputInfoResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._mongo_db_container_redistribute_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -2414,82 +2600,76 @@ def begin_mongo_db_container_redistribute_throughput( redistribute_throughput_parameters=redistribute_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PhysicalPartitionThroughputInfoResult', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_mongo_db_container_redistribute_throughput.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/redistributeThroughput"} # type: ignore + begin_mongo_db_container_redistribute_throughput.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/throughputSettings/default/redistributeThroughput"} # type: ignore @distributed_trace def list_mongo_db_collections( - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any - ) -> Iterable[_models.MongoDBCollectionListResult]: + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.MongoDBCollectionGetResults"]: """Lists the MongoDB collection under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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 + :return: An iterator like instance of either MongoDBCollectionGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MongoDBCollectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoDBCollectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoDBCollectionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_mongo_db_collections_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_mongo_db_collections.metadata['url'], + template_url=self.list_mongo_db_collections.metadata["url"], headers=_headers, params=_params, ) @@ -2497,17 +2677,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -2523,10 +2697,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2536,56 +2708,47 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + 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: str, - account_name: str, - database_name: str, - collection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any ) -> _models.MongoDBCollectionGetResults: """Gets the MongoDB collection under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :type collection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MongoDBCollectionGetResults, or the result of cls(response) + :return: MongoDBCollectionGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoDBCollectionGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoDBCollectionGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_mongo_db_collection.metadata['url'], + template_url=self.get_mongo_db_collection.metadata["url"], headers=_headers, params=_params, ) @@ -2593,25 +2756,23 @@ def get_mongo_db_collection( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MongoDBCollectionGetResults', pipeline_response) + deserialized = self._deserialize("MongoDBCollectionGetResults", pipeline_response) if cls: 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 - + 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, @@ -2619,33 +2780,40 @@ def _create_update_mongo_db_collection_initial( account_name: str, database_name: str, collection_name: str, - create_update_mongo_db_collection_parameters: _models.MongoDBCollectionCreateUpdateParameters, + create_update_mongo_db_collection_parameters: Union[_models.MongoDBCollectionCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.MongoDBCollectionGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MongoDBCollectionGetResults]] - - _json = self._serialize.body(create_update_mongo_db_collection_parameters, 'MongoDBCollectionCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MongoDBCollectionGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_mongo_db_collection_parameters, (IO, bytes)): + _content = create_update_mongo_db_collection_parameters + else: + _json = self._serialize.body( + create_update_mongo_db_collection_parameters, "MongoDBCollectionCreateUpdateParameters" + ) - request = build_create_update_mongo_db_collection_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_mongo_db_collection_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_mongo_db_collection_initial.metadata['url'], + content=_content, + template_url=self._create_update_mongo_db_collection_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2653,10 +2821,9 @@ def _create_update_mongo_db_collection_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2665,15 +2832,101 @@ def _create_update_mongo_db_collection_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MongoDBCollectionGetResults', pipeline_response) + deserialized = self._deserialize("MongoDBCollectionGetResults", pipeline_response) if cls: 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 + _create_update_mongo_db_collection_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}"} # type: ignore + + @overload + def begin_create_update_mongo_db_collection( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + create_update_mongo_db_collection_parameters: _models.MongoDBCollectionCreateUpdateParameters, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param create_update_mongo_db_collection_parameters: The parameters to provide for the current + MongoDB Collection. Required. + :type create_update_mongo_db_collection_parameters: + ~azure.mgmt.cosmosdb.models.MongoDBCollectionCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_update_mongo_db_collection( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + create_update_mongo_db_collection_parameters: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param create_update_mongo_db_collection_parameters: The parameters to provide for the current + MongoDB Collection. Required. + :type create_update_mongo_db_collection_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoDBCollectionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_update_mongo_db_collection( @@ -2682,23 +2935,27 @@ def begin_create_update_mongo_db_collection( account_name: str, database_name: str, collection_name: str, - create_update_mongo_db_collection_parameters: _models.MongoDBCollectionCreateUpdateParameters, + create_update_mongo_db_collection_parameters: Union[_models.MongoDBCollectionCreateUpdateParameters, IO], **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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :type collection_name: str :param create_update_mongo_db_collection_parameters: The parameters to provide for the current - MongoDB Collection. + MongoDB Collection. Is either a model type or a IO type. Required. :type create_update_mongo_db_collection_parameters: - ~azure.mgmt.cosmosdb.models.MongoDBCollectionCreateUpdateParameters + ~azure.mgmt.cosmosdb.models.MongoDBCollectionCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -2710,20 +2967,17 @@ def begin_create_update_mongo_db_collection( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoDBCollectionGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoDBCollectionGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_update_mongo_db_collection_initial( # type: ignore resource_group_name=resource_group_name, @@ -2733,68 +2987,56 @@ def begin_create_update_mongo_db_collection( create_update_mongo_db_collection_parameters=create_update_mongo_db_collection_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MongoDBCollectionGetResults', pipeline_response) + deserialized = self._deserialize("MongoDBCollectionGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_mongo_db_collection_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_mongo_db_collection_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_mongo_db_collection_initial.metadata['url'], + template_url=self._delete_mongo_db_collection_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2802,10 +3044,9 @@ def _delete_mongo_db_collection_initial( # pylint: disable=inconsistent-return- request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2815,27 +3056,22 @@ def _delete_mongo_db_collection_initial( # pylint: disable=inconsistent-return- if cls: return cls(pipeline_response, None, {}) - _delete_mongo_db_collection_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - **kwargs: Any + def begin_delete_mongo_db_collection( + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an existing Azure Cosmos DB MongoDB Collection. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :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. @@ -2847,19 +3083,16 @@ def begin_delete_mongo_db_collection( # pylint: disable=inconsistent-return-sta 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_mongo_db_collection_initial( # type: ignore resource_group_name=resource_group_name, @@ -2867,37 +3100,33 @@ def begin_delete_mongo_db_collection( # pylint: disable=inconsistent-return-sta database_name=database_name, collection_name=collection_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_delete_mongo_db_collection.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}"} # type: ignore def _list_mongo_db_collection_partition_merge_initial( self, @@ -2905,33 +3134,38 @@ def _list_mongo_db_collection_partition_merge_initial( account_name: str, database_name: str, collection_name: str, - merge_parameters: _models.MergeParameters, + merge_parameters: Union[_models.MergeParameters, IO], **kwargs: Any ) -> Optional[_models.PhysicalPartitionStorageInfoCollection]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PhysicalPartitionStorageInfoCollection]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PhysicalPartitionStorageInfoCollection]] - _json = self._serialize.body(merge_parameters, 'MergeParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(merge_parameters, (IO, bytes)): + _content = merge_parameters + else: + _json = self._serialize.body(merge_parameters, "MergeParameters") - request = build_list_mongo_db_collection_partition_merge_request_initial( - subscription_id=self._config.subscription_id, + request = build_list_mongo_db_collection_partition_merge_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._list_mongo_db_collection_partition_merge_initial.metadata['url'], + content=_content, + template_url=self._list_mongo_db_collection_partition_merge_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2939,10 +3173,9 @@ def _list_mongo_db_collection_partition_merge_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2951,17 +3184,16 @@ def _list_mongo_db_collection_partition_merge_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PhysicalPartitionStorageInfoCollection', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionStorageInfoCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _list_mongo_db_collection_partition_merge_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/partitionMerge"} # type: ignore - + _list_mongo_db_collection_partition_merge_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/partitionMerge"} # type: ignore - @distributed_trace + @overload def begin_list_mongo_db_collection_partition_merge( self, resource_group_name: str, @@ -2969,20 +3201,111 @@ def begin_list_mongo_db_collection_partition_merge( database_name: str, collection_name: str, merge_parameters: _models.MergeParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.PhysicalPartitionStorageInfoCollection]: """Merges the partitions of a MongoDB Collection. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :type collection_name: str - :param merge_parameters: The parameters for the merge operation. + :param merge_parameters: The parameters for the merge operation. Required. :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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 PhysicalPartitionStorageInfoCollection or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_list_mongo_db_collection_partition_merge( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + merge_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionStorageInfoCollection]: + """Merges the partitions of a MongoDB Collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param merge_parameters: The parameters for the merge operation. Required. + :type merge_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 PhysicalPartitionStorageInfoCollection or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_list_mongo_db_collection_partition_merge( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + merge_parameters: Union[_models.MergeParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionStorageInfoCollection]: + """Merges the partitions of a MongoDB Collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param merge_parameters: The parameters for the merge operation. Is either a model type or a IO + type. Required. + :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -2995,20 +3318,17 @@ def begin_list_mongo_db_collection_partition_merge( the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PhysicalPartitionStorageInfoCollection] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhysicalPartitionStorageInfoCollection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._list_mongo_db_collection_partition_merge_initial( # type: ignore resource_group_name=resource_group_name, @@ -3018,85 +3338,76 @@ def begin_list_mongo_db_collection_partition_merge( merge_parameters=merge_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PhysicalPartitionStorageInfoCollection', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionStorageInfoCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_list_mongo_db_collection_partition_merge.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/partitionMerge"} # type: ignore + begin_list_mongo_db_collection_partition_merge.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbDatabases/{databaseName}/collections/{collectionName}/partitionMerge"} # type: ignore @distributed_trace def get_mongo_db_collection_throughput( - self, - resource_group_name: str, - account_name: str, - database_name: str, - collection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: """Gets the RUs per second of the MongoDB collection under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :type collection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ThroughputSettingsGetResults, or the result of cls(response) + :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_mongo_db_collection_throughput.metadata['url'], + template_url=self.get_mongo_db_collection_throughput.metadata["url"], headers=_headers, params=_params, ) @@ -3104,25 +3415,23 @@ def get_mongo_db_collection_throughput( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + 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, @@ -3130,33 +3439,38 @@ def _update_mongo_db_collection_throughput_initial( account_name: str, database_name: str, collection_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IO, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - request = build_update_mongo_db_collection_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_mongo_db_collection_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_mongo_db_collection_throughput_initial.metadata['url'], + content=_content, + template_url=self._update_mongo_db_collection_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -3164,10 +3478,9 @@ def _update_mongo_db_collection_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3176,17 +3489,16 @@ def _update_mongo_db_collection_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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 + @overload def begin_update_mongo_db_collection_throughput( self, resource_group_name: str, @@ -3194,22 +3506,113 @@ def begin_update_mongo_db_collection_throughput( database_name: str, collection_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Update the RUs per second of an Azure Cosmos DB MongoDB collection. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :type collection_name: str :param update_throughput_parameters: The RUs per second of the parameters to provide for the - current MongoDB collection. + current MongoDB collection. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_mongo_db_collection_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + update_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update the RUs per second of an Azure Cosmos DB MongoDB collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current MongoDB collection. Required. + :type update_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_mongo_db_collection_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update the RUs per second of an Azure Cosmos DB MongoDB collection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param update_throughput_parameters: The RUs per second of the parameters to provide for the + current MongoDB collection. Is either a model type or a IO type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -3221,20 +3624,17 @@ def begin_update_mongo_db_collection_throughput( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._update_mongo_db_collection_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -3244,68 +3644,56 @@ def begin_update_mongo_db_collection_throughput( update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - database_name: str, - collection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_mongo_db_collection_to_autoscale_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_mongo_db_collection_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_mongo_db_collection_to_autoscale_initial.metadata['url'], + template_url=self._migrate_mongo_db_collection_to_autoscale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -3313,10 +3701,9 @@ def _migrate_mongo_db_collection_to_autoscale_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3325,34 +3712,29 @@ def _migrate_mongo_db_collection_to_autoscale_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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: str, - account_name: str, - database_name: str, - collection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB MongoDB collection from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :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. @@ -3365,19 +3747,16 @@ def begin_migrate_mongo_db_collection_to_autoscale( :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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._migrate_mongo_db_collection_to_autoscale_initial( # type: ignore resource_group_name=resource_group_name, @@ -3385,68 +3764,56 @@ def begin_migrate_mongo_db_collection_to_autoscale( database_name=database_name, collection_name=collection_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - database_name: str, - collection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_mongo_db_collection_to_manual_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_mongo_db_collection_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_mongo_db_collection_to_manual_throughput_initial.metadata['url'], + template_url=self._migrate_mongo_db_collection_to_manual_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -3454,10 +3821,9 @@ def _migrate_mongo_db_collection_to_manual_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3466,34 +3832,29 @@ def _migrate_mongo_db_collection_to_manual_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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: str, - account_name: str, - database_name: str, - collection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, collection_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB MongoDB collection from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :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. @@ -3506,19 +3867,16 @@ def begin_migrate_mongo_db_collection_to_manual_throughput( :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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._migrate_mongo_db_collection_to_manual_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -3526,81 +3884,71 @@ def begin_migrate_mongo_db_collection_to_manual_throughput( database_name=database_name, collection_name=collection_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 @distributed_trace def get_mongo_role_definition( - self, - mongo_role_definition_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, mongo_role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.MongoRoleDefinitionGetResults: """Retrieves the properties of an existing Azure Cosmos DB Mongo Role Definition with the given Id. - :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. + :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. :type mongo_role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MongoRoleDefinitionGetResults, or the result of cls(response) + :return: MongoRoleDefinitionGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoRoleDefinitionGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoRoleDefinitionGetResults] - request = build_get_mongo_role_definition_request( mongo_role_definition_id=mongo_role_definition_id, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_mongo_role_definition.metadata['url'], + template_url=self.get_mongo_role_definition.metadata["url"], headers=_headers, params=_params, ) @@ -3608,57 +3956,62 @@ def get_mongo_role_definition( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MongoRoleDefinitionGetResults', pipeline_response) + deserialized = self._deserialize("MongoRoleDefinitionGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_mongo_role_definition.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}"} # type: ignore - + get_mongo_role_definition.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}"} # type: ignore def _create_update_mongo_role_definition_initial( self, mongo_role_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_role_definition_parameters: _models.MongoRoleDefinitionCreateUpdateParameters, + create_update_mongo_role_definition_parameters: Union[_models.MongoRoleDefinitionCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.MongoRoleDefinitionGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MongoRoleDefinitionGetResults]] - - _json = self._serialize.body(create_update_mongo_role_definition_parameters, 'MongoRoleDefinitionCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MongoRoleDefinitionGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_mongo_role_definition_parameters, (IO, bytes)): + _content = create_update_mongo_role_definition_parameters + else: + _json = self._serialize.body( + create_update_mongo_role_definition_parameters, "MongoRoleDefinitionCreateUpdateParameters" + ) - request = build_create_update_mongo_role_definition_request_initial( + request = build_create_update_mongo_role_definition_request( mongo_role_definition_id=mongo_role_definition_id, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_mongo_role_definition_initial.metadata['url'], + content=_content, + template_url=self._create_update_mongo_role_definition_initial.metadata["url"], headers=_headers, params=_params, ) @@ -3666,10 +4019,9 @@ def _create_update_mongo_role_definition_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3678,15 +4030,97 @@ def _create_update_mongo_role_definition_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MongoRoleDefinitionGetResults', pipeline_response) + deserialized = self._deserialize("MongoRoleDefinitionGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_update_mongo_role_definition_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}"} # type: ignore + _create_update_mongo_role_definition_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}"} # type: ignore + + @overload + def begin_create_update_mongo_role_definition( + self, + mongo_role_definition_id: str, + resource_group_name: str, + account_name: str, + create_update_mongo_role_definition_parameters: _models.MongoRoleDefinitionCreateUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MongoRoleDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB Mongo Role Definition. + + :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. + :type mongo_role_definition_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param create_update_mongo_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_mongo_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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 MongoRoleDefinitionGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_update_mongo_role_definition( + self, + mongo_role_definition_id: str, + resource_group_name: str, + account_name: str, + create_update_mongo_role_definition_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MongoRoleDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB Mongo Role Definition. + :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. + :type mongo_role_definition_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param create_update_mongo_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_mongo_role_definition_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 MongoRoleDefinitionGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_update_mongo_role_definition( @@ -3694,21 +4128,25 @@ def begin_create_update_mongo_role_definition( mongo_role_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_role_definition_parameters: _models.MongoRoleDefinitionCreateUpdateParameters, + create_update_mongo_role_definition_parameters: Union[_models.MongoRoleDefinitionCreateUpdateParameters, IO], **kwargs: Any ) -> LROPoller[_models.MongoRoleDefinitionGetResults]: """Creates or updates an Azure Cosmos DB Mongo Role Definition. - :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. + :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. :type mongo_role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param create_update_mongo_role_definition_parameters: The properties required to create or - update a Role Definition. + update a Role Definition. Is either a model type or a IO type. Required. :type create_update_mongo_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionCreateUpdateParameters + ~azure.mgmt.cosmosdb.models.MongoRoleDefinitionCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -3721,20 +4159,17 @@ def begin_create_update_mongo_role_definition( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoRoleDefinitionGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoRoleDefinitionGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_update_mongo_role_definition_initial( # type: ignore mongo_role_definition_id=mongo_role_definition_id, @@ -3743,66 +4178,55 @@ def begin_create_update_mongo_role_definition( create_update_mongo_role_definition_parameters=create_update_mongo_role_definition_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MongoRoleDefinitionGetResults', pipeline_response) + deserialized = self._deserialize("MongoRoleDefinitionGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_update_mongo_role_definition.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}"} # type: ignore + begin_create_update_mongo_role_definition.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}"} # type: ignore def _delete_mongo_role_definition_initial( # pylint: disable=inconsistent-return-statements - self, - mongo_role_definition_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, mongo_role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_mongo_role_definition_request_initial( + request = build_delete_mongo_role_definition_request( mongo_role_definition_id=mongo_role_definition_id, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_mongo_role_definition_initial.metadata['url'], + template_url=self._delete_mongo_role_definition_initial.metadata["url"], headers=_headers, params=_params, ) @@ -3810,10 +4234,9 @@ def _delete_mongo_role_definition_initial( # pylint: disable=inconsistent-retur request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -3823,24 +4246,20 @@ def _delete_mongo_role_definition_initial( # pylint: disable=inconsistent-retur if cls: return cls(pipeline_response, None, {}) - _delete_mongo_role_definition_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}"} # type: ignore - + _delete_mongo_role_definition_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}"} # type: ignore @distributed_trace - def begin_delete_mongo_role_definition( # pylint: disable=inconsistent-return-statements - self, - mongo_role_definition_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + def begin_delete_mongo_role_definition( + self, mongo_role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an existing Azure Cosmos DB Mongo Role Definition. - :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. + :param mongo_role_definition_id: The ID for the Role Definition {dbName.roleName}. Required. :type mongo_role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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. @@ -3852,95 +4271,85 @@ def begin_delete_mongo_role_definition( # pylint: disable=inconsistent-return-s 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_mongo_role_definition_initial( # type: ignore mongo_role_definition_id=mongo_role_definition_id, resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_mongo_role_definition.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}"} # type: ignore + begin_delete_mongo_role_definition.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions/{mongoRoleDefinitionId}"} # type: ignore @distributed_trace def list_mongo_role_definitions( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.MongoRoleDefinitionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.MongoRoleDefinitionGetResults"]: """Retrieves the list of all Azure Cosmos DB Mongo Role Definitions. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 MongoRoleDefinitionListResult or the result of + :return: An iterator like instance of either MongoRoleDefinitionGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MongoRoleDefinitionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoRoleDefinitionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoRoleDefinitionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_mongo_role_definitions_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_mongo_role_definitions.metadata['url'], + template_url=self.list_mongo_role_definitions.metadata["url"], headers=_headers, params=_params, ) @@ -3948,16 +4357,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_mongo_role_definitions_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -3973,10 +4377,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3986,53 +4388,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_mongo_role_definitions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions"} # type: ignore + list_mongo_role_definitions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbRoleDefinitions"} # type: ignore @distributed_trace def get_mongo_user_definition( - self, - mongo_user_definition_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, mongo_user_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.MongoUserDefinitionGetResults: """Retrieves the properties of an existing Azure Cosmos DB Mongo User Definition with the given Id. - :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. + :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. :type mongo_user_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MongoUserDefinitionGetResults, or the result of cls(response) + :return: MongoUserDefinitionGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoUserDefinitionGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoUserDefinitionGetResults] - request = build_get_mongo_user_definition_request( mongo_user_definition_id=mongo_user_definition_id, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_mongo_user_definition.metadata['url'], + template_url=self.get_mongo_user_definition.metadata["url"], headers=_headers, params=_params, ) @@ -4040,57 +4434,62 @@ def get_mongo_user_definition( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('MongoUserDefinitionGetResults', pipeline_response) + deserialized = self._deserialize("MongoUserDefinitionGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_mongo_user_definition.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}"} # type: ignore - + get_mongo_user_definition.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}"} # type: ignore def _create_update_mongo_user_definition_initial( self, mongo_user_definition_id: str, resource_group_name: str, account_name: str, - create_update_mongo_user_definition_parameters: _models.MongoUserDefinitionCreateUpdateParameters, + create_update_mongo_user_definition_parameters: Union[_models.MongoUserDefinitionCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.MongoUserDefinitionGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MongoUserDefinitionGetResults]] - - _json = self._serialize.body(create_update_mongo_user_definition_parameters, 'MongoUserDefinitionCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.MongoUserDefinitionGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_mongo_user_definition_parameters, (IO, bytes)): + _content = create_update_mongo_user_definition_parameters + else: + _json = self._serialize.body( + create_update_mongo_user_definition_parameters, "MongoUserDefinitionCreateUpdateParameters" + ) - request = build_create_update_mongo_user_definition_request_initial( + request = build_create_update_mongo_user_definition_request( mongo_user_definition_id=mongo_user_definition_id, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_mongo_user_definition_initial.metadata['url'], + content=_content, + template_url=self._create_update_mongo_user_definition_initial.metadata["url"], headers=_headers, params=_params, ) @@ -4098,10 +4497,9 @@ def _create_update_mongo_user_definition_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4110,37 +4508,123 @@ def _create_update_mongo_user_definition_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('MongoUserDefinitionGetResults', pipeline_response) + deserialized = self._deserialize("MongoUserDefinitionGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_update_mongo_user_definition_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}"} # type: ignore - + _create_update_mongo_user_definition_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}"} # type: ignore - @distributed_trace + @overload def begin_create_update_mongo_user_definition( self, mongo_user_definition_id: str, resource_group_name: str, account_name: str, create_update_mongo_user_definition_parameters: _models.MongoUserDefinitionCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.MongoUserDefinitionGetResults]: """Creates or updates an Azure Cosmos DB Mongo User Definition. - :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. + :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. :type mongo_user_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param create_update_mongo_user_definition_parameters: The properties required to create or - update a User Definition. + update a User Definition. Required. :type create_update_mongo_user_definition_parameters: ~azure.mgmt.cosmosdb.models.MongoUserDefinitionCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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 MongoUserDefinitionGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_update_mongo_user_definition( + self, + mongo_user_definition_id: str, + resource_group_name: str, + account_name: str, + create_update_mongo_user_definition_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MongoUserDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB Mongo User Definition. + + :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. + :type mongo_user_definition_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param create_update_mongo_user_definition_parameters: The properties required to create or + update a User Definition. Required. + :type create_update_mongo_user_definition_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 MongoUserDefinitionGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_update_mongo_user_definition( + self, + mongo_user_definition_id: str, + resource_group_name: str, + account_name: str, + create_update_mongo_user_definition_parameters: Union[_models.MongoUserDefinitionCreateUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.MongoUserDefinitionGetResults]: + """Creates or updates an Azure Cosmos DB Mongo User Definition. + + :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. + :type mongo_user_definition_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param create_update_mongo_user_definition_parameters: The properties required to create or + update a User Definition. Is either a model type or a IO type. Required. + :type create_update_mongo_user_definition_parameters: + ~azure.mgmt.cosmosdb.models.MongoUserDefinitionCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -4153,20 +4637,17 @@ def begin_create_update_mongo_user_definition( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoUserDefinitionGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoUserDefinitionGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_update_mongo_user_definition_initial( # type: ignore mongo_user_definition_id=mongo_user_definition_id, @@ -4175,66 +4656,55 @@ def begin_create_update_mongo_user_definition( create_update_mongo_user_definition_parameters=create_update_mongo_user_definition_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MongoUserDefinitionGetResults', pipeline_response) + deserialized = self._deserialize("MongoUserDefinitionGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_update_mongo_user_definition.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}"} # type: ignore + begin_create_update_mongo_user_definition.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}"} # type: ignore def _delete_mongo_user_definition_initial( # pylint: disable=inconsistent-return-statements - self, - mongo_user_definition_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, mongo_user_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_mongo_user_definition_request_initial( + request = build_delete_mongo_user_definition_request( mongo_user_definition_id=mongo_user_definition_id, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_mongo_user_definition_initial.metadata['url'], + template_url=self._delete_mongo_user_definition_initial.metadata["url"], headers=_headers, params=_params, ) @@ -4242,10 +4712,9 @@ def _delete_mongo_user_definition_initial( # pylint: disable=inconsistent-retur request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -4255,24 +4724,20 @@ def _delete_mongo_user_definition_initial( # pylint: disable=inconsistent-retur if cls: return cls(pipeline_response, None, {}) - _delete_mongo_user_definition_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}"} # type: ignore - + _delete_mongo_user_definition_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}"} # type: ignore @distributed_trace - def begin_delete_mongo_user_definition( # pylint: disable=inconsistent-return-statements - self, - mongo_user_definition_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + def begin_delete_mongo_user_definition( + self, mongo_user_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an existing Azure Cosmos DB Mongo User Definition. - :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. + :param mongo_user_definition_id: The ID for the User Definition {dbName.userName}. Required. :type mongo_user_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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. @@ -4284,95 +4749,85 @@ def begin_delete_mongo_user_definition( # pylint: disable=inconsistent-return-s 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_mongo_user_definition_initial( # type: ignore mongo_user_definition_id=mongo_user_definition_id, resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_mongo_user_definition.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}"} # type: ignore + begin_delete_mongo_user_definition.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}"} # type: ignore @distributed_trace def list_mongo_user_definitions( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.MongoUserDefinitionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.MongoUserDefinitionGetResults"]: """Retrieves the list of all Azure Cosmos DB Mongo User Definition. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 MongoUserDefinitionListResult or the result of + :return: An iterator like instance of either MongoUserDefinitionGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MongoUserDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.MongoUserDefinitionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MongoUserDefinitionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MongoUserDefinitionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_mongo_user_definitions_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_mongo_user_definitions.metadata['url'], + template_url=self.list_mongo_user_definitions.metadata["url"], headers=_headers, params=_params, ) @@ -4380,16 +4835,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_mongo_user_definitions_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -4405,10 +4855,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4418,11 +4866,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_mongo_user_definitions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions"} # type: ignore + list_mongo_user_definitions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions"} # type: ignore def _retrieve_continuous_backup_information_initial( self, @@ -4430,33 +4876,38 @@ def _retrieve_continuous_backup_information_initial( account_name: str, database_name: str, collection_name: str, - location: _models.ContinuousBackupRestoreLocation, + location: Union[_models.ContinuousBackupRestoreLocation, IO], **kwargs: Any ) -> Optional[_models.BackupInformation]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.BackupInformation]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.BackupInformation]] - _json = self._serialize.body(location, 'ContinuousBackupRestoreLocation') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(location, (IO, bytes)): + _content = location + else: + _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") - request = build_retrieve_continuous_backup_information_request_initial( - subscription_id=self._config.subscription_id, + request = build_retrieve_continuous_backup_information_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, collection_name=collection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._retrieve_continuous_backup_information_initial.metadata['url'], + content=_content, + template_url=self._retrieve_continuous_backup_information_initial.metadata["url"], headers=_headers, params=_params, ) @@ -4464,10 +4915,9 @@ def _retrieve_continuous_backup_information_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4476,17 +4926,16 @@ def _retrieve_continuous_backup_information_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BackupInformation', pipeline_response) + deserialized = self._deserialize("BackupInformation", pipeline_response) if cls: 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 + _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 + @overload def begin_retrieve_continuous_backup_information( self, resource_group_name: str, @@ -4494,20 +4943,68 @@ def begin_retrieve_continuous_backup_information( database_name: str, collection_name: str, location: _models.ContinuousBackupRestoreLocation, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param collection_name: Cosmos DB collection name. + :param collection_name: Cosmos DB collection name. Required. :type collection_name: str - :param location: The name of the continuous backup restore location. + :param location: The name of the continuous backup restore location. Required. :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_retrieve_continuous_backup_information( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + location: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param location: The name of the continuous backup restore location. Required. + :type location: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -4519,20 +5016,58 @@ def begin_retrieve_continuous_backup_information( :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: + """ + + @distributed_trace + def begin_retrieve_continuous_backup_information( + self, + resource_group_name: str, + account_name: str, + database_name: str, + collection_name: str, + location: Union[_models.ContinuousBackupRestoreLocation, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param collection_name: Cosmos DB collection name. Required. + :type collection_name: str + :param location: The name of the continuous backup restore location. Is either a model type or + a IO type. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BackupInformation] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupInformation] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._retrieve_continuous_backup_information_initial( # type: ignore resource_group_name=resource_group_name, @@ -4542,36 +5077,34 @@ def begin_retrieve_continuous_backup_information( location=location, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BackupInformation', pipeline_response) + deserialized = self._deserialize("BackupInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 ffd35783777b..b9ee13fb35cf 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 @@ -6,11 +6,16 @@ # 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 Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,290 +27,293 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, account_name: str, notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, account_name: str, notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], - *, - json: Optional[_models.NotebookWorkspaceCreateUpdateParameters] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, account_name: str, notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_connection_info_request( - subscription_id: str, resource_group_name: str, account_name: str, notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/listConnectionInfo") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/listConnectionInfo", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_regenerate_auth_token_request_initial( - subscription_id: str, +def build_regenerate_auth_token_request( resource_group_name: str, account_name: str, notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/regenerateAuthToken") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/regenerateAuthToken", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_start_request_initial( - subscription_id: str, +def build_start_request( resource_group_name: str, account_name: str, notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/start") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/start", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class NotebookWorkspacesOperations: """ @@ -326,45 +334,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_database_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.NotebookWorkspaceListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.NotebookWorkspace"]: """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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.paging.ItemPaged[~azure.mgmt.cosmosdb.models.NotebookWorkspaceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either NotebookWorkspace or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.NotebookWorkspace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NotebookWorkspaceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NotebookWorkspaceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_database_account_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_database_account.metadata['url'], + template_url=self.list_by_database_account.metadata["url"], headers=_headers, params=_params, ) @@ -372,16 +375,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_database_account_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -397,10 +395,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -411,11 +407,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_database_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces"} # type: ignore + list_by_database_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces"} # type: ignore @distributed_trace def get( @@ -428,35 +422,34 @@ def get( """Gets the notebook workspace for a Cosmos DB account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param notebook_workspace_name: The name of the notebook workspace resource. + :param notebook_workspace_name: The name of the notebook workspace resource. "default" + Required. :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 - :return: NotebookWorkspace, or the result of cls(response) + :return: NotebookWorkspace or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.NotebookWorkspace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NotebookWorkspace] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NotebookWorkspace] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -464,10 +457,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -475,47 +467,51 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NotebookWorkspace', pipeline_response) + deserialized = self._deserialize("NotebookWorkspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}"} # type: ignore - + 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: str, account_name: str, notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], - notebook_create_update_parameters: _models.NotebookWorkspaceCreateUpdateParameters, + notebook_create_update_parameters: Union[_models.NotebookWorkspaceCreateUpdateParameters, IO], **kwargs: Any ) -> _models.NotebookWorkspace: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NotebookWorkspace] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NotebookWorkspace] - _json = self._serialize.body(notebook_create_update_parameters, 'NotebookWorkspaceCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(notebook_create_update_parameters, (IO, bytes)): + _content = notebook_create_update_parameters + else: + _json = self._serialize.body(notebook_create_update_parameters, "NotebookWorkspaceCreateUpdateParameters") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, notebook_workspace_name=notebook_workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -523,47 +519,94 @@ def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NotebookWorkspace', pipeline_response) + deserialized = self._deserialize("NotebookWorkspace", pipeline_response) if cls: 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 + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, account_name: str, notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], notebook_create_update_parameters: _models.NotebookWorkspaceCreateUpdateParameters, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param notebook_workspace_name: The name of the notebook workspace resource. + :param notebook_workspace_name: The name of the notebook workspace resource. "default" + Required. :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. + database account. Required. :type notebook_create_update_parameters: ~azure.mgmt.cosmosdb.models.NotebookWorkspaceCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.NotebookWorkspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + notebook_create_update_parameters: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param notebook_workspace_name: The name of the notebook workspace resource. "default" + Required. + :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. Required. + :type notebook_create_update_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -575,20 +618,57 @@ def begin_create_or_update( :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: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], + notebook_create_update_parameters: Union[_models.NotebookWorkspaceCreateUpdateParameters, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param notebook_workspace_name: The name of the notebook workspace resource. "default" + Required. + :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. Is either a model type or a IO type. Required. + :type notebook_create_update_parameters: + ~azure.mgmt.cosmosdb.models.NotebookWorkspaceCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.NotebookWorkspace] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.NotebookWorkspace] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NotebookWorkspace] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -597,39 +677,35 @@ def begin_create_or_update( notebook_create_update_parameters=notebook_create_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('NotebookWorkspace', pipeline_response) + deserialized = self._deserialize("NotebookWorkspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -638,25 +714,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, notebook_workspace_name=notebook_workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -664,24 +737,23 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, account_name: str, @@ -691,10 +763,12 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes the notebook workspace for a Cosmos DB account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param notebook_workspace_name: The name of the notebook workspace resource. + :param notebook_workspace_name: The name of the notebook workspace resource. "default" + Required. :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. @@ -706,56 +780,49 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, notebook_workspace_name=notebook_workspace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}"} # type: ignore @distributed_trace def list_connection_info( @@ -768,35 +835,34 @@ def list_connection_info( """Retrieves the connection info for the notebook workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param notebook_workspace_name: The name of the notebook workspace resource. + :param notebook_workspace_name: The name of the notebook workspace resource. "default" + Required. :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 - :return: NotebookWorkspaceConnectionInfoResult, or the result of cls(response) + :return: NotebookWorkspaceConnectionInfoResult or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.NotebookWorkspaceConnectionInfoResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.NotebookWorkspaceConnectionInfoResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.NotebookWorkspaceConnectionInfoResult] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_connection_info.metadata['url'], + template_url=self.list_connection_info.metadata["url"], headers=_headers, params=_params, ) @@ -804,10 +870,9 @@ def list_connection_info( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -815,15 +880,14 @@ def list_connection_info( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NotebookWorkspaceConnectionInfoResult', pipeline_response) + deserialized = self._deserialize("NotebookWorkspaceConnectionInfoResult", pipeline_response) if cls: 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 - + list_connection_info.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/listConnectionInfo"} # type: ignore def _regenerate_auth_token_initial( # pylint: disable=inconsistent-return-statements self, @@ -832,25 +896,22 @@ def _regenerate_auth_token_initial( # pylint: disable=inconsistent-return-state notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_regenerate_auth_token_request_initial( - subscription_id=self._config.subscription_id, + request = build_regenerate_auth_token_request( resource_group_name=resource_group_name, account_name=account_name, notebook_workspace_name=notebook_workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._regenerate_auth_token_initial.metadata['url'], + template_url=self._regenerate_auth_token_initial.metadata["url"], headers=_headers, params=_params, ) @@ -858,24 +919,23 @@ def _regenerate_auth_token_initial( # pylint: disable=inconsistent-return-state request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) 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 - + _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( # pylint: disable=inconsistent-return-statements + def begin_regenerate_auth_token( self, resource_group_name: str, account_name: str, @@ -885,10 +945,12 @@ def begin_regenerate_auth_token( # pylint: disable=inconsistent-return-statemen """Regenerates the auth token for the notebook workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param notebook_workspace_name: The name of the notebook workspace resource. + :param notebook_workspace_name: The name of the notebook workspace resource. "default" + Required. :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. @@ -900,56 +962,49 @@ def begin_regenerate_auth_token( # pylint: disable=inconsistent-return-statemen 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._regenerate_auth_token_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, notebook_workspace_name=notebook_workspace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_regenerate_auth_token.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/regenerateAuthToken"} # type: ignore def _start_initial( # pylint: disable=inconsistent-return-statements self, @@ -958,25 +1013,22 @@ def _start_initial( # pylint: disable=inconsistent-return-statements notebook_workspace_name: Union[str, "_models.NotebookWorkspaceName"], **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + request = build_start_request( resource_group_name=resource_group_name, account_name=account_name, notebook_workspace_name=notebook_workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], headers=_headers, params=_params, ) @@ -984,24 +1036,23 @@ def _start_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) 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 - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/notebookWorkspaces/{notebookWorkspaceName}/start"} # type: ignore @distributed_trace - def begin_start( # pylint: disable=inconsistent-return-statements + def begin_start( self, resource_group_name: str, account_name: str, @@ -1011,10 +1062,12 @@ def begin_start( # pylint: disable=inconsistent-return-statements """Starts the notebook workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param notebook_workspace_name: The name of the notebook workspace resource. + :param notebook_workspace_name: The name of the notebook workspace resource. "default" + Required. :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. @@ -1026,53 +1079,46 @@ def begin_start( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, notebook_workspace_name=notebook_workspace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 31b1a9325c38..738db039f162 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,38 +25,34 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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: + +def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.DocumentDB/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,35 +73,30 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """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 - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -108,13 +104,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -130,10 +124,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -143,8 +135,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.DocumentDB/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.DocumentDB/operations"} # type: ignore 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 87d749d984c7..9350570eb58e 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,20 +25,23 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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, + subscription_id: str, *, filter: str, **kwargs: Any @@ -41,36 +49,38 @@ def build_list_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/metrics") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/metrics", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PartitionKeyRangeIdOperations: """ @@ -91,7 +101,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( self, @@ -102,52 +111,51 @@ def list_metrics( partition_key_range_id: str, filter: str, **kwargs: Any - ) -> Iterable[_models.PartitionMetricListResult]: + ) -> Iterable["_models.PartitionMetric"]: """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param collection_rid: Cosmos DB collection rid. + :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str - :param partition_key_range_id: Partition Key Range Id for which to get data. + :param partition_key_range_id: Partition Key Range Id for which to get data. Required. :type partition_key_range_id: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetricListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PartitionMetric or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PartitionMetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartitionMetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -155,20 +163,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -184,10 +183,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -197,8 +194,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_metrics.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/metrics"} # type: ignore + list_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/metrics"} # type: ignore 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 d357524bedff..b9c0836890cb 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,21 +25,24 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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, + subscription_id: str, *, filter: str, **kwargs: Any @@ -42,37 +50,39 @@ def build_list_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("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") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/metrics", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PartitionKeyRangeIdRegionOperations: """ @@ -93,7 +103,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( self, @@ -105,56 +114,55 @@ def list_metrics( partition_key_range_id: str, filter: str, **kwargs: Any - ) -> Iterable[_models.PartitionMetricListResult]: + ) -> Iterable["_models.PartitionMetric"]: """Retrieves the metrics determined by the given filter for the given partition key range id and region. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param region: Cosmos DB region, with spaces between words and each word capitalized. + :param region: Cosmos DB region, with spaces between words and each word capitalized. Required. :type region: str - :param database_rid: Cosmos DB database rid. + :param database_rid: Cosmos DB database rid. Required. :type database_rid: str - :param collection_rid: Cosmos DB collection rid. + :param collection_rid: Cosmos DB collection rid. Required. :type collection_rid: str - :param partition_key_range_id: Partition Key Range Id for which to get data. + :param partition_key_range_id: Partition Key Range Id for which to get data. Required. :type partition_key_range_id: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetricListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PartitionMetric or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PartitionMetric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PartitionMetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartitionMetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -162,21 +170,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -192,10 +190,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -205,8 +201,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_metrics.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/metrics"} # type: ignore + list_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/region/{region}/databases/{databaseRid}/collections/{collectionRid}/partitionKeyRangeId/{partitionKeyRangeId}/metrics"} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_patch.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_patch.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. 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 d9c54b2384dc..f1145e5b7510 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,51 +25,51 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 + resource_group_name: str, account_name: str, subscription_id: str, *, filter: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/percentile/metrics") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/percentile/metrics", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PercentileOperations: """ @@ -85,52 +90,46 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( - self, - resource_group_name: str, - account_name: str, - filter: str, - **kwargs: Any - ) -> Iterable[_models.PercentileMetricListResult]: + self, resource_group_name: str, account_name: str, filter: str, **kwargs: Any + ) -> Iterable["_models.PercentileMetric"]: """Retrieves the metrics determined by the given filter for the given database account. This url is only for PBS and Replication Latency data. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PercentileMetricListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PercentileMetric or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PercentileMetric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PercentileMetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PercentileMetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_metrics_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -138,17 +137,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_metrics_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -164,10 +157,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -177,8 +168,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_metrics.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/percentile/metrics"} # type: ignore + list_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/percentile/metrics"} # type: ignore 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 347fc0d54830..749dd24d8e7c 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,19 +25,22 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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, + subscription_id: str, *, filter: str, **kwargs: Any @@ -40,35 +48,37 @@ def build_list_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("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") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sourceRegion/{sourceRegion}/targetRegion/{targetRegion}/percentile/metrics", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PercentileSourceTargetOperations: """ @@ -89,7 +99,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( self, @@ -99,52 +108,51 @@ def list_metrics( target_region: str, filter: str, **kwargs: Any - ) -> Iterable[_models.PercentileMetricListResult]: + ) -> Iterable["_models.PercentileMetric"]: """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. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param source_region: Source region from which data is written. Cosmos DB region, with spaces - between words and each word capitalized. + between words and each word capitalized. Required. :type source_region: str :param target_region: Target region to which data is written. Cosmos DB region, with spaces - between words and each word capitalized. + between words and each word capitalized. Required. :type target_region: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PercentileMetricListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PercentileMetric or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PercentileMetric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PercentileMetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PercentileMetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -152,19 +160,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -180,10 +180,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -193,8 +191,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_metrics.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sourceRegion/{sourceRegion}/targetRegion/{targetRegion}/percentile/metrics"} # type: ignore + list_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sourceRegion/{sourceRegion}/targetRegion/{targetRegion}/percentile/metrics"} # type: ignore 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 48141cd4f6b9..9802e1f2da84 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,53 +25,52 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 + resource_group_name: str, account_name: str, target_region: str, subscription_id: str, *, filter: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/targetRegion/{targetRegion}/percentile/metrics") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/targetRegion/{targetRegion}/percentile/metrics", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PercentileTargetOperations: """ @@ -87,57 +91,50 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_metrics( - self, - resource_group_name: str, - account_name: str, - target_region: str, - filter: str, - **kwargs: Any - ) -> Iterable[_models.PercentileMetricListResult]: + self, resource_group_name: str, account_name: str, target_region: str, filter: str, **kwargs: Any + ) -> Iterable["_models.PercentileMetric"]: """Retrieves the metrics determined by the given filter for the given account target region. This url is only for PBS and Replication Latency data. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param target_region: Target region to which data is written. Cosmos DB region, with spaces - between words and each word capitalized. + between words and each word capitalized. Required. :type target_region: str :param filter: An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple - names), startTime, endTime, and timeGrain. The supported operator is eq. + names), startTime, endTime, and timeGrain. The supported operator is eq. Required. :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.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PercentileMetricListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PercentileMetric or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PercentileMetric] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PercentileMetricListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PercentileMetricListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_metrics.metadata['url'], + api_version=api_version, + template_url=self.list_metrics.metadata["url"], headers=_headers, params=_params, ) @@ -145,18 +142,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -172,10 +162,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -185,8 +173,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_metrics.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/targetRegion/{targetRegion}/percentile/metrics"} # type: ignore + list_metrics.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/targetRegion/{targetRegion}/percentile/metrics"} # type: ignore 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 efd28161be39..be88ad84b720 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 @@ -6,11 +6,16 @@ # 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 Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,173 +27,179 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateEndpointConnectionsOperations: """ @@ -209,46 +220,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_database_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_database_account_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_database_account.metadata['url'], + template_url=self.list_by_database_account.metadata["url"], headers=_headers, params=_params, ) @@ -256,16 +262,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_database_account_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -281,10 +282,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -294,52 +293,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_database_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections"} # type: ignore + 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: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, 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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -347,57 +338,60 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + 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: str, account_name: str, private_endpoint_connection_name: str, - parameters: _models.PrivateEndpointConnection, + parameters: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any ) -> Optional[_models.PrivateEndpointConnection]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -405,47 +399,91 @@ def _create_or_update_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: 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 - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.cosmosdb.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -457,20 +495,54 @@ def begin_create_or_update( :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: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.cosmosdb.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, @@ -479,66 +551,55 @@ def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -546,37 +607,33 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + def begin_delete( + self, 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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :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. @@ -588,53 +645,46 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 4bdf6856f4c9..a4d84f2760f6 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,87 +25,86 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - group_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources/{groupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources/{groupName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateLinkResourcesOperations: """ @@ -121,45 +125,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_database_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateLinkResourceListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_database_account_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_database_account.metadata['url'], + template_url=self.list_by_database_account.metadata["url"], headers=_headers, params=_params, ) @@ -167,16 +166,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_database_account_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -192,10 +186,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -205,52 +197,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_database_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources"} # type: ignore + 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: str, - account_name: str, - group_name: str, - **kwargs: Any + self, 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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param group_name: The name of the private link resource. + :param group_name: The name of the private link resource. Required. :type group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResource, or the result of cls(response) + :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, group_name=group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -258,22 +242,20 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResource', pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/privateLinkResources/{groupName}"} # type: ignore - + 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 c78d19a1ee23..05dd53aa347b 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,116 +25,98 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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: + +def build_list_by_location_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "location": _SERIALIZER.url("location", location, 'str'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/restorableDatabaseAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/restorableDatabaseAccounts" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_get_by_location_request( - subscription_id: str, - location: str, - instance_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_by_location_request(location: str, instance_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class RestorableDatabaseAccountsOperations: """ @@ -150,44 +137,39 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> Iterable[_models.RestorableDatabaseAccountsListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.RestorableDatabaseAccountGetResult"]: """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. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :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 + :return: An iterator like instance of either RestorableDatabaseAccountGetResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableDatabaseAccountsListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableDatabaseAccountsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -195,15 +177,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -219,10 +197,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -232,44 +208,38 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.RestorableDatabaseAccountsListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.RestorableDatabaseAccountGetResult"]: """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 + :return: An iterator like instance of either RestorableDatabaseAccountGetResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableDatabaseAccountsListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableDatabaseAccountsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -277,14 +247,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -300,10 +267,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -313,49 +278,42 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/restorableDatabaseAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/restorableDatabaseAccounts"} # type: ignore @distributed_trace def get_by_location( - self, - location: str, - instance_id: str, - **kwargs: Any + self, location: str, instance_id: str, **kwargs: Any ) -> _models.RestorableDatabaseAccountGetResult: """Retrieves the properties of an existing Azure Cosmos DB restorable database account. This call requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/read/*' permission. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :type instance_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RestorableDatabaseAccountGetResult, or the result of cls(response) + :return: RestorableDatabaseAccountGetResult or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.RestorableDatabaseAccountGetResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableDatabaseAccountGetResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableDatabaseAccountGetResult] - request = build_get_by_location_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_by_location.metadata['url'], + template_url=self.get_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -363,22 +321,20 @@ def get_by_location( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('RestorableDatabaseAccountGetResult', pipeline_response) + deserialized = self._deserialize("RestorableDatabaseAccountGetResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}"} # type: ignore - + 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_gremlin_databases_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_gremlin_databases_operations.py index 1dbc52942061..25decee5e44a 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_gremlin_databases_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_gremlin_databases_operations.py @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,48 +25,44 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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: + +def build_list_request(location: str, instance_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableGremlinDatabases") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableGremlinDatabases", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class RestorableGremlinDatabasesOperations: """ @@ -82,49 +83,45 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - location: str, - instance_id: str, - **kwargs: Any - ) -> Iterable[_models.RestorableGremlinDatabasesListResult]: + self, location: str, instance_id: str, **kwargs: Any + ) -> Iterable["_models.RestorableGremlinDatabaseGetResult"]: """Show the event feed of all mutations done on all the Azure Cosmos DB Gremlin databases under the restorable account. This helps in scenario where database was accidentally deleted to get the deletion time. This API requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :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 RestorableGremlinDatabasesListResult or the result + :return: An iterator like instance of either RestorableGremlinDatabaseGetResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableGremlinDatabasesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableGremlinDatabaseGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableGremlinDatabasesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableGremlinDatabasesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -132,16 +129,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -157,10 +149,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -170,8 +160,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableGremlinDatabases"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableGremlinDatabases"} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_gremlin_graphs_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_gremlin_graphs_operations.py index f83734c11f77..59c4206f65cc 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_gremlin_graphs_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_gremlin_graphs_operations.py @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,17 +25,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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, + subscription_id: str, *, restorable_gremlin_database_rid: Optional[str] = None, start_time: Optional[str] = None, @@ -40,38 +48,38 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableGraphs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableGraphs", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if restorable_gremlin_database_rid is not None: - _params['restorableGremlinDatabaseRid'] = _SERIALIZER.query("restorable_gremlin_database_rid", restorable_gremlin_database_rid, 'str') + _params["restorableGremlinDatabaseRid"] = _SERIALIZER.query( + "restorable_gremlin_database_rid", restorable_gremlin_database_rid, "str" + ) if start_time is not None: - _params['startTime'] = _SERIALIZER.query("start_time", start_time, 'str') + _params["startTime"] = _SERIALIZER.query("start_time", start_time, "str") if end_time is not None: - _params['endTime'] = _SERIALIZER.query("end_time", end_time, 'str') + _params["endTime"] = _SERIALIZER.query("end_time", end_time, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class RestorableGremlinGraphsOperations: """ @@ -92,7 +100,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -102,14 +109,15 @@ def list( start_time: Optional[str] = None, end_time: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.RestorableGremlinGraphsListResult]: + ) -> Iterable["_models.RestorableGremlinGraphGetResult"]: """Show the event feed of all mutations done on all the Azure Cosmos DB Gremlin graphs under a specific database. This helps in scenario where container was accidentally deleted. This API requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :type instance_id: str :param restorable_gremlin_database_rid: The resource ID of the Gremlin database. Default value is None. @@ -119,34 +127,33 @@ def list( :param end_time: Restorable Gremlin graphs event feed end time. Default value is None. :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 RestorableGremlinGraphsListResult or the result of + :return: An iterator like instance of either RestorableGremlinGraphGetResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableGremlinGraphsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableGremlinGraphGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableGremlinGraphsListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableGremlinGraphsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, - api_version=api_version, + subscription_id=self._config.subscription_id, restorable_gremlin_database_rid=restorable_gremlin_database_rid, start_time=start_time, end_time=end_time, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -154,19 +161,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - restorable_gremlin_database_rid=restorable_gremlin_database_rid, - start_time=start_time, - end_time=end_time, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -182,10 +181,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -195,8 +192,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableGraphs"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableGraphs"} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_gremlin_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_gremlin_resources_operations.py index 4b56b858cc59..10b53953ce37 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_gremlin_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_gremlin_resources_operations.py @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,17 +25,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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, + subscription_id: str, *, restore_location: Optional[str] = None, restore_timestamp_in_utc: Optional[str] = None, @@ -39,36 +47,36 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableGremlinResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableGremlinResources", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if restore_location is not None: - _params['restoreLocation'] = _SERIALIZER.query("restore_location", restore_location, 'str') + _params["restoreLocation"] = _SERIALIZER.query("restore_location", restore_location, "str") if restore_timestamp_in_utc is not None: - _params['restoreTimestampInUtc'] = _SERIALIZER.query("restore_timestamp_in_utc", restore_timestamp_in_utc, 'str') + _params["restoreTimestampInUtc"] = _SERIALIZER.query( + "restore_timestamp_in_utc", restore_timestamp_in_utc, "str" + ) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class RestorableGremlinResourcesOperations: """ @@ -89,7 +97,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -98,15 +105,16 @@ def list( restore_location: Optional[str] = None, restore_timestamp_in_utc: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.RestorableGremlinResourcesListResult]: + ) -> Iterable["_models.RestorableGremlinResourcesGetResult"]: """Return a list of gremlin database and graphs 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 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :type instance_id: str :param restore_location: The location where the restorable resources are located. Default value is None. @@ -115,33 +123,32 @@ def list( value is None. :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 RestorableGremlinResourcesListResult or the result + :return: An iterator like instance of either RestorableGremlinResourcesGetResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableGremlinResourcesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableGremlinResourcesGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableGremlinResourcesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableGremlinResourcesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, - api_version=api_version, + subscription_id=self._config.subscription_id, restore_location=restore_location, restore_timestamp_in_utc=restore_timestamp_in_utc, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -149,18 +156,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - restore_location=restore_location, - restore_timestamp_in_utc=restore_timestamp_in_utc, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -176,10 +176,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -189,8 +187,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableGremlinResources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableGremlinResources"} # 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 1cd78901f391..3c06ae541c2b 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,17 +25,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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, + subscription_id: str, *, restorable_mongodb_database_rid: Optional[str] = None, start_time: Optional[str] = None, @@ -40,38 +48,38 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbCollections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbCollections", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if restorable_mongodb_database_rid is not None: - _params['restorableMongodbDatabaseRid'] = _SERIALIZER.query("restorable_mongodb_database_rid", restorable_mongodb_database_rid, 'str') + _params["restorableMongodbDatabaseRid"] = _SERIALIZER.query( + "restorable_mongodb_database_rid", restorable_mongodb_database_rid, "str" + ) if start_time is not None: - _params['startTime'] = _SERIALIZER.query("start_time", start_time, 'str') + _params["startTime"] = _SERIALIZER.query("start_time", start_time, "str") if end_time is not None: - _params['endTime'] = _SERIALIZER.query("end_time", end_time, 'str') + _params["endTime"] = _SERIALIZER.query("end_time", end_time, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class RestorableMongodbCollectionsOperations: """ @@ -92,7 +100,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -102,14 +109,15 @@ def list( start_time: Optional[str] = None, end_time: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.RestorableMongodbCollectionsListResult]: + ) -> Iterable["_models.RestorableMongodbCollectionGetResult"]: """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. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :type instance_id: str :param restorable_mongodb_database_rid: The resource ID of the MongoDB database. Default value is None. @@ -119,34 +127,33 @@ def list( :param end_time: Restorable MongoDB collections event feed end time. Default value is None. :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 RestorableMongodbCollectionsListResult or the - result of cls(response) + :return: An iterator like instance of either RestorableMongodbCollectionGetResult or the result + of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbCollectionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbCollectionGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableMongodbCollectionsListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableMongodbCollectionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, - api_version=api_version, + subscription_id=self._config.subscription_id, restorable_mongodb_database_rid=restorable_mongodb_database_rid, start_time=start_time, end_time=end_time, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -154,19 +161,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - restorable_mongodb_database_rid=restorable_mongodb_database_rid, - start_time=start_time, - end_time=end_time, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -182,10 +181,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -195,8 +192,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbCollections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbCollections"} # type: ignore 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 9d61bcc565d5..c2af4633798e 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,48 +25,44 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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: + +def build_list_request(location: str, instance_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbDatabases") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbDatabases", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class RestorableMongodbDatabasesOperations: """ @@ -82,49 +83,45 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - location: str, - instance_id: str, - **kwargs: Any - ) -> Iterable[_models.RestorableMongodbDatabasesListResult]: + self, location: str, instance_id: str, **kwargs: Any + ) -> Iterable["_models.RestorableMongodbDatabaseGetResult"]: """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 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :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 + :return: An iterator like instance of either RestorableMongodbDatabaseGetResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbDatabasesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbDatabaseGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableMongodbDatabasesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableMongodbDatabasesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -132,16 +129,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -157,10 +149,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -170,8 +160,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbDatabases"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbDatabases"} # type: ignore 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 cbd30d0d79c4..2da8fc4a8681 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,17 +25,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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, + subscription_id: str, *, restore_location: Optional[str] = None, restore_timestamp_in_utc: Optional[str] = None, @@ -39,36 +47,36 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbResources", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if restore_location is not None: - _params['restoreLocation'] = _SERIALIZER.query("restore_location", restore_location, 'str') + _params["restoreLocation"] = _SERIALIZER.query("restore_location", restore_location, "str") if restore_timestamp_in_utc is not None: - _params['restoreTimestampInUtc'] = _SERIALIZER.query("restore_timestamp_in_utc", restore_timestamp_in_utc, 'str') + _params["restoreTimestampInUtc"] = _SERIALIZER.query( + "restore_timestamp_in_utc", restore_timestamp_in_utc, "str" + ) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class RestorableMongodbResourcesOperations: """ @@ -89,7 +97,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -98,15 +105,16 @@ def list( restore_location: Optional[str] = None, restore_timestamp_in_utc: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.RestorableMongodbResourcesListResult]: + ) -> Iterable["_models.RestorableMongodbResourcesGetResult"]: """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 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :type instance_id: str :param restore_location: The location where the restorable resources are located. Default value is None. @@ -115,33 +123,32 @@ def list( value is None. :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 + :return: An iterator like instance of either RestorableMongodbResourcesGetResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbResourcesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableMongodbResourcesGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableMongodbResourcesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableMongodbResourcesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, - api_version=api_version, + subscription_id=self._config.subscription_id, restore_location=restore_location, restore_timestamp_in_utc=restore_timestamp_in_utc, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -149,18 +156,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - restore_location=restore_location, - restore_timestamp_in_utc=restore_timestamp_in_utc, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -176,10 +176,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -189,8 +187,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbResources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableMongodbResources"} # type: ignore 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 ce4959f20407..7d12d73b891c 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,17 +25,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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, + subscription_id: str, *, restorable_sql_database_rid: Optional[str] = None, start_time: Optional[str] = None, @@ -40,38 +48,38 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlContainers") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlContainers", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if restorable_sql_database_rid is not None: - _params['restorableSqlDatabaseRid'] = _SERIALIZER.query("restorable_sql_database_rid", restorable_sql_database_rid, 'str') + _params["restorableSqlDatabaseRid"] = _SERIALIZER.query( + "restorable_sql_database_rid", restorable_sql_database_rid, "str" + ) if start_time is not None: - _params['startTime'] = _SERIALIZER.query("start_time", start_time, 'str') + _params["startTime"] = _SERIALIZER.query("start_time", start_time, "str") if end_time is not None: - _params['endTime'] = _SERIALIZER.query("end_time", end_time, 'str') + _params["endTime"] = _SERIALIZER.query("end_time", end_time, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class RestorableSqlContainersOperations: """ @@ -92,7 +100,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -102,14 +109,15 @@ def list( start_time: Optional[str] = None, end_time: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.RestorableSqlContainersListResult]: + ) -> Iterable["_models.RestorableSqlContainerGetResult"]: """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. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :type instance_id: str :param restorable_sql_database_rid: The resource ID of the SQL database. Default value is None. :type restorable_sql_database_rid: str @@ -118,34 +126,33 @@ def list( :param end_time: Restorable Sql containers event feed end time. Default value is None. :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 + :return: An iterator like instance of either RestorableSqlContainerGetResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlContainersListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlContainerGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableSqlContainersListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableSqlContainersListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, - api_version=api_version, + subscription_id=self._config.subscription_id, restorable_sql_database_rid=restorable_sql_database_rid, start_time=start_time, end_time=end_time, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -153,19 +160,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - restorable_sql_database_rid=restorable_sql_database_rid, - start_time=start_time, - end_time=end_time, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -181,10 +180,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -194,8 +191,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlContainers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlContainers"} # type: ignore 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 9b85c3671f07..69e878e52914 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,48 +25,44 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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: + +def build_list_request(location: str, instance_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlDatabases") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlDatabases", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class RestorableSqlDatabasesOperations: """ @@ -82,49 +83,45 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - location: str, - instance_id: str, - **kwargs: Any - ) -> Iterable[_models.RestorableSqlDatabasesListResult]: + self, location: str, instance_id: str, **kwargs: Any + ) -> Iterable["_models.RestorableSqlDatabaseGetResult"]: """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 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :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 + :return: An iterator like instance of either RestorableSqlDatabaseGetResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlDatabasesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlDatabaseGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableSqlDatabasesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableSqlDatabasesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -132,16 +129,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -157,10 +149,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -170,8 +160,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlDatabases"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlDatabases"} # type: ignore 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 371cf4cb0b09..98614df1438b 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 @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,17 +25,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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, + subscription_id: str, *, restore_location: Optional[str] = None, restore_timestamp_in_utc: Optional[str] = None, @@ -39,36 +47,36 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlResources", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if restore_location is not None: - _params['restoreLocation'] = _SERIALIZER.query("restore_location", restore_location, 'str') + _params["restoreLocation"] = _SERIALIZER.query("restore_location", restore_location, "str") if restore_timestamp_in_utc is not None: - _params['restoreTimestampInUtc'] = _SERIALIZER.query("restore_timestamp_in_utc", restore_timestamp_in_utc, 'str') + _params["restoreTimestampInUtc"] = _SERIALIZER.query( + "restore_timestamp_in_utc", restore_timestamp_in_utc, "str" + ) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class RestorableSqlResourcesOperations: """ @@ -89,7 +97,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -98,15 +105,16 @@ def list( restore_location: Optional[str] = None, restore_timestamp_in_utc: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.RestorableSqlResourcesListResult]: + ) -> Iterable["_models.RestorableSqlResourcesGetResult"]: """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 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :type instance_id: str :param restore_location: The location where the restorable resources are located. Default value is None. @@ -115,33 +123,32 @@ def list( value is None. :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 + :return: An iterator like instance of either RestorableSqlResourcesGetResult or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlResourcesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableSqlResourcesGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableSqlResourcesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableSqlResourcesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, - api_version=api_version, + subscription_id=self._config.subscription_id, restore_location=restore_location, restore_timestamp_in_utc=restore_timestamp_in_utc, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -149,18 +156,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - restore_location=restore_location, - restore_timestamp_in_utc=restore_timestamp_in_utc, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -176,10 +176,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -189,8 +187,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlResources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableSqlResources"} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_table_resources_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_table_resources_operations.py index c7023dddd06a..670e57dd8a85 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_table_resources_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_table_resources_operations.py @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,17 +25,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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, + subscription_id: str, *, restore_location: Optional[str] = None, restore_timestamp_in_utc: Optional[str] = None, @@ -39,36 +47,36 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableTableResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableTableResources", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if restore_location is not None: - _params['restoreLocation'] = _SERIALIZER.query("restore_location", restore_location, 'str') + _params["restoreLocation"] = _SERIALIZER.query("restore_location", restore_location, "str") if restore_timestamp_in_utc is not None: - _params['restoreTimestampInUtc'] = _SERIALIZER.query("restore_timestamp_in_utc", restore_timestamp_in_utc, 'str') + _params["restoreTimestampInUtc"] = _SERIALIZER.query( + "restore_timestamp_in_utc", restore_timestamp_in_utc, "str" + ) # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class RestorableTableResourcesOperations: """ @@ -89,7 +97,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -98,14 +105,15 @@ def list( restore_location: Optional[str] = None, restore_timestamp_in_utc: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.RestorableTableResourcesListResult]: + ) -> Iterable["_models.RestorableTableResourcesGetResult"]: """Return a list of tables 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 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :type instance_id: str :param restore_location: The location where the restorable resources are located. Default value is None. @@ -114,33 +122,32 @@ def list( value is None. :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 RestorableTableResourcesListResult or the result - of cls(response) + :return: An iterator like instance of either RestorableTableResourcesGetResult or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableTableResourcesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableTableResourcesGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableTableResourcesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableTableResourcesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, - api_version=api_version, + subscription_id=self._config.subscription_id, restore_location=restore_location, restore_timestamp_in_utc=restore_timestamp_in_utc, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -148,18 +155,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - restore_location=restore_location, - restore_timestamp_in_utc=restore_timestamp_in_utc, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -175,10 +175,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -188,8 +186,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableTableResources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableTableResources"} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_tables_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_tables_operations.py index 40110deb9be8..8d805548a31a 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_tables_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_restorable_tables_operations.py @@ -7,10 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -20,17 +25,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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, + subscription_id: str, *, start_time: Optional[str] = None, end_time: Optional[str] = None, @@ -39,36 +47,34 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableTables") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableTables", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if start_time is not None: - _params['startTime'] = _SERIALIZER.query("start_time", start_time, 'str') + _params["startTime"] = _SERIALIZER.query("start_time", start_time, "str") if end_time is not None: - _params['endTime'] = _SERIALIZER.query("end_time", end_time, 'str') + _params["endTime"] = _SERIALIZER.query("end_time", end_time, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class RestorableTablesOperations: """ @@ -89,7 +95,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -98,46 +103,46 @@ def list( start_time: Optional[str] = None, end_time: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.RestorableTablesListResult]: + ) -> Iterable["_models.RestorableTableGetResult"]: """Show the event feed of all mutations done on all the Azure Cosmos DB Tables. This helps in scenario where table was accidentally deleted. This API requires 'Microsoft.DocumentDB/locations/restorableDatabaseAccounts/.../read' permission. :param location: Cosmos DB region, with spaces between words and each word capitalized. + Required. :type location: str - :param instance_id: The instanceId GUID of a restorable database account. + :param instance_id: The instanceId GUID of a restorable database account. Required. :type instance_id: str :param start_time: Restorable Tables event feed start time. Default value is None. :type start_time: str :param end_time: Restorable Tables event feed end time. Default value is None. :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 RestorableTablesListResult or the result of + :return: An iterator like instance of either RestorableTableGetResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableTablesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.RestorableTableGetResult] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorableTablesListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableTablesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, location=location, instance_id=instance_id, - api_version=api_version, + subscription_id=self._config.subscription_id, start_time=start_time, end_time=end_time, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -145,18 +150,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - location=location, - instance_id=instance_id, - api_version=api_version, - start_time=start_time, - end_time=end_time, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -172,10 +170,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -185,8 +181,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableTables"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/restorableDatabaseAccounts/{instanceId}/restorableTables"} # type: ignore diff --git a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_service_operations.py b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_service_operations.py index 2e8b3477fd9e..b91521f5fe65 100644 --- a/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_service_operations.py +++ b/sdk/cosmos/azure-mgmt-cosmosdb/azure/mgmt/cosmosdb/operations/_service_operations.py @@ -6,11 +6,16 @@ # 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 Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,173 +27,159 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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, - resource_group_name: str, - account_name: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_request(resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - service_name: str, - *, - json: Optional[_models.ServiceResourceCreateUpdateParameters] = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, account_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}", + ) # pylint: disable=line-too-long 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]+)*'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=3), + "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]+)*" + ), + "serviceName": _SERIALIZER.url("service_name", service_name, "str", max_length=50, min_length=3), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - service_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}", + ) # pylint: disable=line-too-long 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]+)*'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=3), + "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]+)*" + ), + "serviceName": _SERIALIZER.url("service_name", service_name, "str", max_length=50, min_length=3), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - service_name: str, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, account_name: str, service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}", + ) # pylint: disable=line-too-long 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]+)*'), - "serviceName": _SERIALIZER.url("service_name", service_name, 'str', max_length=50, min_length=3), + "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]+)*" + ), + "serviceName": _SERIALIZER.url("service_name", service_name, "str", max_length=50, min_length=3), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class ServiceOperations: """ @@ -209,45 +200,38 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ServiceResourceListResult]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.ServiceResource"]: """Gets the status of service. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 ServiceResourceListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.ServiceResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ServiceResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResourceListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -255,16 +239,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -280,10 +259,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -293,43 +270,46 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, service_name: str, - create_update_parameters: _models.ServiceResourceCreateUpdateParameters, + create_update_parameters: Union[_models.ServiceResourceCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ServiceResource]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ServiceResource]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ServiceResource]] - _json = self._serialize.body(create_update_parameters, 'ServiceResourceCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_parameters, (IO, bytes)): + _content = create_update_parameters + else: + _json = self._serialize.body(create_update_parameters, "ServiceResourceCreateUpdateParameters") - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -337,10 +317,9 @@ def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -349,36 +328,119 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}"} # type: ignore - @distributed_trace + @overload def begin_create( self, resource_group_name: str, account_name: str, service_name: str, create_update_parameters: _models.ServiceResourceCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ServiceResource]: """Creates a service. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param service_name: Cosmos DB service name. + :param service_name: Cosmos DB service name. Required. :type service_name: str - :param create_update_parameters: The Service resource parameters. + :param create_update_parameters: The Service resource parameters. Required. :type create_update_parameters: ~azure.mgmt.cosmosdb.models.ServiceResourceCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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 ServiceResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + service_name: str, + create_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Creates a service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param service_name: Cosmos DB service name. Required. + :type service_name: str + :param create_update_parameters: The Service resource parameters. Required. + :type create_update_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 ServiceResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + service_name: str, + create_update_parameters: Union[_models.ServiceResourceCreateUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.ServiceResource]: + """Creates a service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param service_name: Cosmos DB service name. Required. + :type service_name: str + :param create_update_parameters: The Service resource parameters. Is either a model type or a + IO type. Required. + :type create_update_parameters: + ~azure.mgmt.cosmosdb.models.ServiceResourceCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -390,20 +452,17 @@ def begin_create( :return: An instance of LROPoller that returns either ServiceResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ServiceResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceResource] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -412,80 +471,70 @@ def begin_create( create_update_parameters=create_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, service_name: str, **kwargs: Any ) -> _models.ServiceResource: """Gets the status of service. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param service_name: Cosmos DB service name. + :param service_name: Cosmos DB service name. Required. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServiceResource, or the result of cls(response) + :return: ServiceResource or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ServiceResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -493,52 +542,43 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServiceResource', pipeline_response) + deserialized = self._deserialize("ServiceResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - service_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, service_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, service_name=service_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -546,10 +586,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -559,24 +598,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - service_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, account_name: str, service_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes service with the given serviceName. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param service_name: Cosmos DB service name. + :param service_name: Cosmos DB service name. Required. :type service_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. @@ -588,53 +623,46 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, service_name=service_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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}/services/{serviceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/services/{serviceName}"} # type: ignore 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 b753f6103fe4..b48f4fbcb3b2 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 @@ -6,11 +6,16 @@ # 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 Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,1827 +27,1740 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_sql_database_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_sql_database_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - database_name: str, - *, - json: Optional[_models.SqlDatabaseCreateUpdateParameters] = None, - content: Any = None, - **kwargs: Any +def build_create_update_sql_database_request( + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_sql_database_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any +def build_delete_sql_database_request( + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_sql_database_throughput_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_sql_database_throughput_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - database_name: str, - *, - json: Optional[_models.ThroughputSettingsUpdateParameters] = None, - content: Any = None, - **kwargs: Any +def build_update_sql_database_throughput_request( + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **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 +def build_migrate_sql_database_to_autoscale_request( + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToAutoscale", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **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 +def build_migrate_sql_database_to_manual_throughput_request( + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default/migrateToManualThroughput", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_client_encryption_keys_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_client_encryption_key_request( - subscription_id: str, resource_group_name: str, account_name: str, database_name: str, client_encryption_key_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys/{clientEncryptionKeyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys/{clientEncryptionKeyName}", + ) # pylint: disable=line-too-long 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'), - "clientEncryptionKeyName": _SERIALIZER.url("client_encryption_key_name", client_encryption_key_name, '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]+)*" + ), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "clientEncryptionKeyName": _SERIALIZER.url("client_encryption_key_name", client_encryption_key_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_client_encryption_key_request_initial( - subscription_id: str, +def build_create_update_client_encryption_key_request( resource_group_name: str, account_name: str, database_name: str, client_encryption_key_name: str, - *, - json: Optional[_models.ClientEncryptionKeyCreateUpdateParameters] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys/{clientEncryptionKeyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys/{clientEncryptionKeyName}", + ) # pylint: disable=line-too-long 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'), - "clientEncryptionKeyName": _SERIALIZER.url("client_encryption_key_name", client_encryption_key_name, '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]+)*" + ), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "clientEncryptionKeyName": _SERIALIZER.url("client_encryption_key_name", client_encryption_key_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_list_sql_containers_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_sql_container_request( - subscription_id: str, resource_group_name: str, account_name: str, database_name: str, container_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_sql_container_request_initial( - subscription_id: str, +def build_create_update_sql_container_request( resource_group_name: str, account_name: str, database_name: str, container_name: str, - *, - json: Optional[_models.SqlContainerCreateUpdateParameters] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_sql_container_request_initial( - subscription_id: str, +def build_delete_sql_container_request( resource_group_name: str, account_name: str, database_name: str, container_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_list_sql_container_partition_merge_request_initial( - subscription_id: str, +def build_list_sql_container_partition_merge_request( resource_group_name: str, account_name: str, database_name: str, container_name: str, - *, - json: Optional[_models.MergeParameters] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/partitionMerge") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/partitionMerge", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_sql_container_throughput_request( - subscription_id: str, resource_group_name: str, account_name: str, database_name: str, container_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_sql_container_throughput_request_initial( - subscription_id: str, +def build_update_sql_container_throughput_request( resource_group_name: str, account_name: str, database_name: str, container_name: str, - *, - json: Optional[_models.ThroughputSettingsUpdateParameters] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_sql_container_to_autoscale_request_initial( - subscription_id: str, +def build_migrate_sql_container_to_autoscale_request( resource_group_name: str, account_name: str, database_name: str, container_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/migrateToAutoscale") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/migrateToAutoscale", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_migrate_sql_container_to_manual_throughput_request_initial( - subscription_id: str, +def build_migrate_sql_container_to_manual_throughput_request( resource_group_name: str, account_name: str, database_name: str, container_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/migrateToManualThroughput") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/migrateToManualThroughput", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_sql_container_retrieve_throughput_distribution_request_initial( - subscription_id: str, +def build_sql_container_retrieve_throughput_distribution_request( resource_group_name: str, account_name: str, database_name: str, container_name: str, - *, - json: Optional[_models.RetrieveThroughputParameters] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/retrieveThroughputDistribution") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/retrieveThroughputDistribution", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_sql_container_redistribute_throughput_request_initial( - subscription_id: str, +def build_sql_container_redistribute_throughput_request( resource_group_name: str, account_name: str, database_name: str, container_name: str, - *, - json: Optional[_models.RedistributeThroughputParameters] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/redistributeThroughput") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/redistributeThroughput", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_sql_stored_procedures_request( - subscription_id: str, resource_group_name: str, account_name: str, database_name: str, container_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **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, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_sql_stored_procedure_request_initial( - subscription_id: str, +def build_create_update_sql_stored_procedure_request( resource_group_name: str, account_name: str, database_name: str, container_name: str, stored_procedure_name: str, - *, - json: Optional[_models.SqlStoredProcedureCreateUpdateParameters] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_sql_stored_procedure_request_initial( - subscription_id: str, +def build_delete_sql_stored_procedure_request( resource_group_name: str, account_name: str, database_name: str, container_name: str, stored_procedure_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **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, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **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, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_sql_user_defined_function_request_initial( - subscription_id: str, +def build_create_update_sql_user_defined_function_request( resource_group_name: str, account_name: str, database_name: str, container_name: str, user_defined_function_name: str, - *, - json: Optional[_models.SqlUserDefinedFunctionCreateUpdateParameters] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_sql_user_defined_function_request_initial( - subscription_id: str, +def build_delete_sql_user_defined_function_request( resource_group_name: str, account_name: str, database_name: str, container_name: str, user_defined_function_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/userDefinedFunctions/{userDefinedFunctionName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_sql_triggers_request( - subscription_id: str, resource_group_name: str, account_name: str, database_name: str, container_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **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, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_update_sql_trigger_request_initial( - subscription_id: str, +def build_create_update_sql_trigger_request( resource_group_name: str, account_name: str, database_name: str, container_name: str, trigger_name: str, - *, - json: Optional[_models.SqlTriggerCreateUpdateParameters] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_sql_trigger_request_initial( - subscription_id: str, +def build_delete_sql_trigger_request( resource_group_name: str, account_name: str, database_name: str, container_name: str, trigger_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_sql_role_definition_request( - role_definition_id: str, - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + role_definition_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **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: Optional[_models.SqlRoleDefinitionCreateUpdateParameters] = None, - content: Any = None, - **kwargs: Any +def build_create_update_sql_role_definition_request( + role_definition_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - 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 + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_sql_role_definition_request( + role_definition_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_sql_role_definitions_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_sql_role_assignment_request( - role_assignment_id: str, - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + role_assignment_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **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: Optional[_models.SqlRoleAssignmentCreateUpdateParameters] = None, - content: Any = None, - **kwargs: Any +def build_create_update_sql_role_assignment_request( + role_assignment_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - 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 + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_sql_role_assignment_request( + role_assignment_id: str, resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_sql_role_assignments_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_retrieve_continuous_backup_information_request_initial( - subscription_id: str, +def build_retrieve_continuous_backup_information_request( resource_group_name: str, account_name: str, database_name: str, container_name: str, - *, - json: Optional[_models.ContinuousBackupRestoreLocation] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/retrieveContinuousBackupInformation") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/retrieveContinuousBackupInformation", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class SqlResourcesOperations: # pylint: disable=too-many-public-methods """ @@ -1863,45 +1781,41 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_sql_databases( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.SqlDatabaseListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.SqlDatabaseGetResults"]: """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 + :return: An iterator like instance of either SqlDatabaseGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlDatabaseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlDatabaseGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlDatabaseListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlDatabaseListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_sql_databases_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_sql_databases.metadata['url'], + template_url=self.list_sql_databases.metadata["url"], headers=_headers, params=_params, ) @@ -1909,16 +1823,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_sql_databases_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1934,10 +1843,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1947,53 +1854,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_sql_databases.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases"} # type: ignore + 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: str, - account_name: str, - database_name: str, - **kwargs: Any + self, 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. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlDatabaseGetResults, or the result of cls(response) + :return: SqlDatabaseGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.SqlDatabaseGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlDatabaseGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlDatabaseGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_sql_database.metadata['url'], + template_url=self.get_sql_database.metadata["url"], headers=_headers, params=_params, ) @@ -2001,57 +1900,60 @@ def get_sql_database( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SqlDatabaseGetResults', pipeline_response) + deserialized = self._deserialize("SqlDatabaseGetResults", pipeline_response) if cls: 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 - + 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: str, account_name: str, database_name: str, - create_update_sql_database_parameters: _models.SqlDatabaseCreateUpdateParameters, + create_update_sql_database_parameters: Union[_models.SqlDatabaseCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.SqlDatabaseGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SqlDatabaseGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SqlDatabaseGetResults]] - _json = self._serialize.body(create_update_sql_database_parameters, 'SqlDatabaseCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_sql_database_parameters, (IO, bytes)): + _content = create_update_sql_database_parameters + else: + _json = self._serialize.body(create_update_sql_database_parameters, "SqlDatabaseCreateUpdateParameters") - request = build_create_update_sql_database_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_sql_database_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_sql_database_initial.metadata['url'], + content=_content, + template_url=self._create_update_sql_database_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2059,10 +1961,9 @@ def _create_update_sql_database_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2071,37 +1972,121 @@ def _create_update_sql_database_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SqlDatabaseGetResults', pipeline_response) + deserialized = self._deserialize("SqlDatabaseGetResults", pipeline_response) if cls: 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 - + _create_update_sql_database_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}"} # type: ignore - @distributed_trace + @overload def begin_create_update_sql_database( self, resource_group_name: str, account_name: str, database_name: str, create_update_sql_database_parameters: _models.SqlDatabaseCreateUpdateParameters, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :param create_update_sql_database_parameters: The parameters to provide for the current SQL - database. + database. Required. :type create_update_sql_database_parameters: ~azure.mgmt.cosmosdb.models.SqlDatabaseCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlDatabaseGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_update_sql_database( + self, + resource_group_name: str, + account_name: str, + database_name: str, + create_update_sql_database_parameters: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param create_update_sql_database_parameters: The parameters to provide for the current SQL + database. Required. + :type create_update_sql_database_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlDatabaseGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_update_sql_database( + self, + resource_group_name: str, + account_name: str, + database_name: str, + create_update_sql_database_parameters: Union[_models.SqlDatabaseCreateUpdateParameters, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param create_update_sql_database_parameters: The parameters to provide for the current SQL + database. Is either a model type or a IO type. Required. + :type create_update_sql_database_parameters: + ~azure.mgmt.cosmosdb.models.SqlDatabaseCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -2113,20 +2098,17 @@ def begin_create_update_sql_database( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlDatabaseGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlDatabaseGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_update_sql_database_initial( # type: ignore resource_group_name=resource_group_name, @@ -2135,66 +2117,55 @@ def begin_create_update_sql_database( create_update_sql_database_parameters=create_update_sql_database_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SqlDatabaseGetResults', pipeline_response) + deserialized = self._deserialize("SqlDatabaseGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_sql_database_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_sql_database_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_sql_database_initial.metadata['url'], + template_url=self._delete_sql_database_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2202,10 +2173,9 @@ def _delete_sql_database_initial( # pylint: disable=inconsistent-return-stateme request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -2215,24 +2185,20 @@ def _delete_sql_database_initial( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - _delete_sql_database_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any + def begin_delete_sql_database( + self, 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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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. @@ -2244,98 +2210,85 @@ def begin_delete_sql_database( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_sql_database_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: """Gets the RUs per second of the SQL database under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ThroughputSettingsGetResults, or the result of cls(response) + :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_sql_database_throughput.metadata['url'], + template_url=self.get_sql_database_throughput.metadata["url"], headers=_headers, params=_params, ) @@ -2343,57 +2296,60 @@ def get_sql_database_throughput( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + 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: str, account_name: str, database_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IO, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - request = build_update_sql_database_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_sql_database_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_sql_database_throughput_initial.metadata['url'], + content=_content, + template_url=self._update_sql_database_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2401,10 +2357,9 @@ def _update_sql_database_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2413,37 +2368,121 @@ def _update_sql_database_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _update_sql_database_throughput_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/throughputSettings/default"} # type: ignore - @distributed_trace + @overload def begin_update_sql_database_throughput( self, resource_group_name: str, account_name: str, database_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Update RUs per second of an Azure Cosmos DB SQL database. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current SQL database. + current SQL database. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_sql_database_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + update_throughput_parameters: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current SQL database. Required. + :type update_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_sql_database_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current SQL database. Is either a model type or a IO type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -2455,20 +2494,17 @@ def begin_update_sql_database_throughput( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._update_sql_database_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -2477,66 +2513,55 @@ def begin_update_sql_database_throughput( update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_sql_database_to_autoscale_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_sql_database_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_sql_database_to_autoscale_initial.metadata['url'], + template_url=self._migrate_sql_database_to_autoscale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2544,10 +2569,9 @@ def _migrate_sql_database_to_autoscale_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2556,31 +2580,27 @@ def _migrate_sql_database_to_autoscale_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB SQL database from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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. @@ -2593,85 +2613,71 @@ def begin_migrate_sql_database_to_autoscale( :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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._migrate_sql_database_to_autoscale_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_sql_database_to_manual_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_sql_database_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_sql_database_to_manual_throughput_initial.metadata['url'], + template_url=self._migrate_sql_database_to_manual_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2679,10 +2685,9 @@ def _migrate_sql_database_to_manual_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2691,31 +2696,27 @@ def _migrate_sql_database_to_manual_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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: str, - account_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB SQL database from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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. @@ -2728,102 +2729,90 @@ def begin_migrate_sql_database_to_manual_throughput( :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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._migrate_sql_database_to_manual_throughput_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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_client_encryption_keys( - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any - ) -> Iterable[_models.ClientEncryptionKeysListResult]: + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.ClientEncryptionKeyGetResults"]: """Lists the ClientEncryptionKeys under an existing Azure Cosmos DB SQL database. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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 ClientEncryptionKeysListResult or the result of + :return: An iterator like instance of either ClientEncryptionKeyGetResults or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.ClientEncryptionKeysListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ClientEncryptionKeysListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClientEncryptionKeysListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_client_encryption_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_client_encryption_keys.metadata['url'], + template_url=self.list_client_encryption_keys.metadata["url"], headers=_headers, params=_params, ) @@ -2831,17 +2820,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_client_encryption_keys_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -2857,10 +2840,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2870,11 +2851,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_client_encryption_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys"} # type: ignore + list_client_encryption_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys"} # type: ignore @distributed_trace def get_client_encryption_key( @@ -2888,38 +2867,36 @@ def get_client_encryption_key( """Gets the ClientEncryptionKey under an existing Azure Cosmos DB SQL database. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. + :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. :type client_encryption_key_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ClientEncryptionKeyGetResults, or the result of cls(response) + :return: ClientEncryptionKeyGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ClientEncryptionKeyGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClientEncryptionKeyGetResults] - request = build_get_client_encryption_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, client_encryption_key_name=client_encryption_key_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_client_encryption_key.metadata['url'], + template_url=self.get_client_encryption_key.metadata["url"], headers=_headers, params=_params, ) @@ -2927,25 +2904,23 @@ def get_client_encryption_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ClientEncryptionKeyGetResults', pipeline_response) + deserialized = self._deserialize("ClientEncryptionKeyGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_client_encryption_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys/{clientEncryptionKeyName}"} # type: ignore - + get_client_encryption_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys/{clientEncryptionKeyName}"} # type: ignore def _create_update_client_encryption_key_initial( self, @@ -2953,33 +2928,40 @@ def _create_update_client_encryption_key_initial( account_name: str, database_name: str, client_encryption_key_name: str, - create_update_client_encryption_key_parameters: _models.ClientEncryptionKeyCreateUpdateParameters, + create_update_client_encryption_key_parameters: Union[_models.ClientEncryptionKeyCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ClientEncryptionKeyGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ClientEncryptionKeyGetResults]] - - _json = self._serialize.body(create_update_client_encryption_key_parameters, 'ClientEncryptionKeyCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ClientEncryptionKeyGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_client_encryption_key_parameters, (IO, bytes)): + _content = create_update_client_encryption_key_parameters + else: + _json = self._serialize.body( + create_update_client_encryption_key_parameters, "ClientEncryptionKeyCreateUpdateParameters" + ) - request = build_create_update_client_encryption_key_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_client_encryption_key_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, client_encryption_key_name=client_encryption_key_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_client_encryption_key_initial.metadata['url'], + content=_content, + template_url=self._create_update_client_encryption_key_initial.metadata["url"], headers=_headers, params=_params, ) @@ -2987,10 +2969,9 @@ def _create_update_client_encryption_key_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2999,17 +2980,16 @@ def _create_update_client_encryption_key_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ClientEncryptionKeyGetResults', pipeline_response) + deserialized = self._deserialize("ClientEncryptionKeyGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_update_client_encryption_key_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys/{clientEncryptionKeyName}"} # type: ignore - + _create_update_client_encryption_key_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys/{clientEncryptionKeyName}"} # type: ignore - @distributed_trace + @overload def begin_create_update_client_encryption_key( self, resource_group_name: str, @@ -3017,23 +2997,118 @@ def begin_create_update_client_encryption_key( database_name: str, client_encryption_key_name: str, create_update_client_encryption_key_parameters: _models.ClientEncryptionKeyCreateUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ClientEncryptionKeyGetResults]: """Create or update a ClientEncryptionKey. This API is meant to be invoked via tools such as the Azure Powershell (instead of directly). :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. + :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. :type client_encryption_key_name: str :param create_update_client_encryption_key_parameters: The parameters to provide for the client - encryption key. + encryption key. Required. :type create_update_client_encryption_key_parameters: ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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 ClientEncryptionKeyGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_update_client_encryption_key( + self, + resource_group_name: str, + account_name: str, + database_name: str, + client_encryption_key_name: str, + create_update_client_encryption_key_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ClientEncryptionKeyGetResults]: + """Create or update a ClientEncryptionKey. This API is meant to be invoked via tools such as the + Azure Powershell (instead of directly). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. + :type client_encryption_key_name: str + :param create_update_client_encryption_key_parameters: The parameters to provide for the client + encryption key. Required. + :type create_update_client_encryption_key_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 ClientEncryptionKeyGetResults or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_update_client_encryption_key( + self, + resource_group_name: str, + account_name: str, + database_name: str, + client_encryption_key_name: str, + create_update_client_encryption_key_parameters: Union[_models.ClientEncryptionKeyCreateUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.ClientEncryptionKeyGetResults]: + """Create or update a ClientEncryptionKey. This API is meant to be invoked via tools such as the + Azure Powershell (instead of directly). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param client_encryption_key_name: Cosmos DB ClientEncryptionKey name. Required. + :type client_encryption_key_name: str + :param create_update_client_encryption_key_parameters: The parameters to provide for the client + encryption key. Is either a model type or a IO type. Required. + :type create_update_client_encryption_key_parameters: + ~azure.mgmt.cosmosdb.models.ClientEncryptionKeyCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -3046,20 +3121,17 @@ def begin_create_update_client_encryption_key( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ClientEncryptionKeyGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ClientEncryptionKeyGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClientEncryptionKeyGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_update_client_encryption_key_initial( # type: ignore resource_group_name=resource_group_name, @@ -3069,82 +3141,74 @@ def begin_create_update_client_encryption_key( create_update_client_encryption_key_parameters=create_update_client_encryption_key_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ClientEncryptionKeyGetResults', pipeline_response) + deserialized = self._deserialize("ClientEncryptionKeyGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_update_client_encryption_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys/{clientEncryptionKeyName}"} # type: ignore + begin_create_update_client_encryption_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/clientEncryptionKeys/{clientEncryptionKeyName}"} # type: ignore @distributed_trace def list_sql_containers( - self, - resource_group_name: str, - account_name: str, - database_name: str, - **kwargs: Any - ) -> Iterable[_models.SqlContainerListResult]: + self, resource_group_name: str, account_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.SqlContainerGetResults"]: """Lists the SQL container under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :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 + :return: An iterator like instance of either SqlContainerGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlContainerListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlContainerGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlContainerListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlContainerListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_sql_containers.metadata['url'], + template_url=self.list_sql_containers.metadata["url"], headers=_headers, params=_params, ) @@ -3152,17 +3216,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -3178,10 +3236,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -3191,56 +3247,47 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + 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: str, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any + self, 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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlContainerGetResults, or the result of cls(response) + :return: SqlContainerGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.SqlContainerGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlContainerGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlContainerGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_sql_container.metadata['url'], + template_url=self.get_sql_container.metadata["url"], headers=_headers, params=_params, ) @@ -3248,25 +3295,23 @@ def get_sql_container( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SqlContainerGetResults', pipeline_response) + deserialized = self._deserialize("SqlContainerGetResults", pipeline_response) if cls: 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 - + 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, @@ -3274,33 +3319,38 @@ def _create_update_sql_container_initial( account_name: str, database_name: str, container_name: str, - create_update_sql_container_parameters: _models.SqlContainerCreateUpdateParameters, + create_update_sql_container_parameters: Union[_models.SqlContainerCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.SqlContainerGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SqlContainerGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SqlContainerGetResults]] - _json = self._serialize.body(create_update_sql_container_parameters, 'SqlContainerCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_sql_container_parameters, (IO, bytes)): + _content = create_update_sql_container_parameters + else: + _json = self._serialize.body(create_update_sql_container_parameters, "SqlContainerCreateUpdateParameters") - request = build_create_update_sql_container_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_sql_container_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_sql_container_initial.metadata['url'], + content=_content, + template_url=self._create_update_sql_container_initial.metadata["url"], headers=_headers, params=_params, ) @@ -3308,10 +3358,9 @@ def _create_update_sql_container_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3320,17 +3369,16 @@ def _create_update_sql_container_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SqlContainerGetResults', pipeline_response) + deserialized = self._deserialize("SqlContainerGetResults", pipeline_response) if cls: 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 + _create_update_sql_container_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}"} # type: ignore - - @distributed_trace + @overload def begin_create_update_sql_container( self, resource_group_name: str, @@ -3338,22 +3386,28 @@ def begin_create_update_sql_container( database_name: str, container_name: str, create_update_sql_container_parameters: _models.SqlContainerCreateUpdateParameters, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str :param create_update_sql_container_parameters: The parameters to provide for the current SQL - container. + container. Required. :type create_update_sql_container_parameters: ~azure.mgmt.cosmosdb.models.SqlContainerCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 @@ -3365,91 +3419,161 @@ def begin_create_update_sql_container( :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: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlContainerGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._create_update_sql_container_initial( # type: ignore - resource_group_name=resource_group_name, - account_name=account_name, - database_name=database_name, - container_name=container_name, - create_update_sql_container_parameters=create_update_sql_container_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, + @overload + def begin_create_update_sql_container( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + create_update_sql_container_parameters: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param create_update_sql_container_parameters: The parameters to provide for the current SQL + container. Required. + :type create_update_sql_container_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlContainerGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_update_sql_container( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + create_update_sql_container_parameters: Union[_models.SqlContainerCreateUpdateParameters, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param create_update_sql_container_parameters: The parameters to provide for the current SQL + container. Is either a model type or a IO type. Required. + :type create_update_sql_container_parameters: + ~azure.mgmt.cosmosdb.models.SqlContainerCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlContainerGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlContainerGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_update_sql_container_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + database_name=database_name, + container_name=container_name, + create_update_sql_container_parameters=create_update_sql_container_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SqlContainerGetResults', pipeline_response) + deserialized = self._deserialize("SqlContainerGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_sql_container_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_sql_container_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_sql_container_initial.metadata['url'], + template_url=self._delete_sql_container_initial.metadata["url"], headers=_headers, params=_params, ) @@ -3457,10 +3581,9 @@ def _delete_sql_container_initial( # pylint: disable=inconsistent-return-statem request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -3470,27 +3593,22 @@ def _delete_sql_container_initial( # pylint: disable=inconsistent-return-statem if cls: return cls(pipeline_response, None, {}) - _delete_sql_container_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any + def begin_delete_sql_container( + self, 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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :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. @@ -3502,19 +3620,16 @@ def begin_delete_sql_container( # pylint: disable=inconsistent-return-statement 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_sql_container_initial( # type: ignore resource_group_name=resource_group_name, @@ -3522,37 +3637,33 @@ def begin_delete_sql_container( # pylint: disable=inconsistent-return-statement database_name=database_name, container_name=container_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_delete_sql_container.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}"} # type: ignore def _list_sql_container_partition_merge_initial( self, @@ -3560,33 +3671,38 @@ def _list_sql_container_partition_merge_initial( account_name: str, database_name: str, container_name: str, - merge_parameters: _models.MergeParameters, + merge_parameters: Union[_models.MergeParameters, IO], **kwargs: Any ) -> Optional[_models.PhysicalPartitionStorageInfoCollection]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PhysicalPartitionStorageInfoCollection]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PhysicalPartitionStorageInfoCollection]] - _json = self._serialize.body(merge_parameters, 'MergeParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(merge_parameters, (IO, bytes)): + _content = merge_parameters + else: + _json = self._serialize.body(merge_parameters, "MergeParameters") - request = build_list_sql_container_partition_merge_request_initial( - subscription_id=self._config.subscription_id, + request = build_list_sql_container_partition_merge_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._list_sql_container_partition_merge_initial.metadata['url'], + content=_content, + template_url=self._list_sql_container_partition_merge_initial.metadata["url"], headers=_headers, params=_params, ) @@ -3594,10 +3710,9 @@ def _list_sql_container_partition_merge_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3606,17 +3721,16 @@ def _list_sql_container_partition_merge_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PhysicalPartitionStorageInfoCollection', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionStorageInfoCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _list_sql_container_partition_merge_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/partitionMerge"} # type: ignore - + _list_sql_container_partition_merge_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/partitionMerge"} # type: ignore - @distributed_trace + @overload def begin_list_sql_container_partition_merge( self, resource_group_name: str, @@ -3624,20 +3738,26 @@ def begin_list_sql_container_partition_merge( database_name: str, container_name: str, merge_parameters: _models.MergeParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.PhysicalPartitionStorageInfoCollection]: """Merges the partitions of a SQL Container. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param merge_parameters: The parameters for the merge operation. + :param merge_parameters: The parameters for the merge operation. Required. :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :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 @@ -3650,20 +3770,102 @@ def begin_list_sql_container_partition_merge( the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_list_sql_container_partition_merge( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + merge_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionStorageInfoCollection]: + """Merges the partitions of a SQL Container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param merge_parameters: The parameters for the merge operation. Required. + :type merge_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 PhysicalPartitionStorageInfoCollection or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_list_sql_container_partition_merge( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + merge_parameters: Union[_models.MergeParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionStorageInfoCollection]: + """Merges the partitions of a SQL Container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param merge_parameters: The parameters for the merge operation. Is either a model type or a IO + type. Required. + :type merge_parameters: ~azure.mgmt.cosmosdb.models.MergeParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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 PhysicalPartitionStorageInfoCollection or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionStorageInfoCollection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PhysicalPartitionStorageInfoCollection] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhysicalPartitionStorageInfoCollection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._list_sql_container_partition_merge_initial( # type: ignore resource_group_name=resource_group_name, @@ -3673,85 +3875,76 @@ def begin_list_sql_container_partition_merge( merge_parameters=merge_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PhysicalPartitionStorageInfoCollection', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionStorageInfoCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_list_sql_container_partition_merge.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/partitionMerge"} # type: ignore + begin_list_sql_container_partition_merge.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/partitionMerge"} # type: ignore @distributed_trace def get_sql_container_throughput( - self, - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: """Gets the RUs per second of the SQL container under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ThroughputSettingsGetResults, or the result of cls(response) + :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_sql_container_throughput.metadata['url'], + template_url=self.get_sql_container_throughput.metadata["url"], headers=_headers, params=_params, ) @@ -3759,25 +3952,23 @@ def get_sql_container_throughput( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + 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, @@ -3785,33 +3976,38 @@ def _update_sql_container_throughput_initial( account_name: str, database_name: str, container_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IO, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - request = build_update_sql_container_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_sql_container_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_sql_container_throughput_initial.metadata['url'], + content=_content, + template_url=self._update_sql_container_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -3819,10 +4015,9 @@ def _update_sql_container_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3831,17 +4026,16 @@ def _update_sql_container_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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 + @overload def begin_update_sql_container_throughput( self, resource_group_name: str, @@ -3849,22 +4043,71 @@ def begin_update_sql_container_throughput( database_name: str, container_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Update RUs per second of an Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current SQL container. + current SQL container. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_sql_container_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + update_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB SQL container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current SQL container. Required. + :type update_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -3876,20 +4119,59 @@ def begin_update_sql_container_throughput( :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: + """ + + @distributed_trace + def begin_update_sql_container_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.ThroughputSettingsGetResults]: + """Update RUs per second of an Azure Cosmos DB SQL container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current SQL container. Is either a model type or a IO type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._update_sql_container_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -3899,68 +4181,56 @@ def begin_update_sql_container_throughput( update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_sql_container_to_autoscale_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_sql_container_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_sql_container_to_autoscale_initial.metadata['url'], + template_url=self._migrate_sql_container_to_autoscale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -3968,10 +4238,9 @@ def _migrate_sql_container_to_autoscale_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -3980,34 +4249,29 @@ def _migrate_sql_container_to_autoscale_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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: str, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB SQL container from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :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. @@ -4020,19 +4284,16 @@ def begin_migrate_sql_container_to_autoscale( :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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._migrate_sql_container_to_autoscale_initial( # type: ignore resource_group_name=resource_group_name, @@ -4040,68 +4301,56 @@ def begin_migrate_sql_container_to_autoscale( database_name=database_name, container_name=container_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_sql_container_to_manual_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_sql_container_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_sql_container_to_manual_throughput_initial.metadata['url'], + template_url=self._migrate_sql_container_to_manual_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -4109,10 +4358,9 @@ def _migrate_sql_container_to_manual_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4121,34 +4369,29 @@ def _migrate_sql_container_to_manual_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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: str, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB SQL container from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :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. @@ -4161,19 +4404,16 @@ def begin_migrate_sql_container_to_manual_throughput( :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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._migrate_sql_container_to_manual_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -4181,39 +4421,35 @@ def begin_migrate_sql_container_to_manual_throughput( database_name=database_name, container_name=container_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 def _sql_container_retrieve_throughput_distribution_initial( self, @@ -4221,33 +4457,38 @@ def _sql_container_retrieve_throughput_distribution_initial( account_name: str, database_name: str, container_name: str, - retrieve_throughput_parameters: _models.RetrieveThroughputParameters, + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO], **kwargs: Any ) -> Optional[_models.PhysicalPartitionThroughputInfoResult]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PhysicalPartitionThroughputInfoResult]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PhysicalPartitionThroughputInfoResult]] - _json = self._serialize.body(retrieve_throughput_parameters, 'RetrieveThroughputParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(retrieve_throughput_parameters, (IO, bytes)): + _content = retrieve_throughput_parameters + else: + _json = self._serialize.body(retrieve_throughput_parameters, "RetrieveThroughputParameters") - request = build_sql_container_retrieve_throughput_distribution_request_initial( - subscription_id=self._config.subscription_id, + request = build_sql_container_retrieve_throughput_distribution_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._sql_container_retrieve_throughput_distribution_initial.metadata['url'], + content=_content, + template_url=self._sql_container_retrieve_throughput_distribution_initial.metadata["url"], headers=_headers, params=_params, ) @@ -4255,10 +4496,9 @@ def _sql_container_retrieve_throughput_distribution_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4267,15 +4507,102 @@ def _sql_container_retrieve_throughput_distribution_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PhysicalPartitionThroughputInfoResult', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _sql_container_retrieve_throughput_distribution_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/retrieveThroughputDistribution"} # type: ignore + _sql_container_retrieve_throughput_distribution_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/retrieveThroughputDistribution"} # type: ignore + + @overload + def begin_sql_container_retrieve_throughput_distribution( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + retrieve_throughput_parameters: _models.RetrieveThroughputParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB SQL container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current SQL container. Required. + :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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 PhysicalPartitionThroughputInfoResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_sql_container_retrieve_throughput_distribution( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + retrieve_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Retrieve throughput distribution for an Azure Cosmos DB SQL container. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput + distribution for the current SQL container. Required. + :type retrieve_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 PhysicalPartitionThroughputInfoResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_sql_container_retrieve_throughput_distribution( @@ -4284,22 +4611,27 @@ def begin_sql_container_retrieve_throughput_distribution( account_name: str, database_name: str, container_name: str, - retrieve_throughput_parameters: _models.RetrieveThroughputParameters, + retrieve_throughput_parameters: Union[_models.RetrieveThroughputParameters, IO], **kwargs: Any ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: """Retrieve throughput distribution for an Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str :param retrieve_throughput_parameters: The parameters to provide for retrieving throughput - distribution for the current SQL container. + distribution for the current SQL container. Is either a model type or a IO type. Required. :type retrieve_throughput_parameters: ~azure.mgmt.cosmosdb.models.RetrieveThroughputParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -4312,20 +4644,17 @@ def begin_sql_container_retrieve_throughput_distribution( the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PhysicalPartitionThroughputInfoResult] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhysicalPartitionThroughputInfoResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._sql_container_retrieve_throughput_distribution_initial( # type: ignore resource_group_name=resource_group_name, @@ -4335,39 +4664,37 @@ def begin_sql_container_retrieve_throughput_distribution( retrieve_throughput_parameters=retrieve_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PhysicalPartitionThroughputInfoResult', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_sql_container_retrieve_throughput_distribution.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/retrieveThroughputDistribution"} # type: ignore + begin_sql_container_retrieve_throughput_distribution.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/retrieveThroughputDistribution"} # type: ignore def _sql_container_redistribute_throughput_initial( self, @@ -4375,33 +4702,38 @@ def _sql_container_redistribute_throughput_initial( account_name: str, database_name: str, container_name: str, - redistribute_throughput_parameters: _models.RedistributeThroughputParameters, + redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO], **kwargs: Any ) -> Optional[_models.PhysicalPartitionThroughputInfoResult]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.PhysicalPartitionThroughputInfoResult]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PhysicalPartitionThroughputInfoResult]] - _json = self._serialize.body(redistribute_throughput_parameters, 'RedistributeThroughputParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(redistribute_throughput_parameters, (IO, bytes)): + _content = redistribute_throughput_parameters + else: + _json = self._serialize.body(redistribute_throughput_parameters, "RedistributeThroughputParameters") - request = build_sql_container_redistribute_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_sql_container_redistribute_throughput_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._sql_container_redistribute_throughput_initial.metadata['url'], + content=_content, + template_url=self._sql_container_redistribute_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -4409,10 +4741,9 @@ def _sql_container_redistribute_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4421,17 +4752,16 @@ def _sql_container_redistribute_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PhysicalPartitionThroughputInfoResult', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _sql_container_redistribute_throughput_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/redistributeThroughput"} # type: ignore + _sql_container_redistribute_throughput_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/redistributeThroughput"} # type: ignore - - @distributed_trace + @overload def begin_sql_container_redistribute_throughput( self, resource_group_name: str, @@ -4439,22 +4769,115 @@ def begin_sql_container_redistribute_throughput( database_name: str, container_name: str, redistribute_throughput_parameters: _models.RedistributeThroughputParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: """Redistribute throughput for an Azure Cosmos DB SQL container. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str :param redistribute_throughput_parameters: The parameters to provide for redistributing - throughput for the current SQL container. + throughput for the current SQL container. Required. :type redistribute_throughput_parameters: ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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 PhysicalPartitionThroughputInfoResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_sql_container_redistribute_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + redistribute_throughput_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Redistribute throughput for an Azure Cosmos DB SQL container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current SQL container. Required. + :type redistribute_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 PhysicalPartitionThroughputInfoResult or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_sql_container_redistribute_throughput( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + redistribute_throughput_parameters: Union[_models.RedistributeThroughputParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.PhysicalPartitionThroughputInfoResult]: + """Redistribute throughput for an Azure Cosmos DB SQL container. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param redistribute_throughput_parameters: The parameters to provide for redistributing + throughput for the current SQL container. Is either a model type or a IO type. Required. + :type redistribute_throughput_parameters: + ~azure.mgmt.cosmosdb.models.RedistributeThroughputParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -4467,20 +4890,17 @@ def begin_sql_container_redistribute_throughput( the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.PhysicalPartitionThroughputInfoResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PhysicalPartitionThroughputInfoResult] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PhysicalPartitionThroughputInfoResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._sql_container_redistribute_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -4490,86 +4910,79 @@ def begin_sql_container_redistribute_throughput( redistribute_throughput_parameters=redistribute_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PhysicalPartitionThroughputInfoResult', pipeline_response) + deserialized = self._deserialize("PhysicalPartitionThroughputInfoResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_sql_container_redistribute_throughput.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/redistributeThroughput"} # type: ignore + begin_sql_container_redistribute_throughput.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/throughputSettings/default/redistributeThroughput"} # type: ignore @distributed_trace def list_sql_stored_procedures( - self, - resource_group_name: str, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any - ) -> Iterable[_models.SqlStoredProcedureListResult]: + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any + ) -> Iterable["_models.SqlStoredProcedureGetResults"]: """Lists the SQL storedProcedure under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :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 + :return: An iterator like instance of either SqlStoredProcedureGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlStoredProcedureListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlStoredProcedureListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlStoredProcedureListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_sql_stored_procedures_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_sql_stored_procedures.metadata['url'], + template_url=self.list_sql_stored_procedures.metadata["url"], headers=_headers, params=_params, ) @@ -4577,18 +4990,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -4604,10 +5010,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -4617,11 +5021,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + 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( @@ -4636,41 +5038,39 @@ def get_sql_stored_procedure( """Gets the SQL storedProcedure under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param stored_procedure_name: Cosmos DB storedProcedure name. + :param stored_procedure_name: Cosmos DB storedProcedure name. Required. :type stored_procedure_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlStoredProcedureGetResults, or the result of cls(response) + :return: SqlStoredProcedureGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlStoredProcedureGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlStoredProcedureGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_sql_stored_procedure.metadata['url'], + template_url=self.get_sql_stored_procedure.metadata["url"], headers=_headers, params=_params, ) @@ -4678,25 +5078,23 @@ def get_sql_stored_procedure( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SqlStoredProcedureGetResults', pipeline_response) + deserialized = self._deserialize("SqlStoredProcedureGetResults", pipeline_response) if cls: 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 - + 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, @@ -4705,34 +5103,41 @@ def _create_update_sql_stored_procedure_initial( database_name: str, container_name: str, stored_procedure_name: str, - create_update_sql_stored_procedure_parameters: _models.SqlStoredProcedureCreateUpdateParameters, + create_update_sql_stored_procedure_parameters: Union[_models.SqlStoredProcedureCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.SqlStoredProcedureGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SqlStoredProcedureGetResults]] - - _json = self._serialize.body(create_update_sql_stored_procedure_parameters, 'SqlStoredProcedureCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SqlStoredProcedureGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_sql_stored_procedure_parameters, (IO, bytes)): + _content = create_update_sql_stored_procedure_parameters + else: + _json = self._serialize.body( + create_update_sql_stored_procedure_parameters, "SqlStoredProcedureCreateUpdateParameters" + ) - request = build_create_update_sql_stored_procedure_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_sql_stored_procedure_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, stored_procedure_name=stored_procedure_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_sql_stored_procedure_initial.metadata['url'], + content=_content, + template_url=self._create_update_sql_stored_procedure_initial.metadata["url"], headers=_headers, params=_params, ) @@ -4740,10 +5145,9 @@ def _create_update_sql_stored_procedure_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -4752,17 +5156,16 @@ def _create_update_sql_stored_procedure_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SqlStoredProcedureGetResults', pipeline_response) + deserialized = self._deserialize("SqlStoredProcedureGetResults", pipeline_response) if cls: 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 - + _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 + @overload def begin_create_update_sql_stored_procedure( self, resource_group_name: str, @@ -4771,24 +5174,121 @@ def begin_create_update_sql_stored_procedure( container_name: str, stored_procedure_name: str, create_update_sql_stored_procedure_parameters: _models.SqlStoredProcedureCreateUpdateParameters, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param stored_procedure_name: Cosmos DB storedProcedure name. + :param stored_procedure_name: Cosmos DB storedProcedure name. Required. :type stored_procedure_name: str :param create_update_sql_stored_procedure_parameters: The parameters to provide for the current - SQL storedProcedure. + SQL storedProcedure. Required. :type create_update_sql_stored_procedure_parameters: ~azure.mgmt.cosmosdb.models.SqlStoredProcedureCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_update_sql_stored_procedure( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + stored_procedure_name: str, + create_update_sql_stored_procedure_parameters: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param stored_procedure_name: Cosmos DB storedProcedure name. Required. + :type stored_procedure_name: str + :param create_update_sql_stored_procedure_parameters: The parameters to provide for the current + SQL storedProcedure. Required. + :type create_update_sql_stored_procedure_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlStoredProcedureGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_update_sql_stored_procedure( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + stored_procedure_name: str, + create_update_sql_stored_procedure_parameters: Union[_models.SqlStoredProcedureCreateUpdateParameters, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param stored_procedure_name: Cosmos DB storedProcedure name. Required. + :type stored_procedure_name: str + :param create_update_sql_stored_procedure_parameters: The parameters to provide for the current + SQL storedProcedure. Is either a model type or a IO type. Required. + :type create_update_sql_stored_procedure_parameters: + ~azure.mgmt.cosmosdb.models.SqlStoredProcedureCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -4800,20 +5300,17 @@ def begin_create_update_sql_stored_procedure( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlStoredProcedureGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlStoredProcedureGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_update_sql_stored_procedure_initial( # type: ignore resource_group_name=resource_group_name, @@ -4824,39 +5321,35 @@ def begin_create_update_sql_stored_procedure( create_update_sql_stored_procedure_parameters=create_update_sql_stored_procedure_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SqlStoredProcedureGetResults', pipeline_response) + deserialized = self._deserialize("SqlStoredProcedureGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements self, @@ -4867,27 +5360,24 @@ def _delete_sql_stored_procedure_initial( # pylint: disable=inconsistent-return stored_procedure_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_sql_stored_procedure_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_sql_stored_procedure_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, stored_procedure_name=stored_procedure_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_sql_stored_procedure_initial.metadata['url'], + template_url=self._delete_sql_stored_procedure_initial.metadata["url"], headers=_headers, params=_params, ) @@ -4895,10 +5385,9 @@ def _delete_sql_stored_procedure_initial( # pylint: disable=inconsistent-return request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -4908,11 +5397,10 @@ def _delete_sql_stored_procedure_initial( # pylint: disable=inconsistent-return if cls: return cls(pipeline_response, None, {}) - _delete_sql_stored_procedure_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/storedProcedures/{storedProcedureName}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements + def begin_delete_sql_stored_procedure( self, resource_group_name: str, account_name: str, @@ -4924,14 +5412,15 @@ def begin_delete_sql_stored_procedure( # pylint: disable=inconsistent-return-st """Deletes an existing Azure Cosmos DB SQL storedProcedure. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param stored_procedure_name: Cosmos DB storedProcedure name. + :param stored_procedure_name: Cosmos DB storedProcedure name. Required. :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. @@ -4943,19 +5432,16 @@ def begin_delete_sql_stored_procedure( # pylint: disable=inconsistent-return-st 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_sql_stored_procedure_initial( # type: ignore resource_group_name=resource_group_name, @@ -4964,85 +5450,76 @@ def begin_delete_sql_stored_procedure( # pylint: disable=inconsistent-return-st container_name=container_name, stored_procedure_name=stored_procedure_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any - ) -> Iterable[_models.SqlUserDefinedFunctionListResult]: + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any + ) -> Iterable["_models.SqlUserDefinedFunctionGetResults"]: """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :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 + :return: An iterator like instance of either SqlUserDefinedFunctionGetResults or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlUserDefinedFunctionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlUserDefinedFunctionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_sql_user_defined_functions.metadata['url'], + template_url=self.list_sql_user_defined_functions.metadata["url"], headers=_headers, params=_params, ) @@ -5050,18 +5527,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -5077,10 +5547,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5090,11 +5558,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + 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( @@ -5109,41 +5575,39 @@ def get_sql_user_defined_function( """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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param user_defined_function_name: Cosmos DB userDefinedFunction name. + :param user_defined_function_name: Cosmos DB userDefinedFunction name. Required. :type user_defined_function_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlUserDefinedFunctionGetResults, or the result of cls(response) + :return: SqlUserDefinedFunctionGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlUserDefinedFunctionGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlUserDefinedFunctionGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_sql_user_defined_function.metadata['url'], + template_url=self.get_sql_user_defined_function.metadata["url"], headers=_headers, params=_params, ) @@ -5151,25 +5615,23 @@ def get_sql_user_defined_function( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SqlUserDefinedFunctionGetResults', pipeline_response) + deserialized = self._deserialize("SqlUserDefinedFunctionGetResults", pipeline_response) if cls: 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 - + 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, @@ -5178,34 +5640,43 @@ def _create_update_sql_user_defined_function_initial( database_name: str, container_name: str, user_defined_function_name: str, - create_update_sql_user_defined_function_parameters: _models.SqlUserDefinedFunctionCreateUpdateParameters, + create_update_sql_user_defined_function_parameters: Union[ + _models.SqlUserDefinedFunctionCreateUpdateParameters, IO + ], **kwargs: Any ) -> Optional[_models.SqlUserDefinedFunctionGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SqlUserDefinedFunctionGetResults]] - - _json = self._serialize.body(create_update_sql_user_defined_function_parameters, 'SqlUserDefinedFunctionCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SqlUserDefinedFunctionGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_sql_user_defined_function_parameters, (IO, bytes)): + _content = create_update_sql_user_defined_function_parameters + else: + _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, + request = build_create_update_sql_user_defined_function_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, user_defined_function_name=user_defined_function_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_sql_user_defined_function_initial.metadata['url'], + content=_content, + template_url=self._create_update_sql_user_defined_function_initial.metadata["url"], headers=_headers, params=_params, ) @@ -5213,10 +5684,9 @@ def _create_update_sql_user_defined_function_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5225,17 +5695,16 @@ def _create_update_sql_user_defined_function_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SqlUserDefinedFunctionGetResults', pipeline_response) + deserialized = self._deserialize("SqlUserDefinedFunctionGetResults", pipeline_response) if cls: 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 + _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 + @overload def begin_create_update_sql_user_defined_function( self, resource_group_name: str, @@ -5244,24 +5713,125 @@ def begin_create_update_sql_user_defined_function( container_name: str, user_defined_function_name: str, create_update_sql_user_defined_function_parameters: _models.SqlUserDefinedFunctionCreateUpdateParameters, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param user_defined_function_name: Cosmos DB userDefinedFunction name. + :param user_defined_function_name: Cosmos DB userDefinedFunction name. Required. :type user_defined_function_name: str :param create_update_sql_user_defined_function_parameters: The parameters to provide for the - current SQL userDefinedFunction. + current SQL userDefinedFunction. Required. :type create_update_sql_user_defined_function_parameters: ~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @overload + def begin_create_update_sql_user_defined_function( + self, + 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: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param user_defined_function_name: Cosmos DB userDefinedFunction name. Required. + :type user_defined_function_name: str + :param create_update_sql_user_defined_function_parameters: The parameters to provide for the + current SQL userDefinedFunction. Required. + :type create_update_sql_user_defined_function_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace + def begin_create_update_sql_user_defined_function( + self, + 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: Union[ + _models.SqlUserDefinedFunctionCreateUpdateParameters, IO + ], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param user_defined_function_name: Cosmos DB userDefinedFunction name. Required. + :type user_defined_function_name: str + :param create_update_sql_user_defined_function_parameters: The parameters to provide for the + current SQL userDefinedFunction. Is either a model type or a IO type. Required. + :type create_update_sql_user_defined_function_parameters: + ~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -5274,20 +5844,17 @@ def begin_create_update_sql_user_defined_function( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlUserDefinedFunctionGetResults] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlUserDefinedFunctionGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlUserDefinedFunctionGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_update_sql_user_defined_function_initial( # type: ignore resource_group_name=resource_group_name, @@ -5298,39 +5865,35 @@ def begin_create_update_sql_user_defined_function( create_update_sql_user_defined_function_parameters=create_update_sql_user_defined_function_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SqlUserDefinedFunctionGetResults', pipeline_response) + deserialized = self._deserialize("SqlUserDefinedFunctionGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements self, @@ -5341,27 +5904,24 @@ def _delete_sql_user_defined_function_initial( # pylint: disable=inconsistent-r user_defined_function_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_sql_user_defined_function_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_sql_user_defined_function_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, user_defined_function_name=user_defined_function_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_sql_user_defined_function_initial.metadata['url'], + template_url=self._delete_sql_user_defined_function_initial.metadata["url"], headers=_headers, params=_params, ) @@ -5369,10 +5929,9 @@ def _delete_sql_user_defined_function_initial( # pylint: disable=inconsistent-r request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -5382,11 +5941,10 @@ def _delete_sql_user_defined_function_initial( # pylint: disable=inconsistent-r if cls: return cls(pipeline_response, None, {}) - _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 - + _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( # pylint: disable=inconsistent-return-statements + def begin_delete_sql_user_defined_function( self, resource_group_name: str, account_name: str, @@ -5398,14 +5956,15 @@ def begin_delete_sql_user_defined_function( # pylint: disable=inconsistent-retu """Deletes an existing Azure Cosmos DB SQL userDefinedFunction. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param user_defined_function_name: Cosmos DB userDefinedFunction name. + :param user_defined_function_name: Cosmos DB userDefinedFunction name. Required. :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. @@ -5417,19 +5976,16 @@ def begin_delete_sql_user_defined_function( # pylint: disable=inconsistent-retu 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_sql_user_defined_function_initial( # type: ignore resource_group_name=resource_group_name, @@ -5438,84 +5994,75 @@ def begin_delete_sql_user_defined_function( # pylint: disable=inconsistent-retu container_name=container_name, user_defined_function_name=user_defined_function_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - account_name: str, - database_name: str, - container_name: str, - **kwargs: Any - ) -> Iterable[_models.SqlTriggerListResult]: + self, resource_group_name: str, account_name: str, database_name: str, container_name: str, **kwargs: Any + ) -> Iterable["_models.SqlTriggerGetResults"]: """Lists the SQL trigger under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :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 + :return: An iterator like instance of either SqlTriggerGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlTriggerListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlTriggerListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlTriggerListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_sql_triggers.metadata['url'], + template_url=self.list_sql_triggers.metadata["url"], headers=_headers, params=_params, ) @@ -5523,18 +6070,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -5550,10 +6090,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -5563,11 +6101,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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 + 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( @@ -5582,41 +6118,39 @@ def get_sql_trigger( """Gets the SQL trigger under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param trigger_name: Cosmos DB trigger name. + :param trigger_name: Cosmos DB trigger name. Required. :type trigger_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlTriggerGetResults, or the result of cls(response) + :return: SqlTriggerGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.SqlTriggerGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlTriggerGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlTriggerGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_sql_trigger.metadata['url'], + template_url=self.get_sql_trigger.metadata["url"], headers=_headers, params=_params, ) @@ -5624,25 +6158,23 @@ def get_sql_trigger( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SqlTriggerGetResults', pipeline_response) + deserialized = self._deserialize("SqlTriggerGetResults", pipeline_response) if cls: 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 - + 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, @@ -5651,34 +6183,39 @@ def _create_update_sql_trigger_initial( database_name: str, container_name: str, trigger_name: str, - create_update_sql_trigger_parameters: _models.SqlTriggerCreateUpdateParameters, + create_update_sql_trigger_parameters: Union[_models.SqlTriggerCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.SqlTriggerGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SqlTriggerGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SqlTriggerGetResults]] - _json = self._serialize.body(create_update_sql_trigger_parameters, 'SqlTriggerCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_sql_trigger_parameters, (IO, bytes)): + _content = create_update_sql_trigger_parameters + else: + _json = self._serialize.body(create_update_sql_trigger_parameters, "SqlTriggerCreateUpdateParameters") - request = build_create_update_sql_trigger_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_sql_trigger_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, trigger_name=trigger_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_sql_trigger_initial.metadata['url'], + content=_content, + template_url=self._create_update_sql_trigger_initial.metadata["url"], headers=_headers, params=_params, ) @@ -5686,10 +6223,9 @@ def _create_update_sql_trigger_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -5698,17 +6234,16 @@ def _create_update_sql_trigger_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SqlTriggerGetResults', pipeline_response) + deserialized = self._deserialize("SqlTriggerGetResults", pipeline_response) if cls: 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 - + _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 + @overload def begin_create_update_sql_trigger( self, resource_group_name: str, @@ -5717,24 +6252,121 @@ def begin_create_update_sql_trigger( container_name: str, trigger_name: str, create_update_sql_trigger_parameters: _models.SqlTriggerCreateUpdateParameters, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param trigger_name: Cosmos DB trigger name. + :param trigger_name: Cosmos DB trigger name. Required. :type trigger_name: str :param create_update_sql_trigger_parameters: The parameters to provide for the current SQL - trigger. + trigger. Required. :type create_update_sql_trigger_parameters: ~azure.mgmt.cosmosdb.models.SqlTriggerCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_update_sql_trigger( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + trigger_name: str, + create_update_sql_trigger_parameters: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param trigger_name: Cosmos DB trigger name. Required. + :type trigger_name: str + :param create_update_sql_trigger_parameters: The parameters to provide for the current SQL + trigger. Required. + :type create_update_sql_trigger_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlTriggerGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_update_sql_trigger( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + trigger_name: str, + create_update_sql_trigger_parameters: Union[_models.SqlTriggerCreateUpdateParameters, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param trigger_name: Cosmos DB trigger name. Required. + :type trigger_name: str + :param create_update_sql_trigger_parameters: The parameters to provide for the current SQL + trigger. Is either a model type or a IO type. Required. + :type create_update_sql_trigger_parameters: + ~azure.mgmt.cosmosdb.models.SqlTriggerCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -5746,20 +6378,17 @@ def begin_create_update_sql_trigger( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlTriggerGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlTriggerGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_update_sql_trigger_initial( # type: ignore resource_group_name=resource_group_name, @@ -5770,39 +6399,35 @@ def begin_create_update_sql_trigger( create_update_sql_trigger_parameters=create_update_sql_trigger_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SqlTriggerGetResults', pipeline_response) + deserialized = self._deserialize("SqlTriggerGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements self, @@ -5813,27 +6438,24 @@ def _delete_sql_trigger_initial( # pylint: disable=inconsistent-return-statemen trigger_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_sql_trigger_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_sql_trigger_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, trigger_name=trigger_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_sql_trigger_initial.metadata['url'], + template_url=self._delete_sql_trigger_initial.metadata["url"], headers=_headers, params=_params, ) @@ -5841,10 +6463,9 @@ def _delete_sql_trigger_initial( # pylint: disable=inconsistent-return-statemen request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -5854,11 +6475,10 @@ def _delete_sql_trigger_initial( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - _delete_sql_trigger_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlDatabases/{databaseName}/containers/{containerName}/triggers/{triggerName}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements + def begin_delete_sql_trigger( self, resource_group_name: str, account_name: str, @@ -5870,14 +6490,15 @@ def begin_delete_sql_trigger( # pylint: disable=inconsistent-return-statements """Deletes an existing Azure Cosmos DB SQL trigger. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param trigger_name: Cosmos DB trigger name. + :param trigger_name: Cosmos DB trigger name. Required. :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. @@ -5889,19 +6510,16 @@ def begin_delete_sql_trigger( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_sql_trigger_initial( # type: ignore resource_group_name=resource_group_name, @@ -5910,78 +6528,68 @@ def begin_delete_sql_trigger( # pylint: disable=inconsistent-return-statements container_name=container_name, trigger_name=trigger_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.SqlRoleDefinitionGetResults: """Retrieves the properties of an existing Azure Cosmos DB SQL Role Definition with the given Id. - :param role_definition_id: The GUID for the Role Definition. + :param role_definition_id: The GUID for the Role Definition. Required. :type role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlRoleDefinitionGetResults, or the result of cls(response) + :return: SqlRoleDefinitionGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlRoleDefinitionGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlRoleDefinitionGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_sql_role_definition.metadata['url'], + template_url=self.get_sql_role_definition.metadata["url"], headers=_headers, params=_params, ) @@ -5989,57 +6597,62 @@ def get_sql_role_definition( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SqlRoleDefinitionGetResults', pipeline_response) + deserialized = self._deserialize("SqlRoleDefinitionGetResults", pipeline_response) if cls: 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 - + 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: str, resource_group_name: str, account_name: str, - create_update_sql_role_definition_parameters: _models.SqlRoleDefinitionCreateUpdateParameters, + create_update_sql_role_definition_parameters: Union[_models.SqlRoleDefinitionCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.SqlRoleDefinitionGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SqlRoleDefinitionGetResults]] - - _json = self._serialize.body(create_update_sql_role_definition_parameters, 'SqlRoleDefinitionCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SqlRoleDefinitionGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_sql_role_definition_parameters, (IO, bytes)): + _content = create_update_sql_role_definition_parameters + else: + _json = self._serialize.body( + create_update_sql_role_definition_parameters, "SqlRoleDefinitionCreateUpdateParameters" + ) - request = build_create_update_sql_role_definition_request_initial( + request = build_create_update_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, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_sql_role_definition_initial.metadata['url'], + content=_content, + template_url=self._create_update_sql_role_definition_initial.metadata["url"], headers=_headers, params=_params, ) @@ -6047,10 +6660,9 @@ def _create_update_sql_role_definition_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6059,15 +6671,95 @@ def _create_update_sql_role_definition_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SqlRoleDefinitionGetResults', pipeline_response) + deserialized = self._deserialize("SqlRoleDefinitionGetResults", pipeline_response) if cls: 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 + _create_update_sql_role_definition_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}"} # type: ignore + + @overload + def begin_create_update_sql_role_definition( + self, + role_definition_id: str, + resource_group_name: str, + account_name: str, + create_update_sql_role_definition_parameters: _models.SqlRoleDefinitionCreateUpdateParameters, + *, + content_type: str = "application/json", + **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. Required. + :type role_definition_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param create_update_sql_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_sql_role_definition_parameters: + ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_update_sql_role_definition( + self, + role_definition_id: str, + resource_group_name: str, + account_name: str, + create_update_sql_role_definition_parameters: IO, + *, + content_type: str = "application/json", + **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. Required. + :type role_definition_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param create_update_sql_role_definition_parameters: The properties required to create or + update a Role Definition. Required. + :type create_update_sql_role_definition_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_update_sql_role_definition( @@ -6075,21 +6767,25 @@ def begin_create_update_sql_role_definition( role_definition_id: str, resource_group_name: str, account_name: str, - create_update_sql_role_definition_parameters: _models.SqlRoleDefinitionCreateUpdateParameters, + create_update_sql_role_definition_parameters: Union[_models.SqlRoleDefinitionCreateUpdateParameters, IO], **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. + :param role_definition_id: The GUID for the Role Definition. Required. :type role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param create_update_sql_role_definition_parameters: The properties required to create or - update a Role Definition. + update a Role Definition. Is either a model type or a IO type. Required. :type create_update_sql_role_definition_parameters: - ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionCreateUpdateParameters + ~azure.mgmt.cosmosdb.models.SqlRoleDefinitionCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -6101,20 +6797,17 @@ def begin_create_update_sql_role_definition( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlRoleDefinitionGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlRoleDefinitionGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_update_sql_role_definition_initial( # type: ignore role_definition_id=role_definition_id, @@ -6123,66 +6816,55 @@ def begin_create_update_sql_role_definition( create_update_sql_role_definition_parameters=create_update_sql_role_definition_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SqlRoleDefinitionGetResults', pipeline_response) + deserialized = self._deserialize("SqlRoleDefinitionGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements - self, - role_definition_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_sql_role_definition_request_initial( + request = build_delete_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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_sql_role_definition_initial.metadata['url'], + template_url=self._delete_sql_role_definition_initial.metadata["url"], headers=_headers, params=_params, ) @@ -6190,10 +6872,9 @@ def _delete_sql_role_definition_initial( # pylint: disable=inconsistent-return- request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -6203,24 +6884,20 @@ def _delete_sql_role_definition_initial( # pylint: disable=inconsistent-return- if cls: return cls(pipeline_response, None, {}) - _delete_sql_role_definition_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions/{roleDefinitionId}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements - self, - role_definition_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + def begin_delete_sql_role_definition( + self, role_definition_id: str, resource_group_name: str, account_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an existing Azure Cosmos DB SQL Role Definition. - :param role_definition_id: The GUID for the Role Definition. + :param role_definition_id: The GUID for the Role Definition. Required. :type role_definition_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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. @@ -6232,95 +6909,85 @@ def begin_delete_sql_role_definition( # pylint: disable=inconsistent-return-sta 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_sql_role_definition_initial( # type: ignore role_definition_id=role_definition_id, resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.SqlRoleDefinitionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.SqlRoleDefinitionGetResults"]: """Retrieves the list of all Azure Cosmos DB SQL Role Definitions. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 + :return: An iterator like instance of either SqlRoleDefinitionGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleDefinitionGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlRoleDefinitionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlRoleDefinitionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_sql_role_definitions_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_sql_role_definitions.metadata['url'], + template_url=self.list_sql_role_definitions.metadata["url"], headers=_headers, params=_params, ) @@ -6328,16 +6995,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_sql_role_definitions_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -6353,10 +7015,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6366,52 +7026,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_sql_role_definitions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleDefinitions"} # type: ignore + 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: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, 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. + :param role_assignment_id: The GUID for the Role Assignment. Required. :type role_assignment_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlRoleAssignmentGetResults, or the result of cls(response) + :return: SqlRoleAssignmentGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.SqlRoleAssignmentGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlRoleAssignmentGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlRoleAssignmentGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_sql_role_assignment.metadata['url'], + template_url=self.get_sql_role_assignment.metadata["url"], headers=_headers, params=_params, ) @@ -6419,57 +7071,62 @@ def get_sql_role_assignment( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SqlRoleAssignmentGetResults', pipeline_response) + deserialized = self._deserialize("SqlRoleAssignmentGetResults", pipeline_response) if cls: 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 - + 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: str, resource_group_name: str, account_name: str, - create_update_sql_role_assignment_parameters: _models.SqlRoleAssignmentCreateUpdateParameters, + create_update_sql_role_assignment_parameters: Union[_models.SqlRoleAssignmentCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.SqlRoleAssignmentGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.SqlRoleAssignmentGetResults]] - - _json = self._serialize.body(create_update_sql_role_assignment_parameters, 'SqlRoleAssignmentCreateUpdateParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SqlRoleAssignmentGetResults]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_sql_role_assignment_parameters, (IO, bytes)): + _content = create_update_sql_role_assignment_parameters + else: + _json = self._serialize.body( + create_update_sql_role_assignment_parameters, "SqlRoleAssignmentCreateUpdateParameters" + ) - request = build_create_update_sql_role_assignment_request_initial( + request = build_create_update_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, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_sql_role_assignment_initial.metadata['url'], + content=_content, + template_url=self._create_update_sql_role_assignment_initial.metadata["url"], headers=_headers, params=_params, ) @@ -6477,10 +7134,9 @@ def _create_update_sql_role_assignment_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6489,37 +7145,121 @@ def _create_update_sql_role_assignment_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SqlRoleAssignmentGetResults', pipeline_response) + deserialized = self._deserialize("SqlRoleAssignmentGetResults", pipeline_response) if cls: 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 - + _create_update_sql_role_assignment_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}"} # type: ignore - @distributed_trace + @overload def begin_create_update_sql_role_assignment( self, role_assignment_id: str, resource_group_name: str, account_name: str, create_update_sql_role_assignment_parameters: _models.SqlRoleAssignmentCreateUpdateParameters, + *, + content_type: str = "application/json", **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. + :param role_assignment_id: The GUID for the Role Assignment. Required. :type role_assignment_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str :param create_update_sql_role_assignment_parameters: The properties required to create or - update a Role Assignment. + update a Role Assignment. Required. :type create_update_sql_role_assignment_parameters: ~azure.mgmt.cosmosdb.models.SqlRoleAssignmentCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlRoleAssignmentGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_update_sql_role_assignment( + self, + role_assignment_id: str, + resource_group_name: str, + account_name: str, + create_update_sql_role_assignment_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SqlRoleAssignmentGetResults]: + """Creates or updates an Azure Cosmos DB SQL Role Assignment. + + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param create_update_sql_role_assignment_parameters: The properties required to create or + update a Role Assignment. Required. + :type create_update_sql_role_assignment_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.SqlRoleAssignmentGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_update_sql_role_assignment( + self, + role_assignment_id: str, + resource_group_name: str, + account_name: str, + create_update_sql_role_assignment_parameters: Union[_models.SqlRoleAssignmentCreateUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.SqlRoleAssignmentGetResults]: + """Creates or updates an Azure Cosmos DB SQL Role Assignment. + + :param role_assignment_id: The GUID for the Role Assignment. Required. + :type role_assignment_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param create_update_sql_role_assignment_parameters: The properties required to create or + update a Role Assignment. Is either a model type or a IO type. Required. + :type create_update_sql_role_assignment_parameters: + ~azure.mgmt.cosmosdb.models.SqlRoleAssignmentCreateUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -6531,20 +7271,17 @@ def begin_create_update_sql_role_assignment( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlRoleAssignmentGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlRoleAssignmentGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_update_sql_role_assignment_initial( # type: ignore role_assignment_id=role_assignment_id, @@ -6553,66 +7290,55 @@ def begin_create_update_sql_role_assignment( create_update_sql_role_assignment_parameters=create_update_sql_role_assignment_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('SqlRoleAssignmentGetResults', pipeline_response) + deserialized = self._deserialize("SqlRoleAssignmentGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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( # pylint: disable=inconsistent-return-statements - self, - role_assignment_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, role_assignment_id: str, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_sql_role_assignment_request_initial( + request = build_delete_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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_sql_role_assignment_initial.metadata['url'], + template_url=self._delete_sql_role_assignment_initial.metadata["url"], headers=_headers, params=_params, ) @@ -6620,10 +7346,9 @@ def _delete_sql_role_assignment_initial( # pylint: disable=inconsistent-return- request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -6633,24 +7358,20 @@ def _delete_sql_role_assignment_initial( # pylint: disable=inconsistent-return- if cls: return cls(pipeline_response, None, {}) - _delete_sql_role_assignment_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments/{roleAssignmentId}"} # type: ignore - + _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( # pylint: disable=inconsistent-return-statements - self, - role_assignment_id: str, - resource_group_name: str, - account_name: str, - **kwargs: Any + def begin_delete_sql_role_assignment( + self, 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. + :param role_assignment_id: The GUID for the Role Assignment. Required. :type role_assignment_id: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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. @@ -6662,95 +7383,85 @@ def begin_delete_sql_role_assignment( # pylint: disable=inconsistent-return-sta 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_sql_role_assignment_initial( # type: ignore role_assignment_id=role_assignment_id, resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.SqlRoleAssignmentListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.SqlRoleAssignmentGetResults"]: """Retrieves the list of all Azure Cosmos DB SQL Role Assignments. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 + :return: An iterator like instance of either SqlRoleAssignmentGetResults or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.SqlRoleAssignmentGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SqlRoleAssignmentListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlRoleAssignmentListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_sql_role_assignments_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_sql_role_assignments.metadata['url'], + template_url=self.list_sql_role_assignments.metadata["url"], headers=_headers, params=_params, ) @@ -6758,16 +7469,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_sql_role_assignments_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -6783,10 +7489,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -6796,11 +7500,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_sql_role_assignments.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments"} # type: ignore + list_sql_role_assignments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/sqlRoleAssignments"} # type: ignore def _retrieve_continuous_backup_information_initial( self, @@ -6808,33 +7510,38 @@ def _retrieve_continuous_backup_information_initial( account_name: str, database_name: str, container_name: str, - location: _models.ContinuousBackupRestoreLocation, + location: Union[_models.ContinuousBackupRestoreLocation, IO], **kwargs: Any ) -> Optional[_models.BackupInformation]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.BackupInformation]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.BackupInformation]] - _json = self._serialize.body(location, 'ContinuousBackupRestoreLocation') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(location, (IO, bytes)): + _content = location + else: + _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") - request = build_retrieve_continuous_backup_information_request_initial( - subscription_id=self._config.subscription_id, + request = build_retrieve_continuous_backup_information_request( resource_group_name=resource_group_name, account_name=account_name, database_name=database_name, container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._retrieve_continuous_backup_information_initial.metadata['url'], + content=_content, + template_url=self._retrieve_continuous_backup_information_initial.metadata["url"], headers=_headers, params=_params, ) @@ -6842,10 +7549,9 @@ def _retrieve_continuous_backup_information_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -6854,17 +7560,16 @@ def _retrieve_continuous_backup_information_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BackupInformation', pipeline_response) + deserialized = self._deserialize("BackupInformation", pipeline_response) if cls: 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 + _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 + @overload def begin_retrieve_continuous_backup_information( self, resource_group_name: str, @@ -6872,20 +7577,68 @@ def begin_retrieve_continuous_backup_information( database_name: str, container_name: str, location: _models.ContinuousBackupRestoreLocation, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param database_name: Cosmos DB database name. + :param database_name: Cosmos DB database name. Required. :type database_name: str - :param container_name: Cosmos DB container name. + :param container_name: Cosmos DB container name. Required. :type container_name: str - :param location: The name of the continuous backup restore location. + :param location: The name of the continuous backup restore location. Required. :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_retrieve_continuous_backup_information( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + location: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param location: The name of the continuous backup restore location. Required. + :type location: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 @@ -6897,20 +7650,58 @@ def begin_retrieve_continuous_backup_information( :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: + """ + + @distributed_trace + def begin_retrieve_continuous_backup_information( + self, + resource_group_name: str, + account_name: str, + database_name: str, + container_name: str, + location: Union[_models.ContinuousBackupRestoreLocation, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param database_name: Cosmos DB database name. Required. + :type database_name: str + :param container_name: Cosmos DB container name. Required. + :type container_name: str + :param location: The name of the continuous backup restore location. Is either a model type or + a IO type. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BackupInformation] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupInformation] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._retrieve_continuous_backup_information_initial( # type: ignore resource_group_name=resource_group_name, @@ -6920,36 +7711,34 @@ def begin_retrieve_continuous_backup_information( location=location, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BackupInformation', pipeline_response) + deserialized = self._deserialize("BackupInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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 a093537a817e..83e2ab2af4d0 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 @@ -6,11 +6,16 @@ # 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 Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 HttpResponse @@ -22,377 +27,341 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") 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 + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables", + ) # pylint: disable=line-too-long 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]+)*'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_table_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_create_update_table_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - table_name: str, - *, - json: Optional[_models.TableCreateUpdateParameters] = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_update_table_request( + resource_group_name: str, account_name: str, table_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - 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 + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_table_request( + resource_group_name: str, account_name: str, table_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_table_throughput_request( - subscription_id: str, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_update_table_throughput_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - table_name: str, - *, - json: Optional[_models.ThroughputSettingsUpdateParameters] = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_table_throughput_request( + resource_group_name: str, account_name: str, table_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - 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 + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_migrate_table_to_autoscale_request( + resource_group_name: str, account_name: str, table_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToAutoscale", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_migrate_table_to_manual_throughput_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_migrate_table_to_manual_throughput_request( + resource_group_name: str, account_name: str, table_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_retrieve_continuous_backup_information_request_initial( - subscription_id: str, - resource_group_name: str, - account_name: str, - table_name: str, - *, - json: Optional[_models.ContinuousBackupRestoreLocation] = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_retrieve_continuous_backup_information_request( + resource_group_name: str, account_name: str, table_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-15-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/retrieveContinuousBackupInformation") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/retrieveContinuousBackupInformation", + ) # pylint: disable=line-too-long 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'), + "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 - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class TableResourcesOperations: """ @@ -413,44 +382,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_tables( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.TableListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.TableGetResults"]: """Lists the Tables under an existing Azure Cosmos DB database account. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :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 TableListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.TableListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either TableGetResults or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cosmosdb.models.TableGetResults] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: - + request = build_list_tables_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, account_name=account_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_tables.metadata['url'], + template_url=self.list_tables.metadata["url"], headers=_headers, params=_params, ) @@ -458,16 +423,11 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_tables_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - account_name=account_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -483,10 +443,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -496,52 +454,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_tables.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables"} # type: ignore + 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: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> _models.TableGetResults: """Gets the Tables under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableGetResults, or the result of cls(response) + :return: TableGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.TableGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_table.metadata['url'], + template_url=self.get_table.metadata["url"], headers=_headers, params=_params, ) @@ -549,57 +499,60 @@ def get_table( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableGetResults', pipeline_response) + deserialized = self._deserialize("TableGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_table.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}"} # type: ignore - + 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: str, account_name: str, table_name: str, - create_update_table_parameters: _models.TableCreateUpdateParameters, + create_update_table_parameters: Union[_models.TableCreateUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.TableGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.TableGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TableGetResults]] - _json = self._serialize.body(create_update_table_parameters, 'TableCreateUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(create_update_table_parameters, (IO, bytes)): + _content = create_update_table_parameters + else: + _json = self._serialize.body(create_update_table_parameters, "TableCreateUpdateParameters") - request = build_create_update_table_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_update_table_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_update_table_initial.metadata['url'], + content=_content, + template_url=self._create_update_table_initial.metadata["url"], headers=_headers, params=_params, ) @@ -607,10 +560,9 @@ def _create_update_table_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -619,35 +571,120 @@ def _create_update_table_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TableGetResults', pipeline_response) + deserialized = self._deserialize("TableGetResults", pipeline_response) if cls: 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 - + _create_update_table_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}"} # type: ignore - @distributed_trace + @overload def begin_create_update_table( self, resource_group_name: str, account_name: str, table_name: str, create_update_table_parameters: _models.TableCreateUpdateParameters, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param create_update_table_parameters: The parameters to provide for the current Table. + Required. + :type create_update_table_parameters: ~azure.mgmt.cosmosdb.models.TableCreateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.TableGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_update_table( + self, + resource_group_name: str, + account_name: str, + table_name: str, + create_update_table_parameters: IO, + *, + content_type: str = "application/json", **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. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :type table_name: str :param create_update_table_parameters: The parameters to provide for the current Table. + Required. + :type create_update_table_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.TableGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_update_table( + self, + resource_group_name: str, + account_name: str, + table_name: str, + create_update_table_parameters: Union[_models.TableCreateUpdateParameters, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param create_update_table_parameters: The parameters to provide for the current Table. Is + either a model type or a IO type. Required. :type create_update_table_parameters: ~azure.mgmt.cosmosdb.models.TableCreateUpdateParameters + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -659,20 +696,17 @@ def begin_create_update_table( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_update_table_initial( # type: ignore resource_group_name=resource_group_name, @@ -681,66 +715,55 @@ def begin_create_update_table( create_update_table_parameters=create_update_table_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('TableGetResults', pipeline_response) + deserialized = self._deserialize("TableGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_create_update_table.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}"} # type: ignore def _delete_table_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_table_request_initial( - subscription_id=self._config.subscription_id, + request = build_delete_table_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_table_initial.metadata['url'], + template_url=self._delete_table_initial.metadata["url"], headers=_headers, params=_params, ) @@ -748,10 +771,9 @@ def _delete_table_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -761,24 +783,20 @@ def _delete_table_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_table_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}"} # type: ignore - + _delete_table_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}"} # type: ignore @distributed_trace - def begin_delete_table( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + def begin_delete_table( + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes an existing Azure Cosmos DB Table. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :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. @@ -790,98 +808,85 @@ def begin_delete_table( # pylint: disable=inconsistent-return-statements 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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._delete_table_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> _models.ThroughputSettingsGetResults: """Gets the RUs per second of the Table under an existing Azure Cosmos DB database account with the provided name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ThroughputSettingsGetResults, or the result of cls(response) + :return: ThroughputSettingsGetResults or the result of cls(response) :rtype: ~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] - 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, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_table_throughput.metadata['url'], + template_url=self.get_table_throughput.metadata["url"], headers=_headers, params=_params, ) @@ -889,57 +894,60 @@ def get_table_throughput( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + 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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + 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: str, account_name: str, table_name: str, - update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - _json = self._serialize.body(update_throughput_parameters, 'ThroughputSettingsUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_throughput_parameters, (IO, bytes)): + _content = update_throughput_parameters + else: + _json = self._serialize.body(update_throughput_parameters, "ThroughputSettingsUpdateParameters") - request = build_update_table_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_table_throughput_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_table_throughput_initial.metadata['url'], + content=_content, + template_url=self._update_table_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -947,10 +955,9 @@ def _update_table_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -959,37 +966,121 @@ def _update_table_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _update_table_throughput_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default"} # type: ignore - @distributed_trace + @overload def begin_update_table_throughput( self, resource_group_name: str, account_name: str, table_name: str, update_throughput_parameters: _models.ThroughputSettingsUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Update RUs per second of an Azure Cosmos DB Table. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :type table_name: str :param update_throughput_parameters: The parameters to provide for the RUs per second of the - current Table. + current Table. Required. :type update_throughput_parameters: ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_table_throughput( + self, + resource_group_name: str, + account_name: str, + table_name: str, + update_throughput_parameters: IO, + *, + content_type: str = "application/json", + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current Table. Required. + :type update_throughput_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.ThroughputSettingsGetResults] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_table_throughput( + self, + resource_group_name: str, + account_name: str, + table_name: str, + update_throughput_parameters: Union[_models.ThroughputSettingsUpdateParameters, IO], + **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. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param update_throughput_parameters: The parameters to provide for the RUs per second of the + current Table. Is either a model type or a IO type. Required. + :type update_throughput_parameters: + ~azure.mgmt.cosmosdb.models.ThroughputSettingsUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -1001,20 +1092,17 @@ def begin_update_table_throughput( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._update_table_throughput_initial( # type: ignore resource_group_name=resource_group_name, @@ -1023,66 +1111,55 @@ def begin_update_table_throughput( update_throughput_parameters=update_throughput_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_table_to_autoscale_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_table_to_autoscale_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_table_to_autoscale_initial.metadata['url'], + template_url=self._migrate_table_to_autoscale_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1090,10 +1167,9 @@ def _migrate_table_to_autoscale_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1102,31 +1178,27 @@ def _migrate_table_to_autoscale_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB Table from manual throughput to autoscale. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :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. @@ -1139,85 +1211,71 @@ def begin_migrate_table_to_autoscale( :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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._migrate_table_to_autoscale_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + 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: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> Optional[_models.ThroughputSettingsGetResults]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ThroughputSettingsGetResults]] - - request = build_migrate_table_to_manual_throughput_request_initial( - subscription_id=self._config.subscription_id, + request = build_migrate_table_to_manual_throughput_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migrate_table_to_manual_throughput_initial.metadata['url'], + template_url=self._migrate_table_to_manual_throughput_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1225,10 +1283,9 @@ def _migrate_table_to_manual_throughput_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1237,31 +1294,27 @@ def _migrate_table_to_manual_throughput_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: 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 - + _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: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> LROPoller[_models.ThroughputSettingsGetResults]: """Migrate an Azure Cosmos DB Table from autoscale to manual throughput. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :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. @@ -1274,90 +1327,88 @@ def begin_migrate_table_to_manual_throughput( :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: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ThroughputSettingsGetResults] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ThroughputSettingsGetResults] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._migrate_table_to_manual_throughput_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ThroughputSettingsGetResults', pipeline_response) + deserialized = self._deserialize("ThroughputSettingsGetResults", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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 + begin_migrate_table_to_manual_throughput.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/throughputSettings/default/migrateToManualThroughput"} # type: ignore def _retrieve_continuous_backup_information_initial( self, resource_group_name: str, account_name: str, table_name: str, - location: _models.ContinuousBackupRestoreLocation, + location: Union[_models.ContinuousBackupRestoreLocation, IO], **kwargs: Any ) -> Optional[_models.BackupInformation]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.BackupInformation]] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.BackupInformation]] - _json = self._serialize.body(location, 'ContinuousBackupRestoreLocation') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(location, (IO, bytes)): + _content = location + else: + _json = self._serialize.body(location, "ContinuousBackupRestoreLocation") - request = build_retrieve_continuous_backup_information_request_initial( - subscription_id=self._config.subscription_id, + request = build_retrieve_continuous_backup_information_request( resource_group_name=resource_group_name, account_name=account_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._retrieve_continuous_backup_information_initial.metadata['url'], + content=_content, + template_url=self._retrieve_continuous_backup_information_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1365,10 +1416,9 @@ def _retrieve_continuous_backup_information_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1377,35 +1427,117 @@ def _retrieve_continuous_backup_information_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('BackupInformation', pipeline_response) + deserialized = self._deserialize("BackupInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _retrieve_continuous_backup_information_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/retrieveContinuousBackupInformation"} # type: ignore - + _retrieve_continuous_backup_information_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/retrieveContinuousBackupInformation"} # type: ignore - @distributed_trace + @overload def begin_retrieve_continuous_backup_information( self, resource_group_name: str, account_name: str, table_name: str, location: _models.ContinuousBackupRestoreLocation, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.BackupInformation]: """Retrieves continuous backup information for a table. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param account_name: Cosmos DB database account name. + :param account_name: Cosmos DB database account name. Required. :type account_name: str - :param table_name: Cosmos DB table name. + :param table_name: Cosmos DB table name. Required. :type table_name: str - :param location: The name of the continuous backup restore location. + :param location: The name of the continuous backup restore location. Required. :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_retrieve_continuous_backup_information( + self, + resource_group_name: str, + account_name: str, + table_name: str, + location: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a table. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param location: The name of the continuous backup restore location. Required. + :type location: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cosmosdb.models.BackupInformation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_retrieve_continuous_backup_information( + self, + resource_group_name: str, + account_name: str, + table_name: str, + location: Union[_models.ContinuousBackupRestoreLocation, IO], + **kwargs: Any + ) -> LROPoller[_models.BackupInformation]: + """Retrieves continuous backup information for a table. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param account_name: Cosmos DB database account name. Required. + :type account_name: str + :param table_name: Cosmos DB table name. Required. + :type table_name: str + :param location: The name of the continuous backup restore location. Is either a model type or + a IO type. Required. + :type location: ~azure.mgmt.cosmosdb.models.ContinuousBackupRestoreLocation or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 @@ -1417,20 +1549,17 @@ def begin_retrieve_continuous_backup_information( :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: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-15-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BackupInformation] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BackupInformation] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._retrieve_continuous_backup_information_initial( # type: ignore resource_group_name=resource_group_name, @@ -1439,36 +1568,34 @@ def begin_retrieve_continuous_backup_information( location=location, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BackupInformation', pipeline_response) + deserialized = self._deserialize("BackupInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) 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}/tables/{tableName}/retrieveContinuousBackupInformation"} # type: ignore + begin_retrieve_continuous_backup_information.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/tables/{tableName}/retrieveContinuousBackupInformation"} # type: ignore