diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/_meta.json b/sdk/mongocluster/azure-mgmt-mongocluster/_meta.json index ac8e83a0a5854..73d6ec4757a79 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/_meta.json +++ b/sdk/mongocluster/azure-mgmt-mongocluster/_meta.json @@ -1,7 +1,6 @@ { - "commit": "abad0096677005817d2c19df2364663e5583c8fc", + "commit": "b44b6019c2086d2e89d2d39a42c6d3389e40d903", "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.25.0" } \ 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/_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..6c1f406cd427c 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 @@ -46,6 +46,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 +59,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 +67,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_mongo_cluster_request, ) if sys.version_info >= (3, 9): @@ -94,6 +97,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 +209,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 +248,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 +258,9 @@ async def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -269,6 +292,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" @@ -336,6 +368,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, @@ -446,6 +490,7 @@ async def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -455,6 +500,9 @@ async def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -486,6 +534,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 +575,7 @@ async def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -527,6 +585,9 @@ async def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -558,6 +619,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 +692,7 @@ async def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -631,6 +702,9 @@ async def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -662,6 +736,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 +809,7 @@ async def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -735,6 +819,9 @@ async def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -766,6 +853,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 +884,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 +935,7 @@ async def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -835,6 +945,9 @@ async def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -866,6 +979,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 +1020,7 @@ async def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -907,6 +1030,9 @@ async def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -938,6 +1064,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 +1139,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, @@ -1117,6 +1264,9 @@ async def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "publicNetworkAccess": "str", "serverVersion": "str" }, @@ -1137,6 +1287,7 @@ async def begin_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1146,6 +1297,9 @@ async def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1177,6 +1331,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 +1404,7 @@ async def begin_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1250,6 +1414,9 @@ async def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1281,6 +1448,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 +1521,7 @@ async def begin_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1354,6 +1531,9 @@ async def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1385,6 +1565,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 +1596,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 +1649,9 @@ async def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "publicNetworkAccess": "str", "serverVersion": "str" }, @@ -1467,6 +1672,7 @@ async def begin_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1476,6 +1682,9 @@ async def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1507,6 +1716,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 +1791,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]: @@ -1628,6 +1857,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 +1922,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 +1951,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 +1961,9 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1746,6 +1995,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 +2092,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 +2118,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.MongoCluster"]: "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1865,6 +2128,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.MongoCluster"]: "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1896,6 +2162,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 +2258,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: @@ -2158,6 +2445,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: @@ -2245,6 +2538,232 @@ 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]: + await response.read() # Load the body in memory and close the socket + 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 +2783,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: @@ -2351,6 +2883,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, @@ -2607,6 +3152,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 +3281,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]: @@ -2778,6 +3349,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 +3418,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 +3554,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 +3682,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: @@ -3172,6 +3793,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, @@ -3470,6 +4104,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 +4258,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]: @@ -3666,6 +4326,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 +4414,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 +4535,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_mongo_cluster( + 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_mongo_cluster_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..0bdd142e3145f 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 @@ -441,11 +441,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 +473,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 +523,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 +536,48 @@ 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. + + All required parameters must be populated in order to send to server. + + :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 @@ -615,6 +671,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 +688,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 +700,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 @@ -1086,6 +1147,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..b61486cf01fbb 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 @@ -32,6 +32,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 +50,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 +71,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 +100,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 +131,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 +161,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 +189,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 +214,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 +240,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 +269,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 +292,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 +359,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 +390,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 +419,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 +447,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 +479,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 +515,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 +552,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 +583,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 +605,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_mongo_cluster_request( # pylint: disable=name-too-long + 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 +651,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 +763,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 +802,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 +812,9 @@ def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any) "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -766,6 +846,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" @@ -833,6 +922,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, @@ -943,6 +1044,7 @@ def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -952,6 +1054,9 @@ def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -983,6 +1088,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 +1129,7 @@ def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1024,6 +1139,9 @@ def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1055,6 +1173,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 +1246,7 @@ def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1128,6 +1256,9 @@ def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1159,6 +1290,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 +1363,7 @@ def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1232,6 +1373,9 @@ def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1263,6 +1407,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 +1438,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 +1489,7 @@ def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1332,6 +1499,9 @@ def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1363,6 +1533,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 +1574,7 @@ def begin_create_or_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1404,6 +1584,9 @@ def begin_create_or_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1435,6 +1618,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 +1693,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, @@ -1614,6 +1818,9 @@ def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "publicNetworkAccess": "str", "serverVersion": "str" }, @@ -1634,6 +1841,7 @@ def begin_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1643,6 +1851,9 @@ def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1674,6 +1885,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 +1958,7 @@ def begin_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1747,6 +1968,9 @@ def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1778,6 +2002,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 +2075,7 @@ def begin_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1851,6 +2085,9 @@ def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -1882,6 +2119,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 +2150,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 +2203,9 @@ def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "publicNetworkAccess": "str", "serverVersion": "str" }, @@ -1964,6 +2226,7 @@ def begin_update( "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -1973,6 +2236,9 @@ def begin_update( "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -2004,6 +2270,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 +2345,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, @@ -2123,6 +2409,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 +2472,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 +2501,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 +2511,9 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -2239,6 +2545,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 +2642,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 +2668,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.MongoCluster"]: "connectionString": "str", "createMode": "str", "earliestRestoreTime": "str", + "infrastructureVersion": "str", "nodeGroupSpecs": [ { "diskSizeGB": 0, @@ -2358,6 +2678,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.MongoCluster"]: "sku": "str" } ], + "previewFeatures": [ + "str" + ], "privateEndpointConnections": [ { "id": "str", @@ -2389,6 +2712,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 +2808,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: @@ -2651,6 +2995,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: @@ -2738,6 +3088,232 @@ def check_name_availability( return deserialized # type: ignore + 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, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(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 = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + response.read() # Load the body in memory and close the socket + 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 + def begin_promote( + self, + resource_group_name: str, + mongo_cluster_name: str, + body: _models.PromoteReplicaRequest, + *, + 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: ~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: """ @@ -2757,6 +3333,19 @@ 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", + "firewall_rule_name", + "accept", + ] + }, + ) def get( self, resource_group_name: str, mongo_cluster_name: str, firewall_rule_name: str, **kwargs: Any ) -> _models.FirewallRule: @@ -2844,6 +3433,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", + "firewall_rule_name", + "content_type", + "accept", + ] + }, + ) def _create_or_update_initial( self, resource_group_name: str, @@ -3100,6 +3702,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 +3831,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]: @@ -3271,6 +3899,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 +3968,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 +4104,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 +4232,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: @@ -3665,6 +4343,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, @@ -3963,6 +4654,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 +4808,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]: @@ -4159,6 +4876,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 +4964,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 +5084,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_mongo_cluster( + 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_mongo_cluster_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..39193f356533a 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: b44b6019c2086d2e89d2d39a42c6d3389e40d903 repo: Azure/azure-rest-api-specs additionalDirectories: