diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/_meta.json b/sdk/mongocluster/azure-mgmt-mongocluster/_meta.json index ac8e83a0a5854..7019640dd6655 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/_meta.json +++ b/sdk/mongocluster/azure-mgmt-mongocluster/_meta.json @@ -1,7 +1,6 @@ { - "commit": "abad0096677005817d2c19df2364663e5583c8fc", + "commit": "0e07b94c054259e5864acc855eb3977fb6dee368", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "typespec_src": "specification/mongocluster/DocumentDB.MongoCluster.Management", - "@azure-tools/typespec-python": "0.24.3", - "@autorest/python": "6.14.3" + "@azure-tools/typespec-python": "0.27.1" } \ No newline at end of file diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_client.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_client.py index 65bc5634509fa..d2c61cdfec719 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_client.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_client.py @@ -23,6 +23,7 @@ Operations, PrivateEndpointConnectionsOperations, PrivateLinksOperations, + ReplicasOperations, ) if TYPE_CHECKING: @@ -45,6 +46,8 @@ class MongoClusterMgmtClient: # pylint: disable=client-accepts-api-version-keyw azure.mgmt.mongocluster.operations.PrivateEndpointConnectionsOperations :ivar private_links: PrivateLinksOperations operations :vartype private_links: azure.mgmt.mongocluster.operations.PrivateLinksOperations + :ivar replicas: ReplicasOperations operations + :vartype replicas: azure.mgmt.mongocluster.operations.ReplicasOperations :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. @@ -52,7 +55,7 @@ class MongoClusterMgmtClient: # pylint: disable=client-accepts-api-version-keyw :param base_url: Service host. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: The API version to use for this operation. Default value is - "2024-03-01-preview". Note that overriding this default value may result in unsupported + "2024-06-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -99,6 +102,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.private_links = PrivateLinksOperations(self._client, self._config, self._serialize, self._deserialize) + self.replicas = ReplicasOperations(self._client, self._config, self._serialize, self._deserialize) def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_configuration.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_configuration.py index 796ced91ee477..1cee0cdcdc5f3 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_configuration.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_configuration.py @@ -29,13 +29,13 @@ class MongoClusterMgmtClientConfiguration: # pylint: disable=too-many-instance- :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :keyword api_version: The API version to use for this operation. Default value is - "2024-03-01-preview". Note that overriding this default value may result in unsupported + "2024-06-01-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: - api_version: str = kwargs.pop("api_version", "2024-03-01-preview") + api_version: str = kwargs.pop("api_version", "2024-06-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_model_base.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_model_base.py index 43fd8c7e9b1b4..7d82ac3456cbb 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_model_base.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_model_base.py @@ -563,6 +563,7 @@ def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing. """ result = {} + readonly_props = [] if exclude_readonly: readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] for k, v in self.items(): diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_validation.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_validation.py new file mode 100644 index 0000000000000..752b2822f9d3e --- /dev/null +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_validation.py @@ -0,0 +1,50 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools + + +def api_version_validation(**kwargs): + params_added_on = kwargs.pop("params_added_on", {}) + method_added_on = kwargs.pop("method_added_on", "") + + def decorator(func): + @functools.wraps(func) + def wrapper(*args, **kwargs): + try: + # this assumes the client has an _api_version attribute + client = args[0] + client_api_version = client._config.api_version # pylint: disable=protected-access + except AttributeError: + return func(*args, **kwargs) + + if method_added_on > client_api_version: + raise ValueError( + f"'{func.__name__}' is not available in API version " + f"{client_api_version}. Pass service API version {method_added_on} or newer to your client." + ) + + unsupported = { + parameter: api_version + for api_version, parameters in params_added_on.items() + for parameter in parameters + if parameter in kwargs and api_version > client_api_version + } + if unsupported: + raise ValueError( + "".join( + [ + f"'{param}' is not available in API version {client_api_version}. " + f"Use service API version {version} or newer.\n" + for param, version in unsupported.items() + ] + ) + ) + return func(*args, **kwargs) + + return wrapper + + return decorator diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/_client.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/_client.py index 0b9d1db90cb60..0ebb5f3a7dca9 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/_client.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/_client.py @@ -23,6 +23,7 @@ Operations, PrivateEndpointConnectionsOperations, PrivateLinksOperations, + ReplicasOperations, ) if TYPE_CHECKING: @@ -45,6 +46,8 @@ class MongoClusterMgmtClient: # pylint: disable=client-accepts-api-version-keyw azure.mgmt.mongocluster.aio.operations.PrivateEndpointConnectionsOperations :ivar private_links: PrivateLinksOperations operations :vartype private_links: azure.mgmt.mongocluster.aio.operations.PrivateLinksOperations + :ivar replicas: ReplicasOperations operations + :vartype replicas: azure.mgmt.mongocluster.aio.operations.ReplicasOperations :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. @@ -52,7 +55,7 @@ class MongoClusterMgmtClient: # pylint: disable=client-accepts-api-version-keyw :param base_url: Service host. Default value is "https://management.azure.com". :type base_url: str :keyword api_version: The API version to use for this operation. Default value is - "2024-03-01-preview". Note that overriding this default value may result in unsupported + "2024-06-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -99,6 +102,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.private_links = PrivateLinksOperations(self._client, self._config, self._serialize, self._deserialize) + self.replicas = ReplicasOperations(self._client, self._config, self._serialize, self._deserialize) def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/_configuration.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/_configuration.py index 83ff87dfc04d3..ba4223890e750 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/_configuration.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/_configuration.py @@ -29,13 +29,13 @@ class MongoClusterMgmtClientConfiguration: # pylint: disable=too-many-instance- :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :keyword api_version: The API version to use for this operation. Default value is - "2024-03-01-preview". Note that overriding this default value may result in unsupported + "2024-06-01-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: - api_version: str = kwargs.pop("api_version", "2024-03-01-preview") + api_version: str = kwargs.pop("api_version", "2024-06-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/operations/__init__.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/operations/__init__.py index a1f89f68dd6eb..c2fa532ddd595 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/operations/__init__.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/operations/__init__.py @@ -11,6 +11,7 @@ from ._operations import FirewallRulesOperations from ._operations import PrivateEndpointConnectionsOperations from ._operations import PrivateLinksOperations +from ._operations import ReplicasOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -22,6 +23,7 @@ "FirewallRulesOperations", "PrivateEndpointConnectionsOperations", "PrivateLinksOperations", + "ReplicasOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/operations/_operations.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/operations/_operations.py index aae6d1cfb603a..c31edd460d8b7 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/operations/_operations.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/operations/_operations.py @@ -33,6 +33,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -46,6 +48,7 @@ from ... import models as _models from ..._model_base import SdkJSONEncoder, _deserialize +from ..._validation import api_version_validation from ...operations._operations import ( build_firewall_rules_create_or_update_request, build_firewall_rules_delete_request, @@ -58,6 +61,7 @@ build_mongo_clusters_list_by_resource_group_request, build_mongo_clusters_list_connection_strings_request, build_mongo_clusters_list_request, + build_mongo_clusters_promote_request, build_mongo_clusters_update_request, build_operations_list_request, build_private_endpoint_connections_create_request, @@ -65,6 +69,7 @@ build_private_endpoint_connections_get_request, build_private_endpoint_connections_list_by_mongo_cluster_request, build_private_links_list_by_mongo_cluster_request, + build_replicas_list_by_parent_request, ) if sys.version_info >= (3, 9): @@ -94,6 +99,10 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={"2024-03-01-preview": ["api_version", "accept"]}, + ) def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """List the operations for the provider. @@ -202,6 +211,18 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "accept", + ] + }, + ) async def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any) -> _models.MongoCluster: """Gets information about a mongo cluster. @@ -229,6 +250,7 @@ async def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -238,6 +260,9 @@ async def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -269,6 +294,15 @@ async def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -321,7 +355,10 @@ async def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: if response.status_code not in [200]: if _stream: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -336,6 +373,18 @@ async def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: return deserialized # type: ignore + @api_version_validation( + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "content_type", + "accept", + ] + }, + ) async def _create_or_update_initial( self, resource_group_name: str, @@ -384,19 +433,19 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.iter_bytes() - if response.status_code == 201: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -446,6 +495,7 @@ async def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -455,6 +505,9 @@ async def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -486,6 +539,15 @@ async def begin_create_or_update( ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -518,6 +580,7 @@ async def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -527,6 +590,9 @@ async def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -558,6 +624,15 @@ async def begin_create_or_update( ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -622,6 +697,7 @@ async def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -631,6 +707,9 @@ async def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -662,6 +741,15 @@ async def begin_create_or_update( ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -726,6 +814,7 @@ async def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -735,6 +824,9 @@ async def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -766,6 +858,15 @@ async def begin_create_or_update( ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -788,6 +889,19 @@ async def begin_create_or_update( """ @distributed_trace_async + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "content_type", + "accept", + ] + }, + ) async def begin_create_or_update( self, resource_group_name: str, @@ -826,6 +940,7 @@ async def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -835,6 +950,9 @@ async def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -866,6 +984,15 @@ async def begin_create_or_update( ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -898,6 +1025,7 @@ async def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -907,6 +1035,9 @@ async def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -938,6 +1069,15 @@ async def begin_create_or_update( ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -1004,6 +1144,18 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + @api_version_validation( + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "content_type", + "accept", + ] + }, + ) async def _update_initial( self, resource_group_name: str, @@ -1052,20 +1204,20 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.iter_bytes() - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1117,6 +1269,9 @@ async def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "publicNetworkAccess": "str", "serverVersion": "str" }, @@ -1137,6 +1292,7 @@ async def begin_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1146,6 +1302,9 @@ async def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1177,6 +1336,15 @@ async def begin_update( ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -1241,6 +1409,7 @@ async def begin_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1250,6 +1419,9 @@ async def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1281,6 +1453,15 @@ async def begin_update( ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -1345,6 +1526,7 @@ async def begin_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1354,6 +1536,9 @@ async def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1385,6 +1570,15 @@ async def begin_update( ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -1407,6 +1601,19 @@ async def begin_update( """ @distributed_trace_async + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "content_type", + "accept", + ] + }, + ) async def begin_update( self, resource_group_name: str, @@ -1447,6 +1654,9 @@ async def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "publicNetworkAccess": "str", "serverVersion": "str" }, @@ -1467,6 +1677,7 @@ async def begin_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1476,6 +1687,9 @@ async def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1507,6 +1721,15 @@ async def begin_update( ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -1573,6 +1796,17 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + @api_version_validation( + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "accept", + ] + }, + ) async def _delete_initial( self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: @@ -1607,7 +1841,10 @@ async def _delete_initial( response = pipeline_response.http_response if response.status_code not in [202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1617,10 +1854,7 @@ async def _delete_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() - - if response.status_code == 204: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1628,6 +1862,18 @@ async def _delete_initial( return deserialized # type: ignore @distributed_trace_async + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "accept", + ] + }, + ) async def begin_delete( self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: @@ -1681,6 +1927,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={"2024-03-01-preview": ["api_version", "subscription_id", "resource_group_name", "accept"]}, + ) def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.MongoCluster"]: """List all the mongo clusters in a given resource group. @@ -1706,6 +1956,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1715,6 +1966,9 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1746,6 +2000,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -1834,6 +2097,10 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={"2024-03-01-preview": ["api_version", "subscription_id", "accept"]}, + ) def list(self, **kwargs: Any) -> AsyncIterable["_models.MongoCluster"]: """List all the mongo clusters in a given subscription. @@ -1856,6 +2123,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.MongoCluster"]: "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1865,6 +2133,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.MongoCluster"]: "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1896,6 +2167,15 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.MongoCluster"]: ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -1983,6 +2263,18 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "accept", + ] + }, + ) async def list_connection_strings( self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any ) -> _models.ListConnectionStringsResult: @@ -2044,7 +2336,10 @@ async def list_connection_strings( if response.status_code not in [200]: if _stream: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -2158,6 +2453,12 @@ async def check_name_availability( """ @distributed_trace_async + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": ["api_version", "subscription_id", "location", "content_type", "accept"] + }, + ) async def check_name_availability( self, location: str, body: Union[_models.CheckNameAvailabilityRequest, JSON, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResponse: @@ -2230,7 +2531,10 @@ async def check_name_availability( if response.status_code not in [200]: if _stream: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -2245,6 +2549,235 @@ async def check_name_availability( return deserialized # type: ignore + async def _promote_initial( + self, + resource_group_name: str, + mongo_cluster_name: str, + body: Union[_models.PromoteReplicaRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_mongo_clusters_promote_request( + resource_group_name=resource_group_name, + mongo_cluster_name=mongo_cluster_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_promote( + self, + resource_group_name: str, + mongo_cluster_name: str, + body: _models.PromoteReplicaRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Promotes a replica mongo cluster to a primary role. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mongo_cluster_name: The name of the mongo cluster. Required. + :type mongo_cluster_name: str + :param body: The content of the action request. Required. + :type body: ~azure.mgmt.mongocluster.models.PromoteReplicaRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "promoteOption": "str", + "mode": "str" + } + """ + + @overload + async def begin_promote( + self, + resource_group_name: str, + mongo_cluster_name: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Promotes a replica mongo cluster to a primary role. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mongo_cluster_name: The name of the mongo cluster. Required. + :type mongo_cluster_name: str + :param body: The content of the action request. Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_promote( + self, + resource_group_name: str, + mongo_cluster_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Promotes a replica mongo cluster to a primary role. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mongo_cluster_name: The name of the mongo cluster. Required. + :type mongo_cluster_name: str + :param body: The content of the action request. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_promote( + self, + resource_group_name: str, + mongo_cluster_name: str, + body: Union[_models.PromoteReplicaRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Promotes a replica mongo cluster to a primary role. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mongo_cluster_name: The name of the mongo cluster. Required. + :type mongo_cluster_name: str + :param body: The content of the action request. Is one of the following types: + PromoteReplicaRequest, JSON, IO[bytes] Required. + :type body: ~azure.mgmt.mongocluster.models.PromoteReplicaRequest or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "promoteOption": "str", + "mode": "str" + } + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._promote_initial( + resource_group_name=resource_group_name, + mongo_cluster_name=mongo_cluster_name, + body=body, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + class FirewallRulesOperations: """ @@ -2264,6 +2797,19 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "firewall_rule_name", + "accept", + ] + }, + ) async def get( self, resource_group_name: str, mongo_cluster_name: str, firewall_rule_name: str, **kwargs: Any ) -> _models.FirewallRule: @@ -2336,7 +2882,10 @@ async def get( if response.status_code not in [200]: if _stream: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -2351,6 +2900,19 @@ async def get( return deserialized # type: ignore + @api_version_validation( + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "firewall_rule_name", + "content_type", + "accept", + ] + }, + ) async def _create_or_update_initial( self, resource_group_name: str, @@ -2401,23 +2963,20 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.iter_bytes() - - if response.status_code == 201: - deserialized = response.iter_bytes() - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -2607,6 +3166,20 @@ async def begin_create_or_update( """ @distributed_trace_async + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "firewall_rule_name", + "content_type", + "accept", + ] + }, + ) async def begin_create_or_update( self, resource_group_name: str, @@ -2722,6 +3295,18 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + @api_version_validation( + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "firewall_rule_name", + "accept", + ] + }, + ) async def _delete_initial( self, resource_group_name: str, mongo_cluster_name: str, firewall_rule_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: @@ -2757,7 +3342,10 @@ async def _delete_initial( response = pipeline_response.http_response if response.status_code not in [202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -2767,10 +3355,7 @@ async def _delete_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() - - if response.status_code == 204: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -2778,6 +3363,19 @@ async def _delete_initial( return deserialized # type: ignore @distributed_trace_async + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "firewall_rule_name", + "accept", + ] + }, + ) async def begin_delete( self, resource_group_name: str, mongo_cluster_name: str, firewall_rule_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: @@ -2834,6 +3432,18 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "accept", + ] + }, + ) def list_by_mongo_cluster( self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any ) -> AsyncIterable["_models.FirewallRule"]: @@ -2958,6 +3568,18 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "accept", + ] + }, + ) def list_by_mongo_cluster( self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any ) -> AsyncIterable["_models.PrivateEndpointConnectionResource"]: @@ -3074,6 +3696,19 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "private_endpoint_connection_name", + "accept", + ] + }, + ) async def get( self, resource_group_name: str, mongo_cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnectionResource: @@ -3157,7 +3792,10 @@ async def get( if response.status_code not in [200]: if _stream: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -3172,6 +3810,19 @@ async def get( return deserialized # type: ignore + @api_version_validation( + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "private_endpoint_connection_name", + "content_type", + "accept", + ] + }, + ) async def _create_initial( self, resource_group_name: str, @@ -3222,23 +3873,20 @@ async def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.iter_bytes() - - if response.status_code == 201: - deserialized = response.iter_bytes() - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -3470,6 +4118,20 @@ async def begin_create( """ @distributed_trace_async + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "private_endpoint_connection_name", + "content_type", + "accept", + ] + }, + ) async def begin_create( self, resource_group_name: str, @@ -3610,6 +4272,18 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + @api_version_validation( + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "private_endpoint_connection_name", + "accept", + ] + }, + ) async def _delete_initial( self, resource_group_name: str, mongo_cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: @@ -3645,7 +4319,10 @@ async def _delete_initial( response = pipeline_response.http_response if response.status_code not in [202, 204]: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -3655,10 +4332,7 @@ async def _delete_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() - - if response.status_code == 204: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -3666,6 +4340,19 @@ async def _delete_initial( return deserialized # type: ignore @distributed_trace_async + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "private_endpoint_connection_name", + "accept", + ] + }, + ) async def begin_delete( self, resource_group_name: str, mongo_cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: @@ -3741,6 +4428,18 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "accept", + ] + }, + ) def list_by_mongo_cluster( self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any ) -> AsyncIterable["_models.PrivateLinkResource"]: @@ -3850,3 +4549,188 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) + + +class ReplicasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mongocluster.aio.MongoClusterMgmtClient`'s + :attr:`replicas` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + 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_parent( + self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Replica"]: + """List all the replicas for the mongo cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mongo_cluster_name: The name of the mongo cluster. Required. + :type mongo_cluster_name: str + :return: An iterator like instance of Replica + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mongocluster.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "id": "str", + "name": "str", + "properties": { + "administratorLogin": "str", + "administratorLoginPassword": "str", + "clusterStatus": "str", + "connectionString": "str", + "createMode": "str", + "earliestRestoreTime": "str", + "infrastructureVersion": "str", + "nodeGroupSpecs": [ + { + "diskSizeGB": 0, + "enableHa": bool, + "kind": "str", + "nodeCount": 0, + "sku": "str" + } + ], + "previewFeatures": [ + "str" + ], + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str" + }, + "groupIds": [ + "str" + ], + "privateEndpoint": { + "id": "str" + }, + "provisioningState": "str" + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str" + }, + "type": "str" + } + ], + "provisioningState": "str", + "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, + "restoreParameters": { + "pointInTimeUTC": "2020-02-20 00:00:00", + "sourceResourceId": "str" + }, + "serverVersion": "str" + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str" + }, + "type": "str" + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Replica]] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_replicas_list_by_parent_request( + resource_group_name=resource_group_name, + mongo_cluster_name=mongo_cluster_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Replica], deserialized["value"]) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/models/__init__.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/models/__init__.py index 6f92d5a6bc1cb..bfe59d7536138 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/models/__init__.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/models/__init__.py @@ -17,6 +17,7 @@ from ._models import ListConnectionStringsResult from ._models import MongoCluster from ._models import MongoClusterProperties +from ._models import MongoClusterReplicaParameters from ._models import MongoClusterRestoreParameters from ._models import MongoClusterUpdate from ._models import MongoClusterUpdateProperties @@ -30,7 +31,10 @@ from ._models import PrivateLinkResource from ._models import PrivateLinkResourceProperties from ._models import PrivateLinkServiceConnectionState +from ._models import PromoteReplicaRequest from ._models import ProxyResource +from ._models import Replica +from ._models import ReplicationProperties from ._models import Resource from ._models import SystemData from ._models import TrackedResource @@ -42,10 +46,15 @@ from ._enums import MongoClusterStatus from ._enums import NodeKind from ._enums import Origin +from ._enums import PreviewFeature from ._enums import PrivateEndpointConnectionProvisioningState from ._enums import PrivateEndpointServiceConnectionStatus +from ._enums import PromoteMode +from ._enums import PromoteOption from ._enums import ProvisioningState from ._enums import PublicNetworkAccess +from ._enums import ReplicationRole +from ._enums import ReplicationState from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk @@ -62,6 +71,7 @@ "ListConnectionStringsResult", "MongoCluster", "MongoClusterProperties", + "MongoClusterReplicaParameters", "MongoClusterRestoreParameters", "MongoClusterUpdate", "MongoClusterUpdateProperties", @@ -75,7 +85,10 @@ "PrivateLinkResource", "PrivateLinkResourceProperties", "PrivateLinkServiceConnectionState", + "PromoteReplicaRequest", "ProxyResource", + "Replica", + "ReplicationProperties", "Resource", "SystemData", "TrackedResource", @@ -86,10 +99,15 @@ "MongoClusterStatus", "NodeKind", "Origin", + "PreviewFeature", "PrivateEndpointConnectionProvisioningState", "PrivateEndpointServiceConnectionStatus", + "PromoteMode", + "PromoteOption", "ProvisioningState", "PublicNetworkAccess", + "ReplicationRole", + "ReplicationState", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/models/_enums.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/models/_enums.py index 15e43855453be..a621138cad6af 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/models/_enums.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/models/_enums.py @@ -48,6 +48,10 @@ class CreateMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Create a new mongo cluster.""" POINT_IN_TIME_RESTORE = "PointInTimeRestore" """Create a mongo cluster from a restore point-in-time.""" + GEO_REPLICA = "GeoReplica" + """Create a replica cluster in distinct geographic region from the source cluster.""" + REPLICA = "Replica" + """Create a replica cluster in the same geographic region as the source cluster.""" class MongoClusterStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -89,6 +93,14 @@ class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the operation is initiated by a user or system.""" +class PreviewFeature(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Preview features that can be enabled on a mongo cluster.""" + + GEO_REPLICAS = "GeoReplicas" + """Enables geo replicas preview feature. The feature must be set at create-time on new cluster to + enable linking a geo-replica cluster to it.""" + + class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state.""" @@ -113,6 +125,23 @@ class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiv """Connection Rejected""" +class PromoteMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The mode to apply to a promote operation.""" + + SWITCHOVER = "Switchover" + """Promotion will switch the current replica cluster to the primary role and the original primary + will be switched to a replica role, maintaining the replication link.""" + + +class PromoteOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The option to apply to a promote operation.""" + + FORCED = "Forced" + """Promote option forces the promotion without waiting for the replica to be caught up to the + primary. This can result in data-loss so should only be used during disaster recovery + scenarios.""" + + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state of the last accepted operation.""" @@ -139,3 +168,32 @@ class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """If set, mongo cluster can be accessed through private and public methods.""" DISABLED = "Disabled" """If set, the private endpoints are the exclusive access method.""" + + +class ReplicationRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Replication role of the mongo cluster.""" + + PRIMARY = "Primary" + """The cluster is a primary replica.""" + ASYNC_REPLICA = "AsyncReplica" + """The cluster is a local asynchronous replica.""" + GEO_ASYNC_REPLICA = "GeoAsyncReplica" + """The cluster is a geo-asynchronous replica.""" + + +class ReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of the replication link between the replica and source cluster.""" + + ACTIVE = "Active" + """Replication link is active.""" + CATCHUP = "Catchup" + """Replica is catching-up with the primary. This can occur after the replica is created or after a + promotion is triggered.""" + PROVISIONING = "Provisioning" + """Replica and replication link to the primary is being created.""" + UPDATING = "Updating" + """Replication link is being updated due to a change on the replica or an upgrade.""" + BROKEN = "Broken" + """Replication link is broken and the replica may need to be recreated.""" + RECONFIGURING = "Reconfiguring" + """Replication link is re-configuring due to a promotion event.""" diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/models/_models.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/models/_models.py index 980331a3f9c27..3a62ad807a5f2 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/models/_models.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/models/_models.py @@ -281,7 +281,6 @@ class FirewallRuleProperties(_model_base.Model): Readonly variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to server. :ivar provisioning_state: The provisioning state of the firewall rule. Known values are: "Succeeded", "Failed", "Canceled", "InProgress", "Updating", and "Dropping". @@ -344,7 +343,6 @@ class TrackedResource(Resource): Readonly variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long @@ -392,7 +390,6 @@ class MongoCluster(TrackedResource): Readonly variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long @@ -441,11 +438,13 @@ class MongoClusterProperties(_model_base.Model): # pylint: disable=too-many-ins Readonly variables are only populated by the server, and will be ignored when sending a request. - :ivar create_mode: The mode to create a mongo cluster. Known values are: "Default" and - "PointInTimeRestore". + :ivar create_mode: The mode to create a mongo cluster. Known values are: "Default", + "PointInTimeRestore", "GeoReplica", and "Replica". :vartype create_mode: str or ~azure.mgmt.mongocluster.models.CreateMode :ivar restore_parameters: The parameters to create a point-in-time restore mongo cluster. :vartype restore_parameters: ~azure.mgmt.mongocluster.models.MongoClusterRestoreParameters + :ivar replica_parameters: The parameters to create a replica mongo cluster. + :vartype replica_parameters: ~azure.mgmt.mongocluster.models.MongoClusterReplicaParameters :ivar administrator_login: The administrator's login for the mongo cluster. :vartype administrator_login: str :ivar administrator_login_password: The password of the administrator login. @@ -471,14 +470,25 @@ class MongoClusterProperties(_model_base.Model): # pylint: disable=too-many-ins :ivar private_endpoint_connections: List of private endpoint connections. :vartype private_endpoint_connections: list[~azure.mgmt.mongocluster.models.PrivateEndpointConnection] + :ivar preview_features: List of private endpoint connections. + :vartype preview_features: list[str or ~azure.mgmt.mongocluster.models.PreviewFeature] + :ivar replica: The replication properties for the mongo cluster. + :vartype replica: ~azure.mgmt.mongocluster.models.ReplicationProperties + :ivar infrastructure_version: The infrastructure version the cluster is provisioned on. + :vartype infrastructure_version: str """ create_mode: Optional[Union[str, "_models.CreateMode"]] = rest_field(name="createMode", visibility=["create"]) - """The mode to create a mongo cluster. Known values are: \"Default\" and \"PointInTimeRestore\".""" + """The mode to create a mongo cluster. Known values are: \"Default\", \"PointInTimeRestore\", + \"GeoReplica\", and \"Replica\".""" restore_parameters: Optional["_models.MongoClusterRestoreParameters"] = rest_field( name="restoreParameters", visibility=["create"] ) """The parameters to create a point-in-time restore mongo cluster.""" + replica_parameters: Optional["_models.MongoClusterReplicaParameters"] = rest_field( + name="replicaParameters", visibility=["create"] + ) + """The parameters to create a replica mongo cluster.""" administrator_login: Optional[str] = rest_field(name="administratorLogin", visibility=["read", "create", "update"]) """The administrator's login for the mongo cluster.""" administrator_login_password: Optional[str] = rest_field( @@ -510,6 +520,12 @@ class MongoClusterProperties(_model_base.Model): # pylint: disable=too-many-ins name="privateEndpointConnections", visibility=["read"] ) """List of private endpoint connections.""" + preview_features: Optional[List[Union[str, "_models.PreviewFeature"]]] = rest_field(name="previewFeatures") + """List of private endpoint connections.""" + replica: Optional["_models.ReplicationProperties"] = rest_field(visibility=["read"]) + """The replication properties for the mongo cluster.""" + infrastructure_version: Optional[str] = rest_field(name="infrastructureVersion", visibility=["read"]) + """The infrastructure version the cluster is provisioned on.""" @overload def __init__( @@ -517,11 +533,47 @@ def __init__( *, create_mode: Optional[Union[str, "_models.CreateMode"]] = None, restore_parameters: Optional["_models.MongoClusterRestoreParameters"] = None, + replica_parameters: Optional["_models.MongoClusterReplicaParameters"] = None, administrator_login: Optional[str] = None, administrator_login_password: Optional[str] = None, server_version: Optional[str] = None, public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, node_group_specs: Optional[List["_models.NodeGroupSpec"]] = None, + preview_features: Optional[List[Union[str, "_models.PreviewFeature"]]] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class MongoClusterReplicaParameters(_model_base.Model): + """Parameters used for replica operations. + + + :ivar source_resource_id: The id of the replication source cluster. Required. + :vartype source_resource_id: str + :ivar source_location: The location of the source cluster. Required. + :vartype source_location: str + """ + + source_resource_id: str = rest_field(name="sourceResourceId") + """The id of the replication source cluster. Required.""" + source_location: str = rest_field(name="sourceLocation") + """The location of the source cluster. Required.""" + + @overload + def __init__( + self, + *, + source_resource_id: str, + source_location: str, ): ... @overload @@ -573,13 +625,14 @@ class MongoClusterUpdate(_model_base.Model): :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar properties: + :ivar properties: The resource-specific properties for this resource. :vartype properties: ~azure.mgmt.mongocluster.models.MongoClusterUpdateProperties """ tags: Optional[Dict[str, str]] = rest_field() """Resource tags.""" properties: Optional["_models.MongoClusterUpdateProperties"] = rest_field() + """The resource-specific properties for this resource.""" @overload def __init__( @@ -615,6 +668,8 @@ class MongoClusterUpdateProperties(_model_base.Model): :vartype public_network_access: str or ~azure.mgmt.mongocluster.models.PublicNetworkAccess :ivar node_group_specs: The list of node group specs in the cluster. :vartype node_group_specs: list[~azure.mgmt.mongocluster.models.NodeGroupSpec] + :ivar preview_features: List of private endpoint connections. + :vartype preview_features: list[str or ~azure.mgmt.mongocluster.models.PreviewFeature] """ administrator_login: Optional[str] = rest_field(name="administratorLogin", visibility=["read", "create", "update"]) @@ -630,6 +685,8 @@ class MongoClusterUpdateProperties(_model_base.Model): \"Enabled\" and \"Disabled\".""" node_group_specs: Optional[List["_models.NodeGroupSpec"]] = rest_field(name="nodeGroupSpecs") """The list of node group specs in the cluster.""" + preview_features: Optional[List[Union[str, "_models.PreviewFeature"]]] = rest_field(name="previewFeatures") + """List of private endpoint connections.""" @overload def __init__( @@ -640,6 +697,7 @@ def __init__( server_version: Optional[str] = None, public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, node_group_specs: Optional[List["_models.NodeGroupSpec"]] = None, + preview_features: Optional[List[Union[str, "_models.PreviewFeature"]]] = None, ): ... @overload @@ -733,7 +791,7 @@ class Operation(_model_base.Model): is_data_action: Optional[bool] = rest_field(name="isDataAction", visibility=["read"]) """Whether the operation applies to data-plane. This is \"true\" for data-plane operations and \"false\" for Azure Resource Manager/control-plane operations.""" - display: Optional["_models.OperationDisplay"] = rest_field() + display: Optional["_models.OperationDisplay"] = rest_field(visibility=["read"]) """Localized display information for this particular operation.""" origin: Optional[Union[str, "_models.Origin"]] = rest_field(visibility=["read"]) """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit @@ -747,7 +805,6 @@ class Operation(_model_base.Model): def __init__( self, *, - display: Optional["_models.OperationDisplay"] = None, action_type: Optional[Union[str, "_models.ActionType"]] = None, ): ... @@ -765,6 +822,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles class OperationDisplay(_model_base.Model): """Localized display information for and operation. + Readonly variables are only populated by the server, and will be ignored when sending a request. + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". :vartype provider: str @@ -779,39 +838,19 @@ class OperationDisplay(_model_base.Model): :vartype description: str """ - provider: Optional[str] = rest_field() + provider: Optional[str] = rest_field(visibility=["read"]) """The localized friendly form of the resource provider name, e.g. \"Microsoft Monitoring Insights\" or \"Microsoft Compute\".""" - resource: Optional[str] = rest_field() + resource: Optional[str] = rest_field(visibility=["read"]) """The localized friendly name of the resource type related to this operation. E.g. \"Virtual Machines\" or \"Job Schedule Collections\".""" - operation: Optional[str] = rest_field() + operation: Optional[str] = rest_field(visibility=["read"]) """The concise, localized friendly name for the operation; suitable for dropdowns. E.g. \"Create or Update Virtual Machine\", \"Restart Virtual Machine\".""" - description: Optional[str] = rest_field() + description: Optional[str] = rest_field(visibility=["read"]) """The short, localized friendly description of the operation; suitable for tool tips and detailed views.""" - @overload - def __init__( - self, - *, - provider: Optional[str] = None, - resource: Optional[str] = None, - operation: Optional[str] = None, - description: Optional[str] = None, - ): ... - - @overload - def __init__(self, mapping: Mapping[str, Any]): - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation - super().__init__(*args, **kwargs) - class PrivateEndpoint(_model_base.Model): """The Private Endpoint resource. @@ -872,7 +911,6 @@ class PrivateEndpointConnectionProperties(_model_base.Model): Readonly variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to server. :ivar group_ids: The group ids for the private endpoint resource. :vartype group_ids: list[str] @@ -1086,6 +1124,111 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles super().__init__(*args, **kwargs) +class PromoteReplicaRequest(_model_base.Model): + """Promote replica request properties. + + All required parameters must be populated in order to send to server. + + :ivar promote_option: The promote option to apply to the operation. Required. "Forced" + :vartype promote_option: str or ~azure.mgmt.mongocluster.models.PromoteOption + :ivar mode: The mode to apply to the promote operation. Value is optional and default value is + 'Switchover'. "Switchover" + :vartype mode: str or ~azure.mgmt.mongocluster.models.PromoteMode + """ + + promote_option: Union[str, "_models.PromoteOption"] = rest_field(name="promoteOption") + """The promote option to apply to the operation. Required. \"Forced\"""" + mode: Optional[Union[str, "_models.PromoteMode"]] = rest_field() + """The mode to apply to the promote operation. Value is optional and default value is + 'Switchover'. \"Switchover\"""" + + @overload + def __init__( + self, + *, + promote_option: Union[str, "_models.PromoteOption"], + mode: Optional[Union[str, "_models.PromoteMode"]] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class Replica(ProxyResource): + """Represents a mongo cluster replica. + + Readonly variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.mongocluster.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.mongocluster.models.MongoClusterProperties + """ + + properties: Optional["_models.MongoClusterProperties"] = rest_field() + """The resource-specific properties for this resource.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.MongoClusterProperties"] = None, + ): ... + + @overload + def __init__(self, mapping: Mapping[str, Any]): + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation + super().__init__(*args, **kwargs) + + +class ReplicationProperties(_model_base.Model): + """Replica properties of the mongo cluster. + + Readonly variables are only populated by the server, and will be ignored when sending a request. + + :ivar source_resource_id: The resource id the source cluster for the replica cluster. + :vartype source_resource_id: str + :ivar role: The replication role of the cluster. Known values are: "Primary", "AsyncReplica", + and "GeoAsyncReplica". + :vartype role: str or ~azure.mgmt.mongocluster.models.ReplicationRole + :ivar replication_state: The replication link state of the replica cluster. Known values are: + "Active", "Catchup", "Provisioning", "Updating", "Broken", and "Reconfiguring". + :vartype replication_state: str or ~azure.mgmt.mongocluster.models.ReplicationState + """ + + source_resource_id: Optional[str] = rest_field(name="sourceResourceId", visibility=["read"]) + """The resource id the source cluster for the replica cluster.""" + role: Optional[Union[str, "_models.ReplicationRole"]] = rest_field(visibility=["read"]) + """The replication role of the cluster. Known values are: \"Primary\", \"AsyncReplica\", and + \"GeoAsyncReplica\".""" + replication_state: Optional[Union[str, "_models.ReplicationState"]] = rest_field( + name="replicationState", visibility=["read"] + ) + """The replication link state of the replica cluster. Known values are: \"Active\", \"Catchup\", + \"Provisioning\", \"Updating\", \"Broken\", and \"Reconfiguring\".""" + + class SystemData(_model_base.Model): """Metadata pertaining to creation and last modification of the resource. diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/operations/__init__.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/operations/__init__.py index a1f89f68dd6eb..c2fa532ddd595 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/operations/__init__.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/operations/__init__.py @@ -11,6 +11,7 @@ from ._operations import FirewallRulesOperations from ._operations import PrivateEndpointConnectionsOperations from ._operations import PrivateLinksOperations +from ._operations import ReplicasOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -22,6 +23,7 @@ "FirewallRulesOperations", "PrivateEndpointConnectionsOperations", "PrivateLinksOperations", + "ReplicasOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/operations/_operations.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/operations/_operations.py index be7a1866c65c4..fe98030499e06 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/operations/_operations.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/operations/_operations.py @@ -18,6 +18,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -32,6 +34,7 @@ from .. import models as _models from .._model_base import SdkJSONEncoder, _deserialize from .._serialization import Serializer +from .._validation import api_version_validation if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -49,7 +52,7 @@ def build_operations_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +73,7 @@ def build_mongo_clusters_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,7 +102,7 @@ def build_mongo_clusters_create_or_update_request( # pylint: disable=name-too-l _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -130,7 +133,7 @@ def build_mongo_clusters_update_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -160,7 +163,7 @@ def build_mongo_clusters_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -188,7 +191,7 @@ def build_mongo_clusters_list_by_resource_group_request( # pylint: disable=name _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -213,7 +216,7 @@ def build_mongo_clusters_list_request(subscription_id: str, **kwargs: Any) -> Ht _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -239,7 +242,7 @@ def build_mongo_clusters_list_connection_strings_request( # pylint: disable=nam _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -268,7 +271,7 @@ def build_mongo_clusters_check_name_availability_request( # pylint: disable=nam _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -291,13 +294,44 @@ def build_mongo_clusters_check_name_availability_request( # pylint: disable=nam return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) +def build_mongo_clusters_promote_request( + resource_group_name: str, mongo_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/promote" # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "mongoClusterName": _SERIALIZER.url("mongo_cluster_name", mongo_cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + def build_firewall_rules_get_request( resource_group_name: str, mongo_cluster_name: str, firewall_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -327,7 +361,7 @@ def build_firewall_rules_create_or_update_request( # pylint: disable=name-too-l _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -358,7 +392,7 @@ def build_firewall_rules_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -387,7 +421,7 @@ def build_firewall_rules_list_by_mongo_cluster_request( # pylint: disable=name- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -415,7 +449,7 @@ def build_private_endpoint_connections_list_by_mongo_cluster_request( # pylint: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -447,7 +481,7 @@ def build_private_endpoint_connections_get_request( # pylint: disable=name-too- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -483,7 +517,7 @@ def build_private_endpoint_connections_create_request( # pylint: disable=name-t _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -520,7 +554,7 @@ def build_private_endpoint_connections_delete_request( # pylint: disable=name-t _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -551,7 +585,7 @@ def build_private_links_list_by_mongo_cluster_request( # pylint: disable=name-t _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-03-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -573,6 +607,34 @@ def build_private_links_list_by_mongo_cluster_request( # pylint: disable=name-t return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) +def build_replicas_list_by_parent_request( + resource_group_name: str, mongo_cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/replicas" # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "mongoClusterName": _SERIALIZER.url("mongo_cluster_name", mongo_cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + class Operations: """ .. warning:: @@ -591,6 +653,10 @@ def __init__(self, *args, **kwargs): self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={"2024-03-01-preview": ["api_version", "accept"]}, + ) def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """List the operations for the provider. @@ -699,6 +765,18 @@ def __init__(self, *args, **kwargs): self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "accept", + ] + }, + ) def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any) -> _models.MongoCluster: """Gets information about a mongo cluster. @@ -726,6 +804,7 @@ def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any) "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -735,6 +814,9 @@ def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any) "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -766,6 +848,15 @@ def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any) ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -818,7 +909,10 @@ def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any) if response.status_code not in [200]: if _stream: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -833,6 +927,18 @@ def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any) return deserialized # type: ignore + @api_version_validation( + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "content_type", + "accept", + ] + }, + ) def _create_or_update_initial( self, resource_group_name: str, @@ -881,19 +987,19 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.iter_bytes() - if response.status_code == 201: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -943,6 +1049,7 @@ def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -952,6 +1059,9 @@ def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -983,6 +1093,15 @@ def begin_create_or_update( ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -1015,6 +1134,7 @@ def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1024,6 +1144,9 @@ def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1055,6 +1178,15 @@ def begin_create_or_update( ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -1119,6 +1251,7 @@ def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1128,6 +1261,9 @@ def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1159,6 +1295,15 @@ def begin_create_or_update( ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -1223,6 +1368,7 @@ def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1232,6 +1378,9 @@ def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1263,6 +1412,15 @@ def begin_create_or_update( ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -1285,6 +1443,19 @@ def begin_create_or_update( """ @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "content_type", + "accept", + ] + }, + ) def begin_create_or_update( self, resource_group_name: str, @@ -1323,6 +1494,7 @@ def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1332,6 +1504,9 @@ def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1363,6 +1538,15 @@ def begin_create_or_update( ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -1395,6 +1579,7 @@ def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1404,6 +1589,9 @@ def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1435,6 +1623,15 @@ def begin_create_or_update( ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -1501,6 +1698,18 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + @api_version_validation( + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "content_type", + "accept", + ] + }, + ) def _update_initial( self, resource_group_name: str, @@ -1549,20 +1758,20 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.iter_bytes() - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1614,6 +1823,9 @@ def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "publicNetworkAccess": "str", "serverVersion": "str" }, @@ -1634,6 +1846,7 @@ def begin_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1643,6 +1856,9 @@ def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1674,6 +1890,15 @@ def begin_update( ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -1738,6 +1963,7 @@ def begin_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1747,6 +1973,9 @@ def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1778,6 +2007,15 @@ def begin_update( ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -1842,6 +2080,7 @@ def begin_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1851,6 +2090,9 @@ def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1882,6 +2124,15 @@ def begin_update( ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -1904,6 +2155,19 @@ def begin_update( """ @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "content_type", + "accept", + ] + }, + ) def begin_update( self, resource_group_name: str, @@ -1944,6 +2208,9 @@ def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "publicNetworkAccess": "str", "serverVersion": "str" }, @@ -1964,6 +2231,7 @@ def begin_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1973,6 +2241,9 @@ def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -2004,6 +2275,15 @@ def begin_update( ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -2070,6 +2350,17 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + @api_version_validation( + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "accept", + ] + }, + ) def _delete_initial(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, @@ -2102,7 +2393,10 @@ def _delete_initial(self, resource_group_name: str, mongo_cluster_name: str, **k response = pipeline_response.http_response if response.status_code not in [202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -2112,10 +2406,7 @@ def _delete_initial(self, resource_group_name: str, mongo_cluster_name: str, **k response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() - - if response.status_code == 204: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -2123,6 +2414,18 @@ def _delete_initial(self, resource_group_name: str, mongo_cluster_name: str, **k return deserialized # type: ignore @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "accept", + ] + }, + ) def begin_delete(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a mongo cluster. @@ -2174,6 +2477,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={"2024-03-01-preview": ["api_version", "subscription_id", "resource_group_name", "accept"]}, + ) def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.MongoCluster"]: """List all the mongo clusters in a given resource group. @@ -2199,6 +2506,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -2208,6 +2516,9 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -2239,6 +2550,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -2327,6 +2647,10 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={"2024-03-01-preview": ["api_version", "subscription_id", "accept"]}, + ) def list(self, **kwargs: Any) -> Iterable["_models.MongoCluster"]: """List all the mongo clusters in a given subscription. @@ -2349,6 +2673,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.MongoCluster"]: "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -2358,6 +2683,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.MongoCluster"]: "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -2389,6 +2717,15 @@ def list(self, **kwargs: Any) -> Iterable["_models.MongoCluster"]: ], "provisioningState": "str", "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, "restoreParameters": { "pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str" @@ -2476,6 +2813,18 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "accept", + ] + }, + ) def list_connection_strings( self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any ) -> _models.ListConnectionStringsResult: @@ -2537,7 +2886,10 @@ def list_connection_strings( if response.status_code not in [200]: if _stream: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -2651,6 +3003,12 @@ def check_name_availability( """ @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": ["api_version", "subscription_id", "location", "content_type", "accept"] + }, + ) def check_name_availability( self, location: str, body: Union[_models.CheckNameAvailabilityRequest, JSON, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResponse: @@ -2723,7 +3081,10 @@ def check_name_availability( if response.status_code not in [200]: if _stream: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -2738,64 +3099,13 @@ def check_name_availability( return deserialized # type: ignore - -class FirewallRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.mongocluster.MongoClusterMgmtClient`'s - :attr:`firewall_rules` attribute. - """ - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - 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, mongo_cluster_name: str, firewall_rule_name: str, **kwargs: Any - ) -> _models.FirewallRule: - """Gets information about a mongo cluster firewall rule. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param mongo_cluster_name: The name of the mongo cluster. Required. - :type mongo_cluster_name: str - :param firewall_rule_name: The name of the mongo cluster firewall rule. Required. - :type firewall_rule_name: str - :return: FirewallRule. The FirewallRule is compatible with MutableMapping - :rtype: ~azure.mgmt.mongocluster.models.FirewallRule - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "id": "str", - "name": "str", - "properties": { - "endIpAddress": "str", - "startIpAddress": "str", - "provisioningState": "str" - }, - "systemData": { - "createdAt": "2020-02-20 00:00:00", - "createdBy": "str", - "createdByType": "str", - "lastModifiedAt": "2020-02-20 00:00:00", - "lastModifiedBy": "str", - "lastModifiedByType": "str" - }, - "type": "str" - } - """ + def _promote_initial( + self, + resource_group_name: str, + mongo_cluster_name: str, + body: Union[_models.PromoteReplicaRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2804,61 +3114,370 @@ def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_firewall_rules_get_request( + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_mongo_clusters_promote_request( resource_group_name=resource_group_name, mongo_cluster_name=mongo_cluster_name, - firewall_rule_name=firewall_rule_name, subscription_id=self._config.subscription_id, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) - _stream = kwargs.pop("stream", False) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: + if response.status_code not in [202]: + try: response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.FirewallRule, response.json()) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - def _create_or_update_initial( + @overload + def begin_promote( self, resource_group_name: str, mongo_cluster_name: str, - firewall_rule_name: str, - resource: Union[_models.FirewallRule, JSON, IO[bytes]], + body: _models.PromoteReplicaRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + ) -> LROPoller[None]: + """Promotes a replica mongo cluster to a primary role. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mongo_cluster_name: The name of the mongo cluster. Required. + :type mongo_cluster_name: str + :param body: The content of the action request. Required. + :type body: ~azure.mgmt.mongocluster.models.PromoteReplicaRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "promoteOption": "str", + "mode": "str" + } + """ + + @overload + def begin_promote( + self, + resource_group_name: str, + mongo_cluster_name: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Promotes a replica mongo cluster to a primary role. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mongo_cluster_name: The name of the mongo cluster. Required. + :type mongo_cluster_name: str + :param body: The content of the action request. Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_promote( + self, + resource_group_name: str, + mongo_cluster_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Promotes a replica mongo cluster to a primary role. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mongo_cluster_name: The name of the mongo cluster. Required. + :type mongo_cluster_name: str + :param body: The content of the action request. Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_promote( + self, + resource_group_name: str, + mongo_cluster_name: str, + body: Union[_models.PromoteReplicaRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Promotes a replica mongo cluster to a primary role. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mongo_cluster_name: The name of the mongo cluster. Required. + :type mongo_cluster_name: str + :param body: The content of the action request. Is one of the following types: + PromoteReplicaRequest, JSON, IO[bytes] Required. + :type body: ~azure.mgmt.mongocluster.models.PromoteReplicaRequest or JSON or IO[bytes] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "promoteOption": "str", + "mode": "str" + } + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._promote_initial( + resource_group_name=resource_group_name, + mongo_cluster_name=mongo_cluster_name, + body=body, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class FirewallRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mongocluster.MongoClusterMgmtClient`'s + :attr:`firewall_rules` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + 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 + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "firewall_rule_name", + "accept", + ] + }, + ) + def get( + self, resource_group_name: str, mongo_cluster_name: str, firewall_rule_name: str, **kwargs: Any + ) -> _models.FirewallRule: + """Gets information about a mongo cluster firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mongo_cluster_name: The name of the mongo cluster. Required. + :type mongo_cluster_name: str + :param firewall_rule_name: The name of the mongo cluster firewall rule. Required. + :type firewall_rule_name: str + :return: FirewallRule. The FirewallRule is compatible with MutableMapping + :rtype: ~azure.mgmt.mongocluster.models.FirewallRule + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "id": "str", + "name": "str", + "properties": { + "endIpAddress": "str", + "startIpAddress": "str", + "provisioningState": "str" + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str" + }, + "type": "str" + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) + + _request = build_firewall_rules_get_request( + resource_group_name=resource_group_name, + mongo_cluster_name=mongo_cluster_name, + firewall_rule_name=firewall_rule_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.FirewallRule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @api_version_validation( + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "firewall_rule_name", + "content_type", + "accept", + ] + }, + ) + def _create_or_update_initial( + self, + resource_group_name: str, + mongo_cluster_name: str, + firewall_rule_name: str, + resource: Union[_models.FirewallRule, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} @@ -2894,23 +3513,20 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.iter_bytes() - - if response.status_code == 201: - deserialized = response.iter_bytes() - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -3100,6 +3716,20 @@ def begin_create_or_update( """ @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "firewall_rule_name", + "content_type", + "accept", + ] + }, + ) def begin_create_or_update( self, resource_group_name: str, @@ -3215,6 +3845,18 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + @api_version_validation( + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "firewall_rule_name", + "accept", + ] + }, + ) def _delete_initial( self, resource_group_name: str, mongo_cluster_name: str, firewall_rule_name: str, **kwargs: Any ) -> Iterator[bytes]: @@ -3250,7 +3892,10 @@ def _delete_initial( response = pipeline_response.http_response if response.status_code not in [202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -3260,10 +3905,7 @@ def _delete_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() - - if response.status_code == 204: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -3271,6 +3913,19 @@ def _delete_initial( return deserialized # type: ignore @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "firewall_rule_name", + "accept", + ] + }, + ) def begin_delete( self, resource_group_name: str, mongo_cluster_name: str, firewall_rule_name: str, **kwargs: Any ) -> LROPoller[None]: @@ -3327,6 +3982,18 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "accept", + ] + }, + ) def list_by_mongo_cluster( self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any ) -> Iterable["_models.FirewallRule"]: @@ -3451,6 +4118,18 @@ def __init__(self, *args, **kwargs): self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "accept", + ] + }, + ) def list_by_mongo_cluster( self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any ) -> Iterable["_models.PrivateEndpointConnectionResource"]: @@ -3567,6 +4246,19 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "private_endpoint_connection_name", + "accept", + ] + }, + ) def get( self, resource_group_name: str, mongo_cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnectionResource: @@ -3650,7 +4342,10 @@ def get( if response.status_code not in [200]: if _stream: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -3665,6 +4360,19 @@ def get( return deserialized # type: ignore + @api_version_validation( + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "private_endpoint_connection_name", + "content_type", + "accept", + ] + }, + ) def _create_initial( self, resource_group_name: str, @@ -3715,23 +4423,20 @@ def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = response.iter_bytes() - - if response.status_code == 201: - deserialized = response.iter_bytes() - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -3963,6 +4668,20 @@ def begin_create( """ @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "private_endpoint_connection_name", + "content_type", + "accept", + ] + }, + ) def begin_create( self, resource_group_name: str, @@ -4103,6 +4822,18 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) + @api_version_validation( + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "private_endpoint_connection_name", + "accept", + ] + }, + ) def _delete_initial( self, resource_group_name: str, mongo_cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> Iterator[bytes]: @@ -4138,7 +4869,10 @@ def _delete_initial( response = pipeline_response.http_response if response.status_code not in [202, 204]: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -4148,10 +4882,7 @@ def _delete_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() - - if response.status_code == 204: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -4159,6 +4890,19 @@ def _delete_initial( return deserialized # type: ignore @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "private_endpoint_connection_name", + "accept", + ] + }, + ) def begin_delete( self, resource_group_name: str, mongo_cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> LROPoller[None]: @@ -4234,6 +4978,18 @@ def __init__(self, *args, **kwargs): self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace + @api_version_validation( + method_added_on="2024-03-01-preview", + params_added_on={ + "2024-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "accept", + ] + }, + ) def list_by_mongo_cluster( self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any ) -> Iterable["_models.PrivateLinkResource"]: @@ -4342,3 +5098,188 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) + + +class ReplicasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mongocluster.MongoClusterMgmtClient`'s + :attr:`replicas` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + 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_parent( + self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any + ) -> Iterable["_models.Replica"]: + """List all the replicas for the mongo cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param mongo_cluster_name: The name of the mongo cluster. Required. + :type mongo_cluster_name: str + :return: An iterator like instance of Replica + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mongocluster.models.Replica] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "id": "str", + "name": "str", + "properties": { + "administratorLogin": "str", + "administratorLoginPassword": "str", + "clusterStatus": "str", + "connectionString": "str", + "createMode": "str", + "earliestRestoreTime": "str", + "infrastructureVersion": "str", + "nodeGroupSpecs": [ + { + "diskSizeGB": 0, + "enableHa": bool, + "kind": "str", + "nodeCount": 0, + "sku": "str" + } + ], + "previewFeatures": [ + "str" + ], + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str" + }, + "groupIds": [ + "str" + ], + "privateEndpoint": { + "id": "str" + }, + "provisioningState": "str" + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str" + }, + "type": "str" + } + ], + "provisioningState": "str", + "publicNetworkAccess": "str", + "replica": { + "replicationState": "str", + "role": "str", + "sourceResourceId": "str" + }, + "replicaParameters": { + "sourceLocation": "str", + "sourceResourceId": "str" + }, + "restoreParameters": { + "pointInTimeUTC": "2020-02-20 00:00:00", + "sourceResourceId": "str" + }, + "serverVersion": "str" + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str" + }, + "type": "str" + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Replica]] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_replicas_list_by_parent_request( + resource_group_name=resource_group_name, + mongo_cluster_name=mongo_cluster_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.Replica], deserialized["value"]) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/setup.py b/sdk/mongocluster/azure-mgmt-mongocluster/setup.py index 169c4bb604a34..31ba7938cc561 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/setup.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/setup.py @@ -75,6 +75,7 @@ }, install_requires=[ "isodate>=0.6.1", + "typing-extensions>=4.6.0", "azure-common>=1.1", "azure-mgmt-core>=1.3.2", ], diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/tests/conftest.py b/sdk/mongocluster/azure-mgmt-mongocluster/tests/conftest.py index 587e126e50b08..85d1adc3301cc 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/tests/conftest.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/tests/conftest.py @@ -35,6 +35,7 @@ load_dotenv() + @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") @@ -47,4 +48,4 @@ def add_sanitizers(test_proxy): add_general_regex_sanitizer(regex=client_secret, value="00000000-0000-0000-0000-000000000000") add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") add_header_regex_sanitizer(key="Cookie", value="cookie;") - add_body_key_sanitizer(json_path="$..access_token", value="access_token") \ No newline at end of file + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/tests/test_cli_mgmt_mongocluster.py b/sdk/mongocluster/azure-mgmt-mongocluster/tests/test_cli_mgmt_mongocluster.py index 21d73582f9d1d..4ba91b6fcf31d 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/tests/test_cli_mgmt_mongocluster.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/tests/test_cli_mgmt_mongocluster.py @@ -1,15 +1,16 @@ # coding: utf-8 -#------------------------------------------------------------------------- +# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. -#-------------------------------------------------------------------------- +# -------------------------------------------------------------------------- from azure.mgmt.mongocluster import MongoClusterMgmtClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy -AZURE_LOCATION = 'eastus' +AZURE_LOCATION = "eastus" + class TestMgmtMongoCluster(AzureMgmtRecordedTestCase): @@ -23,4 +24,4 @@ def test_list_by_resource_group(self, resource_group): @recorded_by_proxy def test_list_operations(self): - assert list(self.client.operations.list()) \ No newline at end of file + assert list(self.client.operations.list()) diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/tests/test_cli_mgmt_mongocluster_lro.py b/sdk/mongocluster/azure-mgmt-mongocluster/tests/test_cli_mgmt_mongocluster_lro.py index 7aab5b1c897d3..e6c43441dac27 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/tests/test_cli_mgmt_mongocluster_lro.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/tests/test_cli_mgmt_mongocluster_lro.py @@ -1,9 +1,10 @@ from azure.mgmt.mongocluster import MongoClusterMgmtClient from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy -AZURE_LOCATION = 'westus2' +AZURE_LOCATION = "westus2" Mongo_Cluster_Name = "pythontestmongocluster" + class TestMgmtMongoCluster(AzureMgmtRecordedTestCase): def setup_method(self, method): @@ -13,64 +14,52 @@ def setup_method(self, method): @recorded_by_proxy def test_mongo_clusters_mgmt(self, resource_group): response = self.client.mongo_clusters.begin_create_or_update( - resource_group_name = resource_group.name, - mongo_cluster_name = Mongo_Cluster_Name, - resource = { + resource_group_name=resource_group.name, + mongo_cluster_name=Mongo_Cluster_Name, + resource={ "location": AZURE_LOCATION, "properties": { "administratorLogin": "myMongoCluster", "administratorLoginPassword": "myMongoCluster333", "serverVersion": "5.0", "nodeGroupSpecs": [ - { - "diskSizeGB": 128, - "enableHa": True, - "kind": "Shard", - "nodeCount": 1, - "sku": "M30" - } + {"diskSizeGB": 128, "enableHa": True, "kind": "Shard", "nodeCount": 1, "sku": "M30"} ], }, - } + }, ).result() assert response response = self.client.mongo_clusters.begin_update( - resource_group_name = resource_group.name, - mongo_cluster_name = Mongo_Cluster_Name, - properties = { + resource_group_name=resource_group.name, + mongo_cluster_name=Mongo_Cluster_Name, + properties={ "location": AZURE_LOCATION, "properties": { "administratorLogin": "myMongoCluster", "administratorLoginPassword": "myMongoCluster333", "serverVersion": "5.0", "nodeGroupSpecs": [ - { - "kind": "Shard", - "sku": "M50", - "diskSizeGB": 256, - "enableHa": True, - "nodeCount": 1 - } + {"kind": "Shard", "sku": "M50", "diskSizeGB": 256, "enableHa": True, "nodeCount": 1} ], - "publicNetworkAccess": "Enabled" + "publicNetworkAccess": "Enabled", }, - } + }, ).result() assert response response = self.client.mongo_clusters.get( - resource_group_name = resource_group.name, - mongo_cluster_name = Mongo_Cluster_Name, + resource_group_name=resource_group.name, + mongo_cluster_name=Mongo_Cluster_Name, ) assert response response = self.client.mongo_clusters.list_by_resource_group( - resource_group_name = resource_group.name, + resource_group_name=resource_group.name, ) assert len(list(response)) == 1 response = self.client.mongo_clusters.begin_delete( - resource_group_name = resource_group.name, - mongo_cluster_name = Mongo_Cluster_Name, + resource_group_name=resource_group.name, + mongo_cluster_name=Mongo_Cluster_Name, ).result() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/tsp-location.yaml b/sdk/mongocluster/azure-mgmt-mongocluster/tsp-location.yaml index 64bcd552ca418..ecca5887448fd 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/tsp-location.yaml +++ b/sdk/mongocluster/azure-mgmt-mongocluster/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/mongocluster/DocumentDB.MongoCluster.Management -commit: abad0096677005817d2c19df2364663e5583c8fc +commit: 0e07b94c054259e5864acc855eb3977fb6dee368 repo: Azure/azure-rest-api-specs -additionalDirectories: +additionalDirectories: \ No newline at end of file