diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/CHANGELOG.md b/sdk/mongocluster/azure-mgmt-mongocluster/CHANGELOG.md index a8b2eb1dbc81..49a65c1af1d6 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/CHANGELOG.md +++ b/sdk/mongocluster/azure-mgmt-mongocluster/CHANGELOG.md @@ -1,5 +1,58 @@ # Release History +## 1.1.0b1 (2025-05-12) + +### Features Added + + - Client `MongoClusterMgmtClient` added operation group `users` + - Model `MongoClusterProperties` added property `data_api` + - Model `MongoClusterProperties` added property `auth_config` + - Model `MongoClusterUpdateProperties` added property `data_api` + - Model `MongoClusterUpdateProperties` added property `auth_config` + - Model `StorageProperties` added property `type` + - Model `StorageProperties` added property `iops` + - Model `StorageProperties` added property `throughput` + - Added model `AuthConfigProperties` + - Added enum `AuthenticationMode` + - Added enum `DataApiMode` + - Added model `DataApiProperties` + - Added model `DatabaseRole` + - Added model `EntraIdentityProvider` + - Added model `EntraIdentityProviderProperties` + - Added enum `EntraPrincipalType` + - Added model `IdentityProvider` + - Added enum `IdentityProviderType` + - Added enum `StorageType` + - Added model `User` + - Added model `UserProperties` + - Added enum `UserRole` + - Added model `UsersOperations` + - Method `MongoClusterProperties.__init__` has a new overload `def __init__(self: None, create_mode: Optional[Union[str, _models.CreateMode]], restore_parameters: Optional[_models.MongoClusterRestoreParameters], replica_parameters: Optional[_models.MongoClusterReplicaParameters], administrator: Optional[_models.AdministratorProperties], server_version: Optional[str], public_network_access: Optional[Union[str, _models.PublicNetworkAccess]], high_availability: Optional[_models.HighAvailabilityProperties], storage: Optional[_models.StorageProperties], sharding: Optional[_models.ShardingProperties], compute: Optional[_models.ComputeProperties], backup: Optional[_models.BackupProperties], data_api: Optional[_models.DataApiProperties], preview_features: Optional[List[Union[str, _models.PreviewFeature]]], auth_config: Optional[_models.AuthConfigProperties])` + - Method `MongoClusterUpdateProperties.__init__` has a new overload `def __init__(self: None, administrator: Optional[_models.AdministratorProperties], server_version: Optional[str], public_network_access: Optional[Union[str, _models.PublicNetworkAccess]], high_availability: Optional[_models.HighAvailabilityProperties], storage: Optional[_models.StorageProperties], sharding: Optional[_models.ShardingProperties], compute: Optional[_models.ComputeProperties], backup: Optional[_models.BackupProperties], data_api: Optional[_models.DataApiProperties], preview_features: Optional[List[Union[str, _models.PreviewFeature]]], auth_config: Optional[_models.AuthConfigProperties])` + - Method `Operation.__init__` has a new overload `def __init__(self: None, display: Optional[_models.OperationDisplay])` + - Method `StorageProperties.__init__` has a new overload `def __init__(self: None, size_gb: Optional[int], type: Optional[Union[str, _models.StorageType]], iops: Optional[int], throughput: Optional[int])` + - Method `AuthConfigProperties.__init__` has a new overload `def __init__(self: None, allowed_modes: Optional[List[Union[str, _models.AuthenticationMode]]])` + - Method `AuthConfigProperties.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `DataApiProperties.__init__` has a new overload `def __init__(self: None, mode: Optional[Union[str, _models.DataApiMode]])` + - Method `DataApiProperties.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `DatabaseRole.__init__` has a new overload `def __init__(self: None, db: str, role: Union[str, _models.UserRole])` + - Method `DatabaseRole.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `EntraIdentityProvider.__init__` has a new overload `def __init__(self: None, properties: _models.EntraIdentityProviderProperties)` + - Method `EntraIdentityProvider.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `EntraIdentityProvider.__init__` has a new overload `def __init__(self: None, type: str)` + - Method `EntraIdentityProvider.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `EntraIdentityProviderProperties.__init__` has a new overload `def __init__(self: None, principal_type: Union[str, _models.EntraPrincipalType])` + - Method `EntraIdentityProviderProperties.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `IdentityProvider.__init__` has a new overload `def __init__(self: None, type: str)` + - Method `IdentityProvider.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `User.__init__` has a new overload `def __init__(self: None, properties: Optional[_models.UserProperties])` + - Method `User.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `UserProperties.__init__` has a new overload `def __init__(self: None, identity_provider: Optional[_models.IdentityProvider], roles: Optional[List[_models.DatabaseRole]])` + - Method `UserProperties.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])` + - Method `UsersOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, mongo_cluster_name: str, user_name: str, resource: User, content_type: str)` + - Method `UsersOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, mongo_cluster_name: str, user_name: str, resource: JSON, content_type: str)` + - Method `UsersOperations.begin_create_or_update` has a new overload `def begin_create_or_update(self: None, resource_group_name: str, mongo_cluster_name: str, user_name: str, resource: IO[bytes], content_type: str)` + ## 1.0.0 (2024-09-26) ### Features Added diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/README.md b/sdk/mongocluster/azure-mgmt-mongocluster/README.md index 5657f54813b9..8a0d8cb11094 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/README.md +++ b/sdk/mongocluster/azure-mgmt-mongocluster/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Mongocluster Management Client Library. -This package has been tested with Python 3.8+. +This package has been tested with Python 3.9+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.8+ is required to use this package. +- Python 3.9+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -24,7 +24,7 @@ pip install azure-identity ### Authentication -By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables. +By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configuration of the following environment variables. - `AZURE_CLIENT_ID` for Azure client ID. - `AZURE_TENANT_ID` for Azure tenant ID. diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/_meta.json b/sdk/mongocluster/azure-mgmt-mongocluster/_meta.json index c03f8a84580e..38e2bebf3785 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/_meta.json +++ b/sdk/mongocluster/azure-mgmt-mongocluster/_meta.json @@ -1,6 +1,6 @@ { - "commit": "f93850874010501f216ceadf19459402efd16d9e", + "commit": "713682507acfafd4e56645790022ae6fd18312f2", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "typespec_src": "specification/mongocluster/DocumentDB.MongoCluster.Management", - "@azure-tools/typespec-python": "0.33.0" + "@azure-tools/typespec-python": "0.44.2" } \ No newline at end of file diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/apiview-properties.json b/sdk/mongocluster/azure-mgmt-mongocluster/apiview-properties.json new file mode 100644 index 000000000000..42e74ca7a56b --- /dev/null +++ b/sdk/mongocluster/azure-mgmt-mongocluster/apiview-properties.json @@ -0,0 +1,120 @@ +{ + "CrossLanguagePackageId": "Microsoft.DocumentDB", + "CrossLanguageDefinitionId": { + "azure.mgmt.mongocluster.models.AdministratorProperties": "Microsoft.DocumentDB.AdministratorProperties", + "azure.mgmt.mongocluster.models.AuthConfigProperties": "Microsoft.DocumentDB.AuthConfigProperties", + "azure.mgmt.mongocluster.models.BackupProperties": "Microsoft.DocumentDB.BackupProperties", + "azure.mgmt.mongocluster.models.CheckNameAvailabilityRequest": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityRequest", + "azure.mgmt.mongocluster.models.CheckNameAvailabilityResponse": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityResponse", + "azure.mgmt.mongocluster.models.ComputeProperties": "Microsoft.DocumentDB.ComputeProperties", + "azure.mgmt.mongocluster.models.ConnectionString": "Microsoft.DocumentDB.ConnectionString", + "azure.mgmt.mongocluster.models.DataApiProperties": "Microsoft.DocumentDB.DataApiProperties", + "azure.mgmt.mongocluster.models.DatabaseRole": "Microsoft.DocumentDB.DatabaseRole", + "azure.mgmt.mongocluster.models.IdentityProvider": "Microsoft.DocumentDB.IdentityProvider", + "azure.mgmt.mongocluster.models.EntraIdentityProvider": "Microsoft.DocumentDB.EntraIdentityProvider", + "azure.mgmt.mongocluster.models.EntraIdentityProviderProperties": "Microsoft.DocumentDB.EntraIdentityProviderProperties", + "azure.mgmt.mongocluster.models.ErrorAdditionalInfo": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "azure.mgmt.mongocluster.models.ErrorDetail": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "azure.mgmt.mongocluster.models.ErrorResponse": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "azure.mgmt.mongocluster.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", + "azure.mgmt.mongocluster.models.ProxyResource": "Azure.ResourceManager.CommonTypes.ProxyResource", + "azure.mgmt.mongocluster.models.FirewallRule": "Microsoft.DocumentDB.FirewallRule", + "azure.mgmt.mongocluster.models.FirewallRuleProperties": "Microsoft.DocumentDB.FirewallRuleProperties", + "azure.mgmt.mongocluster.models.HighAvailabilityProperties": "Microsoft.DocumentDB.HighAvailabilityProperties", + "azure.mgmt.mongocluster.models.ListConnectionStringsResult": "Microsoft.DocumentDB.ListConnectionStringsResult", + "azure.mgmt.mongocluster.models.TrackedResource": "Azure.ResourceManager.CommonTypes.TrackedResource", + "azure.mgmt.mongocluster.models.MongoCluster": "Microsoft.DocumentDB.MongoCluster", + "azure.mgmt.mongocluster.models.MongoClusterProperties": "Microsoft.DocumentDB.MongoClusterProperties", + "azure.mgmt.mongocluster.models.MongoClusterReplicaParameters": "Microsoft.DocumentDB.MongoClusterReplicaParameters", + "azure.mgmt.mongocluster.models.MongoClusterRestoreParameters": "Microsoft.DocumentDB.MongoClusterRestoreParameters", + "azure.mgmt.mongocluster.models.MongoClusterUpdate": "Azure.ResourceManager.Foundations.ResourceUpdateModel", + "azure.mgmt.mongocluster.models.MongoClusterUpdateProperties": "Azure.ResourceManager.Foundations.ResourceUpdateModelProperties", + "azure.mgmt.mongocluster.models.Operation": "Azure.ResourceManager.CommonTypes.Operation", + "azure.mgmt.mongocluster.models.OperationDisplay": "Azure.ResourceManager.CommonTypes.OperationDisplay", + "azure.mgmt.mongocluster.models.PrivateEndpoint": "Azure.ResourceManager.CommonTypes.PrivateEndpoint", + "azure.mgmt.mongocluster.models.PrivateEndpointConnection": "Azure.ResourceManager.CommonTypes.PrivateEndpointConnection", + "azure.mgmt.mongocluster.models.PrivateEndpointConnectionProperties": "Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionProperties", + "azure.mgmt.mongocluster.models.PrivateEndpointConnectionResource": "Microsoft.DocumentDB.PrivateEndpointConnectionResource", + "azure.mgmt.mongocluster.models.PrivateLinkResource": "Microsoft.DocumentDB.PrivateLinkResource", + "azure.mgmt.mongocluster.models.PrivateLinkResourceProperties": "Azure.ResourceManager.CommonTypes.PrivateLinkResourceProperties", + "azure.mgmt.mongocluster.models.PrivateLinkServiceConnectionState": "Azure.ResourceManager.CommonTypes.PrivateLinkServiceConnectionState", + "azure.mgmt.mongocluster.models.PromoteReplicaRequest": "Microsoft.DocumentDB.PromoteReplicaRequest", + "azure.mgmt.mongocluster.models.Replica": "Microsoft.DocumentDB.Replica", + "azure.mgmt.mongocluster.models.ReplicationProperties": "Microsoft.DocumentDB.ReplicationProperties", + "azure.mgmt.mongocluster.models.ShardingProperties": "Microsoft.DocumentDB.ShardingProperties", + "azure.mgmt.mongocluster.models.StorageProperties": "Microsoft.DocumentDB.StorageProperties", + "azure.mgmt.mongocluster.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData", + "azure.mgmt.mongocluster.models.User": "Microsoft.DocumentDB.User", + "azure.mgmt.mongocluster.models.UserProperties": "Microsoft.DocumentDB.UserProperties", + "azure.mgmt.mongocluster.models.Origin": "Azure.ResourceManager.CommonTypes.Origin", + "azure.mgmt.mongocluster.models.ActionType": "Azure.ResourceManager.CommonTypes.ActionType", + "azure.mgmt.mongocluster.models.CreatedByType": "Azure.ResourceManager.CommonTypes.createdByType", + "azure.mgmt.mongocluster.models.CreateMode": "Microsoft.DocumentDB.CreateMode", + "azure.mgmt.mongocluster.models.ProvisioningState": "Microsoft.DocumentDB.ProvisioningState", + "azure.mgmt.mongocluster.models.MongoClusterStatus": "Microsoft.DocumentDB.MongoClusterStatus", + "azure.mgmt.mongocluster.models.PublicNetworkAccess": "Microsoft.DocumentDB.PublicNetworkAccess", + "azure.mgmt.mongocluster.models.HighAvailabilityMode": "Microsoft.DocumentDB.HighAvailabilityMode", + "azure.mgmt.mongocluster.models.StorageType": "Microsoft.DocumentDB.StorageType", + "azure.mgmt.mongocluster.models.DataApiMode": "Microsoft.DocumentDB.DataApiMode", + "azure.mgmt.mongocluster.models.PrivateEndpointServiceConnectionStatus": "Azure.ResourceManager.CommonTypes.PrivateEndpointServiceConnectionStatus", + "azure.mgmt.mongocluster.models.PrivateEndpointConnectionProvisioningState": "Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionProvisioningState", + "azure.mgmt.mongocluster.models.PreviewFeature": "Microsoft.DocumentDB.PreviewFeature", + "azure.mgmt.mongocluster.models.ReplicationRole": "Microsoft.DocumentDB.ReplicationRole", + "azure.mgmt.mongocluster.models.ReplicationState": "Microsoft.DocumentDB.ReplicationState", + "azure.mgmt.mongocluster.models.AuthenticationMode": "Microsoft.DocumentDB.AuthenticationMode", + "azure.mgmt.mongocluster.models.CheckNameAvailabilityReason": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityReason", + "azure.mgmt.mongocluster.models.PromoteOption": "Microsoft.DocumentDB.PromoteOption", + "azure.mgmt.mongocluster.models.PromoteMode": "Microsoft.DocumentDB.PromoteMode", + "azure.mgmt.mongocluster.models.IdentityProviderType": "Microsoft.DocumentDB.IdentityProviderType", + "azure.mgmt.mongocluster.models.EntraPrincipalType": "Microsoft.DocumentDB.EntraPrincipalType", + "azure.mgmt.mongocluster.models.UserRole": "Microsoft.DocumentDB.UserRole", + "azure.mgmt.mongocluster.operations.Operations.list": "Azure.ResourceManager.Operations.list", + "azure.mgmt.mongocluster.aio.operations.Operations.list": "Azure.ResourceManager.Operations.list", + "azure.mgmt.mongocluster.operations.MongoClustersOperations.get": "Microsoft.DocumentDB.MongoClusters.get", + "azure.mgmt.mongocluster.aio.operations.MongoClustersOperations.get": "Microsoft.DocumentDB.MongoClusters.get", + "azure.mgmt.mongocluster.operations.MongoClustersOperations.begin_create_or_update": "Microsoft.DocumentDB.MongoClusters.createOrUpdate", + "azure.mgmt.mongocluster.aio.operations.MongoClustersOperations.begin_create_or_update": "Microsoft.DocumentDB.MongoClusters.createOrUpdate", + "azure.mgmt.mongocluster.operations.MongoClustersOperations.begin_update": "Microsoft.DocumentDB.MongoClusters.update", + "azure.mgmt.mongocluster.aio.operations.MongoClustersOperations.begin_update": "Microsoft.DocumentDB.MongoClusters.update", + "azure.mgmt.mongocluster.operations.MongoClustersOperations.begin_delete": "Microsoft.DocumentDB.MongoClusters.delete", + "azure.mgmt.mongocluster.aio.operations.MongoClustersOperations.begin_delete": "Microsoft.DocumentDB.MongoClusters.delete", + "azure.mgmt.mongocluster.operations.MongoClustersOperations.list_by_resource_group": "Microsoft.DocumentDB.MongoClusters.listByResourceGroup", + "azure.mgmt.mongocluster.aio.operations.MongoClustersOperations.list_by_resource_group": "Microsoft.DocumentDB.MongoClusters.listByResourceGroup", + "azure.mgmt.mongocluster.operations.MongoClustersOperations.list": "Microsoft.DocumentDB.MongoClusters.list", + "azure.mgmt.mongocluster.aio.operations.MongoClustersOperations.list": "Microsoft.DocumentDB.MongoClusters.list", + "azure.mgmt.mongocluster.operations.MongoClustersOperations.list_connection_strings": "Microsoft.DocumentDB.MongoClusters.listConnectionStrings", + "azure.mgmt.mongocluster.aio.operations.MongoClustersOperations.list_connection_strings": "Microsoft.DocumentDB.MongoClusters.listConnectionStrings", + "azure.mgmt.mongocluster.operations.MongoClustersOperations.check_name_availability": "Microsoft.DocumentDB.MongoClusters.checkNameAvailability", + "azure.mgmt.mongocluster.aio.operations.MongoClustersOperations.check_name_availability": "Microsoft.DocumentDB.MongoClusters.checkNameAvailability", + "azure.mgmt.mongocluster.operations.MongoClustersOperations.begin_promote": "Microsoft.DocumentDB.MongoClusters.promote", + "azure.mgmt.mongocluster.aio.operations.MongoClustersOperations.begin_promote": "Microsoft.DocumentDB.MongoClusters.promote", + "azure.mgmt.mongocluster.operations.FirewallRulesOperations.get": "Microsoft.DocumentDB.FirewallRules.get", + "azure.mgmt.mongocluster.aio.operations.FirewallRulesOperations.get": "Microsoft.DocumentDB.FirewallRules.get", + "azure.mgmt.mongocluster.operations.FirewallRulesOperations.begin_create_or_update": "Microsoft.DocumentDB.FirewallRules.createOrUpdate", + "azure.mgmt.mongocluster.aio.operations.FirewallRulesOperations.begin_create_or_update": "Microsoft.DocumentDB.FirewallRules.createOrUpdate", + "azure.mgmt.mongocluster.operations.FirewallRulesOperations.begin_delete": "Microsoft.DocumentDB.FirewallRules.delete", + "azure.mgmt.mongocluster.aio.operations.FirewallRulesOperations.begin_delete": "Microsoft.DocumentDB.FirewallRules.delete", + "azure.mgmt.mongocluster.operations.FirewallRulesOperations.list_by_mongo_cluster": "Microsoft.DocumentDB.FirewallRules.listByMongoCluster", + "azure.mgmt.mongocluster.aio.operations.FirewallRulesOperations.list_by_mongo_cluster": "Microsoft.DocumentDB.FirewallRules.listByMongoCluster", + "azure.mgmt.mongocluster.operations.PrivateEndpointConnectionsOperations.list_by_mongo_cluster": "Microsoft.DocumentDB.PrivateEndpointConnections.listByMongoCluster", + "azure.mgmt.mongocluster.aio.operations.PrivateEndpointConnectionsOperations.list_by_mongo_cluster": "Microsoft.DocumentDB.PrivateEndpointConnections.listByMongoCluster", + "azure.mgmt.mongocluster.operations.PrivateEndpointConnectionsOperations.get": "Microsoft.DocumentDB.PrivateEndpointConnections.get", + "azure.mgmt.mongocluster.aio.operations.PrivateEndpointConnectionsOperations.get": "Microsoft.DocumentDB.PrivateEndpointConnections.get", + "azure.mgmt.mongocluster.operations.PrivateEndpointConnectionsOperations.begin_create": "Microsoft.DocumentDB.PrivateEndpointConnections.create", + "azure.mgmt.mongocluster.aio.operations.PrivateEndpointConnectionsOperations.begin_create": "Microsoft.DocumentDB.PrivateEndpointConnections.create", + "azure.mgmt.mongocluster.operations.PrivateEndpointConnectionsOperations.begin_delete": "Microsoft.DocumentDB.PrivateEndpointConnections.delete", + "azure.mgmt.mongocluster.aio.operations.PrivateEndpointConnectionsOperations.begin_delete": "Microsoft.DocumentDB.PrivateEndpointConnections.delete", + "azure.mgmt.mongocluster.operations.PrivateLinksOperations.list_by_mongo_cluster": "Microsoft.DocumentDB.PrivateLinks.listByMongoCluster", + "azure.mgmt.mongocluster.aio.operations.PrivateLinksOperations.list_by_mongo_cluster": "Microsoft.DocumentDB.PrivateLinks.listByMongoCluster", + "azure.mgmt.mongocluster.operations.ReplicasOperations.list_by_parent": "Microsoft.DocumentDB.Replicas.listByParent", + "azure.mgmt.mongocluster.aio.operations.ReplicasOperations.list_by_parent": "Microsoft.DocumentDB.Replicas.listByParent", + "azure.mgmt.mongocluster.operations.UsersOperations.get": "Microsoft.DocumentDB.Users.get", + "azure.mgmt.mongocluster.aio.operations.UsersOperations.get": "Microsoft.DocumentDB.Users.get", + "azure.mgmt.mongocluster.operations.UsersOperations.begin_create_or_update": "Microsoft.DocumentDB.Users.createOrUpdate", + "azure.mgmt.mongocluster.aio.operations.UsersOperations.begin_create_or_update": "Microsoft.DocumentDB.Users.createOrUpdate", + "azure.mgmt.mongocluster.operations.UsersOperations.begin_delete": "Microsoft.DocumentDB.Users.delete", + "azure.mgmt.mongocluster.aio.operations.UsersOperations.begin_delete": "Microsoft.DocumentDB.Users.delete", + "azure.mgmt.mongocluster.operations.UsersOperations.list_by_mongo_cluster": "Microsoft.DocumentDB.Users.listByMongoCluster", + "azure.mgmt.mongocluster.aio.operations.UsersOperations.list_by_mongo_cluster": "Microsoft.DocumentDB.Users.listByMongoCluster" + } +} \ No newline at end of file diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/__init__.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/__init__.py index 7c7f589084c0..034de13c93e8 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/__init__.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._client import MongoClusterMgmtClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import MongoClusterMgmtClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "MongoClusterMgmtClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() 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 93fcfbef2c23..7b2cbbbe14ba 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_client.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_client.py @@ -7,16 +7,18 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING, cast from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse +from azure.core.settings import settings from azure.mgmt.core import ARMPipelineClient from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints from ._configuration import MongoClusterMgmtClientConfiguration -from ._serialization import Deserializer, Serializer +from ._utils.serialization import Deserializer, Serializer from .operations import ( FirewallRulesOperations, MongoClustersOperations, @@ -24,14 +26,14 @@ PrivateEndpointConnectionsOperations, PrivateLinksOperations, ReplicasOperations, + UsersOperations, ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MongoClusterMgmtClient: # pylint: disable=client-accepts-api-version-keyword +class MongoClusterMgmtClient: # pylint: disable=too-many-instance-attributes """The Microsoft Azure management API provides create, read, update, and delete functionality for Azure Cosmos DB for MongoDB vCore resources including clusters and firewall rules. @@ -48,30 +50,39 @@ class MongoClusterMgmtClient: # pylint: disable=client-accepts-api-version-keyw :vartype private_links: azure.mgmt.mongocluster.operations.PrivateLinksOperations :ivar replicas: ReplicasOperations operations :vartype replicas: azure.mgmt.mongocluster.operations.ReplicasOperations + :ivar users: UsersOperations operations + :vartype users: azure.mgmt.mongocluster.operations.UsersOperations :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. :type subscription_id: str - :param base_url: Service host. Default value is "https://management.azure.com". + :param base_url: Service host. Default value is None. :type base_url: str - :keyword api_version: The API version to use for this operation. Default value is "2024-07-01". - Note that overriding this default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2025-04-01-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any ) -> None: _endpoint = "{endpoint}" + _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) self._config = MongoClusterMgmtClientConfiguration( - credential=credential, subscription_id=subscription_id, base_url=base_url, **kwargs + credential=credential, + subscription_id=subscription_id, + base_url=cast(str, base_url), + credential_scopes=credential_scopes, + **kwargs ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -90,7 +101,7 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, _endpoint), policies=_policies, **kwargs) self._serialize = Serializer() self._deserialize = Deserializer() @@ -103,6 +114,7 @@ def __init__( ) self.private_links = PrivateLinksOperations(self._client, self._config, self._serialize, self._deserialize) self.replicas = ReplicasOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(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 870c54669cad..d38b6da85f5a 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_configuration.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_configuration.py @@ -14,11 +14,10 @@ from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class MongoClusterMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class MongoClusterMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for MongoClusterMgmtClient. Note that all parameters used to create this instance are saved as instance @@ -30,8 +29,9 @@ class MongoClusterMgmtClientConfiguration: # pylint: disable=too-many-instance- :type subscription_id: str :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-07-01". - Note that overriding this default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2025-04-01-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ @@ -42,7 +42,7 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "2024-07-01") + api_version: str = kwargs.pop("api_version", "2025-04-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/_patch.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_patch.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_utils/__init__.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_utils/__init__.py new file mode 100644 index 000000000000..8026245c2abc --- /dev/null +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_utils/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_model_base.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_utils/model_base.py similarity index 91% rename from sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_model_base.py rename to sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_utils/model_base.py index 12ad7f29c71e..49d5c7259389 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_model_base.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_utils/model_base.py @@ -1,10 +1,12 @@ +# pylint: disable=too-many-lines # 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. +# 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. # -------------------------------------------------------------------------- -# pylint: disable=protected-access, arguments-differ, signature-differs, broad-except, too-many-lines +# pylint: disable=protected-access, broad-except import copy import calendar @@ -20,6 +22,7 @@ from datetime import datetime, date, time, timedelta, timezone from json import JSONEncoder import xml.etree.ElementTree as ET +from collections.abc import MutableMapping from typing_extensions import Self import isodate from azure.core.exceptions import DeserializationError @@ -27,11 +30,6 @@ from azure.core.pipeline import PipelineResponse from azure.core.serialization import _Null -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping - _LOGGER = logging.getLogger(__name__) __all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] @@ -346,7 +344,7 @@ def _get_model(module_name: str, model_name: str): _UNSET = object() -class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object +class _MyMutableMapping(MutableMapping[str, typing.Any]): def __init__(self, data: typing.Dict[str, typing.Any]) -> None: self._data = data @@ -372,50 +370,97 @@ def __ne__(self, other: typing.Any) -> bool: return not self.__eq__(other) def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ return self._data.keys() def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ return self._data.values() def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ return self._data.items() def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ try: return self[key] except KeyError: return default @typing.overload - def pop(self, key: str) -> typing.Any: ... + def pop(self, key: str) -> typing.Any: ... # pylint: disable=arguments-differ @typing.overload - def pop(self, key: str, default: _T) -> _T: ... + def pop(self, key: str, default: _T) -> _T: ... # pylint: disable=signature-differs @typing.overload - def pop(self, key: str, default: typing.Any) -> typing.Any: ... + def pop(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ if default is _UNSET: return self._data.pop(key) return self._data.pop(key, default) def popitem(self) -> typing.Tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ return self._data.popitem() def clear(self) -> None: + """ + Remove all items from D. + """ self._data.clear() - def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ self._data.update(*args, **kwargs) @typing.overload def setdefault(self, key: str, default: None = None) -> None: ... @typing.overload - def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ if default is _UNSET: return self._data.setdefault(key) return self._data.setdefault(key, default) @@ -573,7 +618,7 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: def copy(self) -> "Model": return Model(self.__dict__) - def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: disable=unused-argument + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' @@ -584,8 +629,8 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: di annotations = { k: v for mro_class in mros - if hasattr(mro_class, "__annotations__") # pylint: disable=no-member - for k, v in mro_class.__annotations__.items() # pylint: disable=no-member + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() } for attr, rf in attr_to_rest_field.items(): rf._module = cls.__module__ @@ -596,12 +641,12 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: di cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") - return super().__new__(cls) # pylint: disable=no-value-for-parameter + return super().__new__(cls) def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: for base in cls.__bases__: - if hasattr(base, "__mapping__"): # pylint: disable=no-member - base.__mapping__[discriminator or cls.__name__] = cls # type: ignore # pylint: disable=no-member + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore @classmethod def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: @@ -612,7 +657,7 @@ def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField @classmethod def _deserialize(cls, data, exist_discriminators): - if not hasattr(cls, "__mapping__"): # pylint: disable=no-member + if not hasattr(cls, "__mapping__"): return cls(data) discriminator = cls._get_discriminator(exist_discriminators) if discriminator is None: @@ -636,7 +681,7 @@ def _deserialize(cls, data, exist_discriminators): return mapped_cls._deserialize(data, exist_discriminators) def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]: - """Return a dict that can be JSONify using json.dump. + """Return a dict that can be turned into json using json.dump. :keyword bool exclude_readonly: Whether to remove the readonly properties. :returns: A dict JSON compatible object @@ -733,7 +778,7 @@ def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.An ) -def _get_deserialize_callable_from_annotation( # pylint: disable=R0911, R0915, R0912 +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-branches annotation: typing.Any, module: typing.Optional[str], rf: typing.Optional["_RestField"] = None, @@ -753,7 +798,7 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=R0911, R0915, except AttributeError: model_name = annotation if module is not None: - annotation = _get_model(module, model_name) + annotation = _get_model(module, model_name) # type: ignore try: if module and _is_model(annotation): @@ -893,6 +938,35 @@ def _deserialize( return _deserialize_with_callable(deserializer, value) +def _failsafe_deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, value, module, rf, format) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + value: typing.Any, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, value) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + class _RestField: def __init__( self, diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_serialization.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_utils/serialization.py similarity index 93% rename from sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_serialization.py rename to sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_utils/serialization.py index 01a226bd7f14..eb86ea23c965 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_serialization.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_utils/serialization.py @@ -1,28 +1,10 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pyright: reportUnnecessaryTypeIgnoreComment=false @@ -48,9 +30,7 @@ IO, Mapping, Callable, - TypeVar, MutableMapping, - Type, List, ) @@ -61,13 +41,13 @@ import xml.etree.ElementTree as ET import isodate # type: ignore +from typing_extensions import Self from azure.core.exceptions import DeserializationError, SerializationError from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -ModelType = TypeVar("ModelType", bound="Model") JSON = MutableMapping[str, Any] @@ -185,73 +165,7 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], except NameError: _long_type = int - -class UTC(datetime.tzinfo): - """Time Zone info for handling UTC""" - - def utcoffset(self, dt): - """UTF offset for UTC is 0. - - :param datetime.datetime dt: The datetime - :returns: The offset - :rtype: datetime.timedelta - """ - return datetime.timedelta(0) - - def tzname(self, dt): - """Timestamp representation. - - :param datetime.datetime dt: The datetime - :returns: The timestamp representation - :rtype: str - """ - return "Z" - - def dst(self, dt): - """No daylight saving for UTC. - - :param datetime.datetime dt: The datetime - :returns: The daylight saving time - :rtype: datetime.timedelta - """ - return datetime.timedelta(hours=1) - - -try: - from datetime import timezone as _FixedOffset # type: ignore -except ImportError: # Python 2.7 - - class _FixedOffset(datetime.tzinfo): # type: ignore - """Fixed offset in minutes east from UTC. - Copy/pasted from Python doc - :param datetime.timedelta offset: offset in timedelta format - """ - - def __init__(self, offset): - self.__offset = offset - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return str(self.__offset.total_seconds() / 3600) - - def __repr__(self): - return "".format(self.tzname(None)) - - def dst(self, dt): - return datetime.timedelta(0) - - def __getinitargs__(self): - return (self.__offset,) - - -try: - from datetime import timezone - - TZ_UTC = timezone.utc -except ImportError: - TZ_UTC = UTC() # type: ignore +TZ_UTC = datetime.timezone.utc _FLATTEN = re.compile(r"(? ModelType: + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: ModelType + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( - cls: Type[ModelType], + cls, data: Any, key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, content_type: Optional[str] = None, - ) -> ModelType: + ) -> Self: """Parse a dict using given key extractor return a model. By default consider key @@ -479,8 +393,8 @@ def from_dict( :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: ModelType + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -507,7 +421,6 @@ def _flatten_subtype(cls, key, objects): def _classify(cls, response, objects): """Check the class _subtype_map for any child classes. We want to ignore any inherited _subtype_maps. - Remove the polymorphic key from the initial data. :param dict response: The initial data :param dict objects: The class objects @@ -519,7 +432,7 @@ def _classify(cls, response, objects): if not isinstance(response, ET.Element): rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) else: subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) if subtype_value: @@ -564,7 +477,7 @@ def _decode_attribute_map_key(key): return key.replace("\\.", ".") -class Serializer(object): # pylint: disable=too-many-public-methods +class Serializer: # pylint: disable=too-many-public-methods """Request object model serializer.""" basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -599,7 +512,7 @@ class Serializer(object): # pylint: disable=too-many-public-methods "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, type]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -627,7 +540,7 @@ def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, to :param object target_obj: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, dict - :raises: SerializationError if serialization fails. + :raises SerializationError: if serialization fails. :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) @@ -737,8 +650,8 @@ def body(self, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: dict - :raises: SerializationError if serialization fails. - :raises: ValueError if data is None + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized request body """ @@ -782,8 +695,8 @@ def url(self, name, data, data_type, **kwargs): :param str data_type: The type to be serialized from. :rtype: str :returns: The serialized URL path - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None """ try: output = self.serialize_data(data, data_type, **kwargs) @@ -806,8 +719,8 @@ def query(self, name, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, list - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized query parameter """ try: @@ -836,8 +749,8 @@ def header(self, name, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized header """ try: @@ -856,9 +769,9 @@ def serialize_data(self, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :raises: AttributeError if required data is None. - :raises: ValueError if data is None - :raises: SerializationError if serialization fails. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. :returns: The serialized data. :rtype: str, int, float, bool, dict, list """ @@ -1193,7 +1106,7 @@ def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: str - :raises: TypeError if format invalid. + :raises TypeError: if format invalid. :return: serialized rfc """ try: @@ -1219,7 +1132,7 @@ def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: str - :raises: SerializationError if format invalid. + :raises SerializationError: if format invalid. :return: serialized iso """ if isinstance(attr, str): @@ -1252,7 +1165,7 @@ def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: int - :raises: SerializationError if format invalid + :raises SerializationError: if format invalid :return: serialied unix """ if isinstance(attr, int): @@ -1430,7 +1343,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) @@ -1442,7 +1355,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument return children[0] -class Deserializer(object): +class Deserializer: """Response object model deserializer. :param dict classes: Class type dictionary for deserializing complex types. @@ -1453,7 +1366,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, type]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1489,7 +1402,7 @@ def __call__(self, target_obj, response_data, content_type=None): :param str target_obj: Target data type to deserialize to. :param requests.Response response_data: REST response object. :param str content_type: Swagger "produces" if available. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1503,7 +1416,7 @@ def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return :param str target_obj: Target data type to deserialize to. :param object data: Object to deserialize. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1684,17 +1597,21 @@ def _instantiate_model(self, response, attrs, additional_properties=None): subtype = getattr(response, "_subtype_map", {}) try: readonly = [ - k for k, v in response._validation.items() if v.get("readonly") # pylint: disable=protected-access + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") ] const = [ - k for k, v in response._validation.items() if v.get("constant") # pylint: disable=protected-access + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") ] kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} response_obj = response(**kwargs) for attr in readonly: setattr(response_obj, attr, attrs.get(attr)) if additional_properties: - response_obj.additional_properties = additional_properties + response_obj.additional_properties = additional_properties # type: ignore return response_obj except TypeError as err: msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore @@ -1714,7 +1631,7 @@ def deserialize_data(self, data, data_type): # pylint: disable=too-many-return- :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1796,7 +1713,7 @@ def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return :param dict attr: Dictionary to be deserialized. :return: Deserialized object. :rtype: dict - :raises: TypeError if non-builtin datatype encountered. + :raises TypeError: if non-builtin datatype encountered. """ if attr is None: return None @@ -1842,7 +1759,7 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return :param str data_type: deserialization data type. :return: Deserialized basic type. :rtype: str, int, float or bool - :raises: TypeError if string format is not valid. + :raises TypeError: if string format is not valid. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1933,7 +1850,7 @@ def deserialize_bytearray(attr): :param str attr: response string to be deserialized. :return: Deserialized bytearray :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1946,7 +1863,7 @@ def deserialize_base64(attr): :param str attr: response string to be deserialized. :return: Deserialized base64 string :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1961,7 +1878,7 @@ def deserialize_decimal(attr): :param str attr: response string to be deserialized. :return: Deserialized decimal - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. :rtype: decimal """ if isinstance(attr, ET.Element): @@ -1979,7 +1896,7 @@ def deserialize_long(attr): :param str attr: response string to be deserialized. :return: Deserialized int :rtype: long or int - :raises: ValueError if string format invalid. + :raises ValueError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1992,7 +1909,7 @@ def deserialize_duration(attr): :param str attr: response string to be deserialized. :return: Deserialized duration :rtype: TimeDelta - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2010,7 +1927,7 @@ def deserialize_date(attr): :param str attr: response string to be deserialized. :return: Deserialized date :rtype: Date - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2026,7 +1943,7 @@ def deserialize_time(attr): :param str attr: response string to be deserialized. :return: Deserialized time :rtype: datetime.time - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2041,14 +1958,14 @@ def deserialize_rfc(attr): :param str attr: response string to be deserialized. :return: Deserialized RFC datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text try: parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) if not date_obj.tzinfo: date_obj = date_obj.astimezone(tz=TZ_UTC) @@ -2064,7 +1981,7 @@ def deserialize_iso(attr): :param str attr: response string to be deserialized. :return: Deserialized ISO datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2102,7 +2019,7 @@ def deserialize_unix(attr): :param int attr: Object to be serialized. :return: Deserialized datetime :rtype: Datetime - :raises: DeserializationError if format invalid + :raises DeserializationError: if format invalid """ if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_version.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_version.py index 0ec13ea52bbf..a1f432eddc4e 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_version.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "1.1.0b1" diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/__init__.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/__init__.py index 450287ccbf62..1d6e3fc2ed37 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/__init__.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._client import MongoClusterMgmtClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import MongoClusterMgmtClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "MongoClusterMgmtClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() 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 837664327c15..91aa9a2ac94d 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 @@ -7,15 +7,17 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING +from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.settings import settings from azure.mgmt.core import AsyncARMPipelineClient from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints -from .._serialization import Deserializer, Serializer +from .._utils.serialization import Deserializer, Serializer from ._configuration import MongoClusterMgmtClientConfiguration from .operations import ( FirewallRulesOperations, @@ -24,14 +26,14 @@ PrivateEndpointConnectionsOperations, PrivateLinksOperations, ReplicasOperations, + UsersOperations, ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MongoClusterMgmtClient: # pylint: disable=client-accepts-api-version-keyword +class MongoClusterMgmtClient: # pylint: disable=too-many-instance-attributes """The Microsoft Azure management API provides create, read, update, and delete functionality for Azure Cosmos DB for MongoDB vCore resources including clusters and firewall rules. @@ -48,30 +50,39 @@ class MongoClusterMgmtClient: # pylint: disable=client-accepts-api-version-keyw :vartype private_links: azure.mgmt.mongocluster.aio.operations.PrivateLinksOperations :ivar replicas: ReplicasOperations operations :vartype replicas: azure.mgmt.mongocluster.aio.operations.ReplicasOperations + :ivar users: UsersOperations operations + :vartype users: azure.mgmt.mongocluster.aio.operations.UsersOperations :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. :type subscription_id: str - :param base_url: Service host. Default value is "https://management.azure.com". + :param base_url: Service host. Default value is None. :type base_url: str - :keyword api_version: The API version to use for this operation. Default value is "2024-07-01". - Note that overriding this default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2025-04-01-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any ) -> None: _endpoint = "{endpoint}" + _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) self._config = MongoClusterMgmtClientConfiguration( - credential=credential, subscription_id=subscription_id, base_url=base_url, **kwargs + credential=credential, + subscription_id=subscription_id, + base_url=cast(str, base_url), + credential_scopes=credential_scopes, + **kwargs ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -90,7 +101,9 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( + base_url=cast(str, _endpoint), policies=_policies, **kwargs + ) self._serialize = Serializer() self._deserialize = Deserializer() @@ -103,6 +116,7 @@ def __init__( ) self.private_links = PrivateLinksOperations(self._client, self._config, self._serialize, self._deserialize) self.replicas = ReplicasOperations(self._client, self._config, self._serialize, self._deserialize) + self.users = UsersOperations(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 fefa880a1456..a465d9816ce5 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 @@ -14,11 +14,10 @@ from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class MongoClusterMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class MongoClusterMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for MongoClusterMgmtClient. Note that all parameters used to create this instance are saved as instance @@ -30,8 +29,9 @@ class MongoClusterMgmtClientConfiguration: # pylint: disable=too-many-instance- :type subscription_id: str :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-07-01". - Note that overriding this default value may result in unsupported behavior. + :keyword api_version: The API version to use for this operation. Default value is + "2025-04-01-preview". Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ @@ -42,7 +42,7 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "2024-07-01") + api_version: str = kwargs.pop("api_version", "2025-04-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/_patch.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/_patch.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize 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 c2fa532ddd59..67346bccc6ff 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 @@ -5,16 +5,23 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._operations import Operations -from ._operations import MongoClustersOperations -from ._operations import FirewallRulesOperations -from ._operations import PrivateEndpointConnectionsOperations -from ._operations import PrivateLinksOperations -from ._operations import ReplicasOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import Operations # type: ignore +from ._operations import MongoClustersOperations # type: ignore +from ._operations import FirewallRulesOperations # type: ignore +from ._operations import PrivateEndpointConnectionsOperations # type: ignore +from ._operations import PrivateLinksOperations # type: ignore +from ._operations import ReplicasOperations # type: ignore +from ._operations import UsersOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -24,6 +31,7 @@ "PrivateEndpointConnectionsOperations", "PrivateLinksOperations", "ReplicasOperations", + "UsersOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _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 4a0bf928072d..348fe621650f 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,26 +6,13 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase import json -import sys -from typing import ( - Any, - AsyncIterable, - AsyncIterator, - Callable, - Dict, - IO, - List, - Optional, - Type, - TypeVar, - Union, - cast, - overload, -) +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -47,7 +34,8 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._model_base import SdkJSONEncoder, _deserialize +from ..._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from ..._utils.serialization import Deserializer, Serializer from ..._validation import api_version_validation from ...operations._operations import ( build_firewall_rules_create_or_update_request, @@ -70,15 +58,16 @@ build_private_endpoint_connections_list_by_mongo_cluster_request, build_private_links_list_by_mongo_cluster_request, build_replicas_list_by_parent_request, + build_users_create_or_update_request, + build_users_delete_request, + build_users_get_request, + build_users_list_by_mongo_cluster_request, ) +from .._configuration import MongoClusterMgmtClientConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +JSON = MutableMapping[str, Any] class Operations: @@ -93,15 +82,12 @@ class Operations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MongoClusterMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """List the operations for the provider. @@ -114,7 +100,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -161,7 +147,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Operation], deserialized["value"]) + list_of_elem = _deserialize(List[_models.Operation], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -177,7 +163,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -197,15 +183,12 @@ class MongoClustersOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MongoClusterMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) async def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any) -> _models.MongoCluster: """Gets information about a mongo cluster. @@ -218,7 +201,7 @@ async def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: :rtype: ~azure.mgmt.mongocluster.models.MongoCluster :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -258,7 +241,7 @@ async def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if _stream: @@ -271,9 +254,6 @@ async def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: return deserialized # type: ignore - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) async def _create_or_update_initial( self, resource_group_name: str, @@ -281,7 +261,7 @@ async def _create_or_update_initial( resource: Union[_models.MongoCluster, JSON, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -330,7 +310,7 @@ async def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -432,9 +412,6 @@ async def begin_create_or_update( """ @distributed_trace_async - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) async def begin_create_or_update( self, resource_group_name: str, @@ -510,9 +487,6 @@ 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-06-01-preview": ["base_url"]}, - ) async def _update_initial( self, resource_group_name: str, @@ -520,7 +494,7 @@ async def _update_initial( properties: Union[_models.MongoClusterUpdate, JSON, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -569,7 +543,7 @@ async def _update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -672,9 +646,6 @@ async def begin_update( """ @distributed_trace_async - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) async def begin_update( self, resource_group_name: str, @@ -750,13 +721,10 @@ 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-06-01-preview": ["base_url"]}, - ) async def _delete_initial( self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -795,7 +763,7 @@ async def _delete_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -811,9 +779,6 @@ async def _delete_initial( return deserialized # type: ignore @distributed_trace_async - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) async def begin_delete( self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: @@ -873,9 +838,6 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) 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. @@ -891,7 +853,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy cls: ClsType[List[_models.MongoCluster]] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -940,7 +902,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.MongoCluster], deserialized["value"]) + list_of_elem = _deserialize(List[_models.MongoCluster], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -956,7 +918,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -964,9 +926,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def list(self, **kwargs: Any) -> AsyncIterable["_models.MongoCluster"]: """List all the mongo clusters in a given subscription. @@ -979,7 +938,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.MongoCluster"]: cls: ClsType[List[_models.MongoCluster]] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1027,7 +986,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.MongoCluster], deserialized["value"]) + list_of_elem = _deserialize(List[_models.MongoCluster], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -1043,7 +1002,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -1051,9 +1010,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) async def list_connection_strings( self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any ) -> _models.ListConnectionStringsResult: @@ -1070,7 +1026,7 @@ async def list_connection_strings( :rtype: ~azure.mgmt.mongocluster.models.ListConnectionStringsResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1110,7 +1066,7 @@ async def list_connection_strings( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if _stream: @@ -1186,9 +1142,6 @@ async def check_name_availability( """ @distributed_trace_async - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) async def check_name_availability( self, location: str, body: Union[_models.CheckNameAvailabilityRequest, JSON, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResponse: @@ -1204,7 +1157,7 @@ async def check_name_availability( :rtype: ~azure.mgmt.mongocluster.models.CheckNameAvailabilityResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1253,7 +1206,7 @@ async def check_name_availability( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if _stream: @@ -1270,7 +1223,6 @@ async def check_name_availability( method_added_on="2024-06-01-preview", params_added_on={ "2024-06-01-preview": [ - "base_url", "api_version", "subscription_id", "resource_group_name", @@ -1287,7 +1239,7 @@ async def _promote_initial( body: Union[_models.PromoteReplicaRequest, JSON, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1336,7 +1288,7 @@ async def _promote_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -1436,7 +1388,6 @@ async def begin_promote( method_added_on="2024-06-01-preview", params_added_on={ "2024-06-01-preview": [ - "base_url", "api_version", "subscription_id", "resource_group_name", @@ -1527,15 +1478,12 @@ class FirewallRulesOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MongoClusterMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) async def get( self, resource_group_name: str, mongo_cluster_name: str, firewall_rule_name: str, **kwargs: Any ) -> _models.FirewallRule: @@ -1552,7 +1500,7 @@ async def get( :rtype: ~azure.mgmt.mongocluster.models.FirewallRule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1593,7 +1541,7 @@ async def get( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if _stream: @@ -1606,9 +1554,6 @@ async def get( return deserialized # type: ignore - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) async def _create_or_update_initial( self, resource_group_name: str, @@ -1617,7 +1562,7 @@ async def _create_or_update_initial( resource: Union[_models.FirewallRule, JSON, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1667,7 +1612,7 @@ async def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -1776,9 +1721,6 @@ async def begin_create_or_update( """ @distributed_trace_async - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) async def begin_create_or_update( self, resource_group_name: str, @@ -1857,13 +1799,10 @@ 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-06-01-preview": ["base_url"]}, - ) async def _delete_initial( self, resource_group_name: str, mongo_cluster_name: str, firewall_rule_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1903,7 +1842,7 @@ async def _delete_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -1919,9 +1858,6 @@ async def _delete_initial( return deserialized # type: ignore @distributed_trace_async - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) async def begin_delete( self, resource_group_name: str, mongo_cluster_name: str, firewall_rule_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: @@ -1984,9 +1920,6 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def list_by_mongo_cluster( self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any ) -> AsyncIterable["_models.FirewallRule"]: @@ -2006,7 +1939,7 @@ def list_by_mongo_cluster( cls: ClsType[List[_models.FirewallRule]] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2056,7 +1989,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.FirewallRule], deserialized["value"]) + list_of_elem = _deserialize(List[_models.FirewallRule], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -2072,7 +2005,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -2092,15 +2025,12 @@ class PrivateEndpointConnectionsOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MongoClusterMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def list_by_mongo_cluster( self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any ) -> AsyncIterable["_models.PrivateEndpointConnectionResource"]: @@ -2121,7 +2051,7 @@ def list_by_mongo_cluster( cls: ClsType[List[_models.PrivateEndpointConnectionResource]] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2171,7 +2101,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.PrivateEndpointConnectionResource], deserialized["value"]) + list_of_elem = _deserialize(List[_models.PrivateEndpointConnectionResource], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -2187,7 +2117,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -2195,9 +2125,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) async def get( self, resource_group_name: str, mongo_cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnectionResource: @@ -2216,7 +2143,7 @@ async def get( :rtype: ~azure.mgmt.mongocluster.models.PrivateEndpointConnectionResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2257,7 +2184,7 @@ async def get( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if _stream: @@ -2270,9 +2197,6 @@ async def get( return deserialized # type: ignore - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) async def _create_initial( self, resource_group_name: str, @@ -2281,7 +2205,7 @@ async def _create_initial( resource: Union[_models.PrivateEndpointConnectionResource, JSON, IO[bytes]], **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2331,7 +2255,7 @@ async def _create_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -2446,9 +2370,6 @@ async def begin_create( """ @distributed_trace_async - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) async def begin_create( self, resource_group_name: str, @@ -2534,13 +2455,10 @@ 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-06-01-preview": ["base_url"]}, - ) async def _delete_initial( self, resource_group_name: str, mongo_cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2580,7 +2498,7 @@ async def _delete_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -2596,9 +2514,6 @@ async def _delete_initial( return deserialized # type: ignore @distributed_trace_async - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) async def begin_delete( self, resource_group_name: str, mongo_cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: @@ -2674,15 +2589,12 @@ class PrivateLinksOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MongoClusterMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def list_by_mongo_cluster( self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any ) -> AsyncIterable["_models.PrivateLinkResource"]: @@ -2703,7 +2615,7 @@ def list_by_mongo_cluster( cls: ClsType[List[_models.PrivateLinkResource]] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2753,7 +2665,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.PrivateLinkResource], deserialized["value"]) + list_of_elem = _deserialize(List[_models.PrivateLinkResource], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -2769,7 +2681,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -2789,17 +2701,16 @@ class ReplicasOperations: 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") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MongoClusterMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace @api_version_validation( method_added_on="2024-06-01-preview", params_added_on={ "2024-06-01-preview": [ - "base_url", "api_version", "subscription_id", "resource_group_name", @@ -2827,7 +2738,7 @@ def list_by_parent( cls: ClsType[List[_models.Replica]] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2877,7 +2788,632 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Replica], deserialized["value"]) + list_of_elem = _deserialize(List[_models.Replica], deserialized.get("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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class UsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mongocluster.aio.MongoClusterMgmtClient`'s + :attr:`users` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MongoClusterMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "user_name", + "accept", + ] + }, + ) + async def get( + self, resource_group_name: str, mongo_cluster_name: str, user_name: str, **kwargs: Any + ) -> _models.User: + """Gets the defintion of a Mongo cluster user. + + :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 user_name: The name of the mongo cluster user. Required. + :type user_name: str + :return: User. The User is compatible with MutableMapping + :rtype: ~azure.mgmt.mongocluster.models.User + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.User] = kwargs.pop("cls", None) + + _request = build_users_get_request( + resource_group_name=resource_group_name, + mongo_cluster_name=mongo_cluster_name, + user_name=user_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("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]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.User, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "user_name", + "content_type", + "accept", + ] + }, + ) + async def _create_or_update_initial( + self, + resource_group_name: str, + mongo_cluster_name: str, + user_name: str, + resource: Union[_models.User, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = 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(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_users_create_or_update_request( + resource_group_name=resource_group_name, + mongo_cluster_name=mongo_cluster_name, + user_name=user_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + 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_create_or_update( + self, + resource_group_name: str, + mongo_cluster_name: str, + user_name: str, + resource: _models.User, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user on a 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 + :param user_name: The name of the mongo cluster user. Required. + :type user_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.mongocluster.models.User + :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 User. The User is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mongocluster.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + mongo_cluster_name: str, + user_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user on a 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 + :param user_name: The name of the mongo cluster user. Required. + :type user_name: str + :param resource: Resource create parameters. Required. + :type resource: 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 User. The User is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mongocluster.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + mongo_cluster_name: str, + user_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user on a 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 + :param user_name: The name of the mongo cluster user. Required. + :type user_name: str + :param resource: Resource create parameters. Required. + :type resource: 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 User. The User is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mongocluster.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "user_name", + "content_type", + "accept", + ] + }, + ) + async def begin_create_or_update( + self, + resource_group_name: str, + mongo_cluster_name: str, + user_name: str, + resource: Union[_models.User, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.User]: + """Creates a new user or updates an existing user on a 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 + :param user_name: The name of the mongo cluster user. Required. + :type user_name: str + :param resource: Resource create parameters. Is one of the following types: User, JSON, + IO[bytes] Required. + :type resource: ~azure.mgmt.mongocluster.models.User or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns User. The User is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mongocluster.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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[_models.User] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + mongo_cluster_name=mongo_cluster_name, + user_name=user_name, + resource=resource, + 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): + response = pipeline_response.http_response + deserialized = _deserialize(_models.User, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.User].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.User]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "user_name", + "accept", + ] + }, + ) + async def _delete_initial( + self, resource_group_name: str, mongo_cluster_name: str, user_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_users_delete_request( + resource_group_name=resource_group_name, + mongo_cluster_name=mongo_cluster_name, + user_name=user_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "user_name", + "accept", + ] + }, + ) + async def begin_delete( + self, resource_group_name: str, mongo_cluster_name: str, user_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a mongo cluster user. + + :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 user_name: The name of the mongo cluster user. Required. + :type user_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + mongo_cluster_name=mongo_cluster_name, + user_name=user_name, + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-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.User"]: + """List all the users on a 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 User + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mongocluster.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.User]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_users_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, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.User], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -2893,7 +3429,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/operations/_patch.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/operations/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/operations/_patch.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/aio/operations/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize 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 a352c3476837..9e9c49188c49 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 @@ -5,78 +5,109 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models import AdministratorProperties -from ._models import BackupProperties -from ._models import CheckNameAvailabilityRequest -from ._models import CheckNameAvailabilityResponse -from ._models import ComputeProperties -from ._models import ConnectionString -from ._models import ErrorAdditionalInfo -from ._models import ErrorDetail -from ._models import ErrorResponse -from ._models import FirewallRule -from ._models import FirewallRuleProperties -from ._models import HighAvailabilityProperties -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 -from ._models import Operation -from ._models import OperationDisplay -from ._models import PrivateEndpoint -from ._models import PrivateEndpointConnection -from ._models import PrivateEndpointConnectionProperties -from ._models import PrivateEndpointConnectionResource -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 ShardingProperties -from ._models import StorageProperties -from ._models import SystemData -from ._models import TrackedResource +from typing import TYPE_CHECKING -from ._enums import ActionType -from ._enums import CheckNameAvailabilityReason -from ._enums import CreateMode -from ._enums import CreatedByType -from ._enums import HighAvailabilityMode -from ._enums import MongoClusterStatus -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 +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models import ( # type: ignore + AdministratorProperties, + AuthConfigProperties, + BackupProperties, + CheckNameAvailabilityRequest, + CheckNameAvailabilityResponse, + ComputeProperties, + ConnectionString, + DataApiProperties, + DatabaseRole, + EntraIdentityProvider, + EntraIdentityProviderProperties, + ErrorAdditionalInfo, + ErrorDetail, + ErrorResponse, + FirewallRule, + FirewallRuleProperties, + HighAvailabilityProperties, + IdentityProvider, + ListConnectionStringsResult, + MongoCluster, + MongoClusterProperties, + MongoClusterReplicaParameters, + MongoClusterRestoreParameters, + MongoClusterUpdate, + MongoClusterUpdateProperties, + Operation, + OperationDisplay, + PrivateEndpoint, + PrivateEndpointConnection, + PrivateEndpointConnectionProperties, + PrivateEndpointConnectionResource, + PrivateLinkResource, + PrivateLinkResourceProperties, + PrivateLinkServiceConnectionState, + PromoteReplicaRequest, + ProxyResource, + Replica, + ReplicationProperties, + Resource, + ShardingProperties, + StorageProperties, + SystemData, + TrackedResource, + User, + UserProperties, +) + +from ._enums import ( # type: ignore + ActionType, + AuthenticationMode, + CheckNameAvailabilityReason, + CreateMode, + CreatedByType, + DataApiMode, + EntraPrincipalType, + HighAvailabilityMode, + IdentityProviderType, + MongoClusterStatus, + Origin, + PreviewFeature, + PrivateEndpointConnectionProvisioningState, + PrivateEndpointServiceConnectionStatus, + PromoteMode, + PromoteOption, + ProvisioningState, + PublicNetworkAccess, + ReplicationRole, + ReplicationState, + StorageType, + UserRole, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ "AdministratorProperties", + "AuthConfigProperties", "BackupProperties", "CheckNameAvailabilityRequest", "CheckNameAvailabilityResponse", "ComputeProperties", "ConnectionString", + "DataApiProperties", + "DatabaseRole", + "EntraIdentityProvider", + "EntraIdentityProviderProperties", "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", "FirewallRule", "FirewallRuleProperties", "HighAvailabilityProperties", + "IdentityProvider", "ListConnectionStringsResult", "MongoCluster", "MongoClusterProperties", @@ -102,11 +133,17 @@ "StorageProperties", "SystemData", "TrackedResource", + "User", + "UserProperties", "ActionType", + "AuthenticationMode", "CheckNameAvailabilityReason", "CreateMode", "CreatedByType", + "DataApiMode", + "EntraPrincipalType", "HighAvailabilityMode", + "IdentityProviderType", "MongoClusterStatus", "Origin", "PreviewFeature", @@ -118,6 +155,8 @@ "PublicNetworkAccess", "ReplicationRole", "ReplicationState", + "StorageType", + "UserRole", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _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 850548c02ab8..af8bb84527c6 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 @@ -19,6 +19,17 @@ class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Actions are for internal-only APIs.""" +class AuthenticationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The authentication modes supporting on the Mongo cluster.""" + + NATIVE_AUTH = "NativeAuth" + """Native mongo authentication mode using username and password with auth mechanism + 'SCRAM-SHA-256'.""" + MICROSOFT_ENTRA_ID = "MicrosoftEntraID" + """Microsot Entra ID authentication mode using Entra users assigned to the cluster and auth + mechanism 'MONGODB-OIDC'.""" + + class CheckNameAvailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Possible reasons for a name not being available.""" @@ -54,6 +65,24 @@ class CreateMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Create a replica cluster in the same geographic region as the source cluster.""" +class DataApiMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The mode to apply to the Mongo Data API.""" + + ENABLED = "Enabled" + """Mongo Data API is enabled for the cluster.""" + DISABLED = "Disabled" + """Mongo Data API is disabled for the cluster.""" + + +class EntraPrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Microsoft Entra ID principal types available for a Mongo user.""" + + USER = "User" + """Entra user type.""" + SERVIE_PRINCIPAL = "ServicePrincipal" + """Entra service principal type.""" + + class HighAvailabilityMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The high availability modes for a cluster.""" @@ -68,6 +97,13 @@ class HighAvailabilityMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): is available in the region, otherwise falls-back to provisioning with SameZone.""" +class IdentityProviderType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Identity provider types that a a user identity can belong to.""" + + MICROSOFT_ENTRA_ID = "MicrosoftEntraID" + """Microsoft Entra ID provider.""" + + class MongoClusterStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the Mongo cluster resource.""" @@ -125,7 +161,7 @@ class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiv """The private endpoint connection status.""" PENDING = "Pending" - """Connectionaiting for approval or rejection""" + """Connection waiting for approval or rejection""" APPROVED = "Approved" """Connection approved""" REJECTED = "Rejected" @@ -204,3 +240,20 @@ class ReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Replication link is broken and the replica may need to be recreated.""" RECONFIGURING = "Reconfiguring" """Replication link is re-configuring due to a promotion event.""" + + +class StorageType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of storage that a mongo cluster can be provisioned with.""" + + PREMIUM_SSD = "PremiumSSD" + """Premium SSD for high performance workloads.""" + PREMIUM_SS_DV2 = "PremiumSSDv2" + """Premium SSD v2 for very IO-intensive workloads. This is a preview option and has additional + limitations.""" + + +class UserRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Built-in database role that can be assigned to a user.""" + + DATABASE_OWNER = "dbOwner" + """Datbase owner role permissions on the target scope.""" 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 6558dd01704b..682d4e71fa45 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 @@ -1,24 +1,24 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 -# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=useless-super-delegation import datetime -from typing import Any, Dict, List, Mapping, Optional, TYPE_CHECKING, Union, overload +from typing import Any, Dict, List, Literal, Mapping, Optional, TYPE_CHECKING, Union, overload -from .. import _model_base -from .._model_base import rest_field +from .._utils.model_base import Model as _Model, rest_discriminator, rest_field +from ._enums import IdentityProviderType if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models -class AdministratorProperties(_model_base.Model): +class AdministratorProperties(_Model): """The local administrator login properties. :ivar user_name: The administrator user name. @@ -38,25 +38,53 @@ def __init__( *, user_name: Optional[str] = None, password: Optional[str] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class BackupProperties(_model_base.Model): +class AuthConfigProperties(_Model): + """The authentication configuration for the Mongo cluster. + + :ivar allowed_modes: Allowed authentication modes for data access on the cluster. + :vartype allowed_modes: list[str or ~azure.mgmt.mongocluster.models.AuthenticationMode] + """ + + allowed_modes: Optional[List[Union[str, "_models.AuthenticationMode"]]] = rest_field( + name="allowedModes", visibility=["read", "create", "update", "delete", "query"] + ) + """Allowed authentication modes for data access on the cluster.""" + + @overload + def __init__( + self, + *, + allowed_modes: Optional[List[Union[str, "_models.AuthenticationMode"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackupProperties(_Model): """The backup properties of the cluster. This includes the earliest restore time and retention settings. - Readonly variables are only populated by the server, and will be ignored when sending a request. - :ivar earliest_restore_time: Earliest restore timestamp in UTC ISO8601 format. :vartype earliest_restore_time: str """ @@ -65,7 +93,7 @@ class BackupProperties(_model_base.Model): """Earliest restore timestamp in UTC ISO8601 format.""" -class CheckNameAvailabilityRequest(_model_base.Model): +class CheckNameAvailabilityRequest(_Model): """The check availability request body. :ivar name: The name of the resource for which availability needs to be checked. @@ -74,9 +102,9 @@ class CheckNameAvailabilityRequest(_model_base.Model): :vartype type: str """ - name: Optional[str] = rest_field() + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name of the resource for which availability needs to be checked.""" - type: Optional[str] = rest_field() + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The resource type.""" @overload @@ -85,20 +113,20 @@ def __init__( *, name: Optional[str] = None, type: Optional[str] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class CheckNameAvailabilityResponse(_model_base.Model): +class CheckNameAvailabilityResponse(_Model): """The check availability result. :ivar name_available: Indicates if the resource name is available. @@ -110,12 +138,16 @@ class CheckNameAvailabilityResponse(_model_base.Model): :vartype message: str """ - name_available: Optional[bool] = rest_field(name="nameAvailable") + name_available: Optional[bool] = rest_field( + name="nameAvailable", visibility=["read", "create", "update", "delete", "query"] + ) """Indicates if the resource name is available.""" - reason: Optional[Union[str, "_models.CheckNameAvailabilityReason"]] = rest_field() + reason: Optional[Union[str, "_models.CheckNameAvailabilityReason"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The reason why the given name is not available. Known values are: \"Invalid\" and \"AlreadyExists\".""" - message: Optional[str] = rest_field() + message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Detailed reason why the given name is not available.""" @overload @@ -125,20 +157,20 @@ def __init__( name_available: Optional[bool] = None, reason: Optional[Union[str, "_models.CheckNameAvailabilityReason"]] = None, message: Optional[str] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class ComputeProperties(_model_base.Model): +class ComputeProperties(_Model): """The compute properties of the cluster. This includes the virtual-cores/memory and scaling options applied to servers in the cluster. @@ -147,7 +179,7 @@ class ComputeProperties(_model_base.Model): :vartype tier: str """ - tier: Optional[str] = rest_field() + tier: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The compute tier to assign to the cluster, where each tier maps to a virtual-core and memory size. Example values: 'M30', 'M40'.""" @@ -156,24 +188,22 @@ def __init__( self, *, tier: Optional[str] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class ConnectionString(_model_base.Model): +class ConnectionString(_Model): """Connection string for the mongo cluster. - Readonly variables are only populated by the server, and will be ignored when sending a request. - :ivar connection_string: Value of the connection string. :vartype connection_string: str :ivar description: Description of the connection string. @@ -190,10 +220,172 @@ class ConnectionString(_model_base.Model): """Name of the connection string.""" -class ErrorAdditionalInfo(_model_base.Model): - """The resource management error additional info. +class DataApiProperties(_Model): + """Data API properties. + + :ivar mode: The mode to indicate whether the Mongo Data API is enabled for a cluster. Known + values are: "Enabled" and "Disabled". + :vartype mode: str or ~azure.mgmt.mongocluster.models.DataApiMode + """ + + mode: Optional[Union[str, "_models.DataApiMode"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The mode to indicate whether the Mongo Data API is enabled for a cluster. Known values are: + \"Enabled\" and \"Disabled\".""" + + @overload + def __init__( + self, + *, + mode: Optional[Union[str, "_models.DataApiMode"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DatabaseRole(_Model): + """Database role definition that is assigned to a user. + + :ivar db: Database scope that the role is assigned to. Required. + :vartype db: str + :ivar role: The role that is assigned to the user on the database scope. Required. "dbOwner" + :vartype role: str or ~azure.mgmt.mongocluster.models.UserRole + """ + + db: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Database scope that the role is assigned to. Required.""" + role: Union[str, "_models.UserRole"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The role that is assigned to the user on the database scope. Required. \"dbOwner\"""" + + @overload + def __init__( + self, + *, + db: str, + role: Union[str, "_models.UserRole"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class IdentityProvider(_Model): + """Defines a user's identity provider definition. - Readonly variables are only populated by the server, and will be ignored when sending a request. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + EntraIdentityProvider + + :ivar type: The type of identity provider that the user belongs to. Required. + "MicrosoftEntraID" + :vartype type: str or ~azure.mgmt.mongocluster.models.IdentityProviderType + """ + + __mapping__: Dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """The type of identity provider that the user belongs to. Required. \"MicrosoftEntraID\"""" + + @overload + def __init__( + self, + *, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EntraIdentityProvider(IdentityProvider, discriminator="MicrosoftEntraID"): + """Defines a Microsot Entra ID Mongo user. + + :ivar type: The type of identity provider that the user belongs to. Required. Microsoft Entra + ID provider. + :vartype type: str or ~azure.mgmt.mongocluster.models.MICROSOFT_ENTRA_ID + :ivar properties: The Entra identity properties for the user. Required. + :vartype properties: ~azure.mgmt.mongocluster.models.EntraIdentityProviderProperties + """ + + type: Literal[IdentityProviderType.MICROSOFT_ENTRA_ID] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of identity provider that the user belongs to. Required. Microsoft Entra ID provider.""" + properties: "_models.EntraIdentityProviderProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The Entra identity properties for the user. Required.""" + + @overload + def __init__( + self, + *, + properties: "_models.EntraIdentityProviderProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, type=IdentityProviderType.MICROSOFT_ENTRA_ID, **kwargs) + + +class EntraIdentityProviderProperties(_Model): + """Microsoft Entra ID provider properties. + + :ivar principal_type: The principal type of the user. Required. Known values are: "User" and + "ServicePrincipal". + :vartype principal_type: str or ~azure.mgmt.mongocluster.models.EntraPrincipalType + """ + + principal_type: Union[str, "_models.EntraPrincipalType"] = rest_field( + name="principalType", visibility=["read", "create", "update", "delete", "query"] + ) + """The principal type of the user. Required. Known values are: \"User\" and \"ServicePrincipal\".""" + + @overload + def __init__( + self, + *, + principal_type: Union[str, "_models.EntraPrincipalType"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ErrorAdditionalInfo(_Model): + """The resource management error additional info. :ivar type: The additional info type. :vartype type: str @@ -207,11 +399,9 @@ class ErrorAdditionalInfo(_model_base.Model): """The additional info.""" -class ErrorDetail(_model_base.Model): +class ErrorDetail(_Model): """The error detail. - Readonly variables are only populated by the server, and will be ignored when sending a request. - :ivar code: The error code. :vartype code: str :ivar message: The error message. @@ -238,15 +428,14 @@ class ErrorDetail(_model_base.Model): """The error additional info.""" -class ErrorResponse(_model_base.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. +class ErrorResponse(_Model): + """Error response. :ivar error: The error object. :vartype error: ~azure.mgmt.mongocluster.models.ErrorDetail """ - error: Optional["_models.ErrorDetail"] = rest_field() + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The error object.""" @overload @@ -254,26 +443,24 @@ def __init__( self, *, error: Optional["_models.ErrorDetail"] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class Resource(_model_base.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Readonly variables are only populated by the server, and will be ignored when sending a request. +class Resource(_Model): + """Resource. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -287,7 +474,7 @@ class Resource(_model_base.Model): id: Optional[str] = rest_field(visibility=["read"]) """Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long""" + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.""" name: Optional[str] = rest_field(visibility=["read"]) """The name of the resource.""" type: Optional[str] = rest_field(visibility=["read"]) @@ -298,13 +485,10 @@ class Resource(_model_base.Model): class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have - tags and a location. - - Readonly variables are only populated by the server, and will be ignored when sending a request. + """Proxy Resource. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -320,10 +504,8 @@ class ProxyResource(Resource): class FirewallRule(ProxyResource): """Represents a mongo cluster firewall rule. - 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 + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -337,7 +519,9 @@ class FirewallRule(ProxyResource): :vartype properties: ~azure.mgmt.mongocluster.models.FirewallRuleProperties """ - properties: Optional["_models.FirewallRuleProperties"] = rest_field() + properties: Optional["_models.FirewallRuleProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The resource-specific properties for this resource.""" @overload @@ -345,25 +529,22 @@ def __init__( self, *, properties: Optional["_models.FirewallRuleProperties"] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class FirewallRuleProperties(_model_base.Model): +class FirewallRuleProperties(_Model): """The properties of a mongo cluster firewall rule. - Readonly variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_state: The provisioning state of the firewall rule. Known values are: "Succeeded", "Failed", "Canceled", "InProgress", "Updating", and "Dropping". :vartype provisioning_state: str or ~azure.mgmt.mongocluster.models.ProvisioningState @@ -380,9 +561,11 @@ class FirewallRuleProperties(_model_base.Model): ) """The provisioning state of the firewall rule. Known values are: \"Succeeded\", \"Failed\", \"Canceled\", \"InProgress\", \"Updating\", and \"Dropping\".""" - start_ip_address: str = rest_field(name="startIpAddress") + start_ip_address: str = rest_field( + name="startIpAddress", visibility=["read", "create", "update", "delete", "query"] + ) """The start IP address of the mongo cluster firewall rule. Must be IPv4 format. Required.""" - end_ip_address: str = rest_field(name="endIpAddress") + end_ip_address: str = rest_field(name="endIpAddress", visibility=["read", "create", "update", "delete", "query"]) """The end IP address of the mongo cluster firewall rule. Must be IPv4 format. Required.""" @overload @@ -391,20 +574,20 @@ def __init__( *, start_ip_address: str, end_ip_address: str, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class HighAvailabilityProperties(_model_base.Model): +class HighAvailabilityProperties(_Model): """The high availability properties of the cluster. :ivar target_mode: The target high availability mode requested for the cluster. Known values @@ -412,7 +595,9 @@ class HighAvailabilityProperties(_model_base.Model): :vartype target_mode: str or ~azure.mgmt.mongocluster.models.HighAvailabilityMode """ - target_mode: Optional[Union[str, "_models.HighAvailabilityMode"]] = rest_field(name="targetMode") + target_mode: Optional[Union[str, "_models.HighAvailabilityMode"]] = rest_field( + name="targetMode", visibility=["read", "create", "update", "delete", "query"] + ) """The target high availability mode requested for the cluster. Known values are: \"Disabled\", \"SameZone\", and \"ZoneRedundantPreferred\".""" @@ -421,24 +606,22 @@ def __init__( self, *, target_mode: Optional[Union[str, "_models.HighAvailabilityMode"]] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class ListConnectionStringsResult(_model_base.Model): +class ListConnectionStringsResult(_Model): """The connection strings for the given mongo cluster. - Readonly variables are only populated by the server, and will be ignored when sending a request. - :ivar connection_strings: An array that contains the connection strings for a mongo cluster. :vartype connection_strings: list[~azure.mgmt.mongocluster.models.ConnectionString] """ @@ -450,14 +633,10 @@ class ListConnectionStringsResult(_model_base.Model): class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which - has 'tags' and a 'location'. - - Readonly variables are only populated by the server, and will be ignored when sending a request. - + """Tracked Resource. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -473,7 +652,7 @@ class TrackedResource(Resource): :vartype location: str """ - tags: Optional[Dict[str, str]] = rest_field() + tags: Optional[Dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Resource tags.""" location: str = rest_field(visibility=["read", "create"]) """The geo-location where the resource lives. Required.""" @@ -484,27 +663,24 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) class MongoCluster(TrackedResource): """Represents a mongo cluster resource. - 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 + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -522,7 +698,9 @@ class MongoCluster(TrackedResource): :vartype properties: ~azure.mgmt.mongocluster.models.MongoClusterProperties """ - properties: Optional["_models.MongoClusterProperties"] = rest_field() + properties: Optional["_models.MongoClusterProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The resource-specific properties for this resource.""" @overload @@ -532,24 +710,22 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, properties: Optional["_models.MongoClusterProperties"] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class MongoClusterProperties(_model_base.Model): # pylint: disable=too-many-instance-attributes +class MongoClusterProperties(_Model): """The properties of a mongo cluster. - 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", "PointInTimeRestore", "GeoReplica", and "Replica". :vartype create_mode: str or ~azure.mgmt.mongocluster.models.CreateMode @@ -583,6 +759,8 @@ class MongoClusterProperties(_model_base.Model): # pylint: disable=too-many-ins :vartype compute: ~azure.mgmt.mongocluster.models.ComputeProperties :ivar backup: The backup properties of the mongo cluster. :vartype backup: ~azure.mgmt.mongocluster.models.BackupProperties + :ivar data_api: The Data API properties of the mongo cluster. + :vartype data_api: ~azure.mgmt.mongocluster.models.DataApiProperties :ivar private_endpoint_connections: List of private endpoint connections. :vartype private_endpoint_connections: list[~azure.mgmt.mongocluster.models.PrivateEndpointConnection] @@ -592,22 +770,30 @@ class MongoClusterProperties(_model_base.Model): # pylint: disable=too-many-ins :vartype replica: ~azure.mgmt.mongocluster.models.ReplicationProperties :ivar infrastructure_version: The infrastructure version the cluster is provisioned on. :vartype infrastructure_version: str + :ivar auth_config: The authentication configuration for the cluster. + :vartype auth_config: ~azure.mgmt.mongocluster.models.AuthConfigProperties """ - create_mode: Optional[Union[str, "_models.CreateMode"]] = rest_field(name="createMode", visibility=["create"]) + create_mode: Optional[Union[str, "_models.CreateMode"]] = rest_field( + name="createMode", visibility=["read", "create"] + ) """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"] + name="restoreParameters", visibility=["read", "create"] ) """The parameters to create a point-in-time restore mongo cluster.""" replica_parameters: Optional["_models.MongoClusterReplicaParameters"] = rest_field( - name="replicaParameters", visibility=["create"] + name="replicaParameters", visibility=["read", "create"] ) """The parameters to create a replica mongo cluster.""" - administrator: Optional["_models.AdministratorProperties"] = rest_field() + administrator: Optional["_models.AdministratorProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The local administrator properties for the mongo cluster.""" - server_version: Optional[str] = rest_field(name="serverVersion") + server_version: Optional[str] = rest_field( + name="serverVersion", visibility=["read", "create", "update", "delete", "query"] + ) """The Mongo DB server version. Defaults to the latest available version if not specified.""" connection_string: Optional[str] = rest_field(name="connectionString", visibility=["read"]) """The default mongo connection string for the cluster.""" @@ -621,29 +807,51 @@ class MongoClusterProperties(_model_base.Model): # pylint: disable=too-many-ins ) """The status of the mongo cluster. Known values are: \"Ready\", \"Provisioning\", \"Updating\", \"Starting\", \"Stopping\", \"Stopped\", and \"Dropping\".""" - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = rest_field(name="publicNetworkAccess") + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = rest_field( + name="publicNetworkAccess", visibility=["read", "create", "update", "delete", "query"] + ) """Whether or not public endpoint access is allowed for this mongo cluster. Known values are: \"Enabled\" and \"Disabled\".""" - high_availability: Optional["_models.HighAvailabilityProperties"] = rest_field(name="highAvailability") + high_availability: Optional["_models.HighAvailabilityProperties"] = rest_field( + name="highAvailability", visibility=["read", "create", "update", "delete", "query"] + ) """The high availability properties of the mongo cluster.""" - storage: Optional["_models.StorageProperties"] = rest_field() + storage: Optional["_models.StorageProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The storage properties of the mongo cluster.""" - sharding: Optional["_models.ShardingProperties"] = rest_field() + sharding: Optional["_models.ShardingProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The sharding properties of the mongo cluster.""" - compute: Optional["_models.ComputeProperties"] = rest_field() + compute: Optional["_models.ComputeProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The compute properties of the mongo cluster.""" - backup: Optional["_models.BackupProperties"] = rest_field() + backup: Optional["_models.BackupProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The backup properties of the mongo cluster.""" + data_api: Optional["_models.DataApiProperties"] = rest_field( + name="dataApi", visibility=["read", "create", "update", "delete", "query"] + ) + """The Data API properties of the mongo cluster.""" private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = rest_field( name="privateEndpointConnections", visibility=["read"] ) """List of private endpoint connections.""" - preview_features: Optional[List[Union[str, "_models.PreviewFeature"]]] = rest_field(name="previewFeatures") + preview_features: Optional[List[Union[str, "_models.PreviewFeature"]]] = rest_field( + name="previewFeatures", visibility=["read", "create", "update", "delete", "query"] + ) """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.""" + auth_config: Optional["_models.AuthConfigProperties"] = rest_field( + name="authConfig", visibility=["read", "create", "update", "delete", "query"] + ) + """The authentication configuration for the cluster.""" @overload def __init__( @@ -660,33 +868,36 @@ def __init__( sharding: Optional["_models.ShardingProperties"] = None, compute: Optional["_models.ComputeProperties"] = None, backup: Optional["_models.BackupProperties"] = None, + data_api: Optional["_models.DataApiProperties"] = None, preview_features: Optional[List[Union[str, "_models.PreviewFeature"]]] = None, - ): ... + auth_config: Optional["_models.AuthConfigProperties"] = None, + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class MongoClusterReplicaParameters(_model_base.Model): +class MongoClusterReplicaParameters(_Model): """Parameters used for replica operations. - :ivar source_resource_id: The id of the replication source cluster. Required. :vartype source_resource_id: str :ivar source_location: The location of the source cluster. Required. :vartype source_location: str """ - source_resource_id: str = rest_field(name="sourceResourceId") + source_resource_id: str = rest_field( + name="sourceResourceId", visibility=["read", "create", "update", "delete", "query"] + ) """The id of the replication source cluster. Required.""" - source_location: str = rest_field(name="sourceLocation") + source_location: str = rest_field(name="sourceLocation", visibility=["read", "create", "update", "delete", "query"]) """The location of the source cluster. Required.""" @overload @@ -695,20 +906,20 @@ def __init__( *, source_resource_id: str, source_location: str, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class MongoClusterRestoreParameters(_model_base.Model): +class MongoClusterRestoreParameters(_Model): """Parameters used for restore operations. :ivar point_in_time_utc: UTC point in time to restore a mongo cluster. @@ -717,9 +928,13 @@ class MongoClusterRestoreParameters(_model_base.Model): :vartype source_resource_id: str """ - point_in_time_utc: Optional[datetime.datetime] = rest_field(name="pointInTimeUTC", format="rfc3339") + point_in_time_utc: Optional[datetime.datetime] = rest_field( + name="pointInTimeUTC", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """UTC point in time to restore a mongo cluster.""" - source_resource_id: Optional[str] = rest_field(name="sourceResourceId") + source_resource_id: Optional[str] = rest_field( + name="sourceResourceId", visibility=["read", "create", "update", "delete", "query"] + ) """Resource ID to locate the source cluster to restore.""" @overload @@ -728,20 +943,20 @@ def __init__( *, point_in_time_utc: Optional[datetime.datetime] = None, source_resource_id: Optional[str] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class MongoClusterUpdate(_model_base.Model): +class MongoClusterUpdate(_Model): """The type used for update operations of the MongoCluster. :ivar tags: Resource tags. @@ -750,9 +965,11 @@ class MongoClusterUpdate(_model_base.Model): :vartype properties: ~azure.mgmt.mongocluster.models.MongoClusterUpdateProperties """ - tags: Optional[Dict[str, str]] = rest_field() + tags: Optional[Dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Resource tags.""" - properties: Optional["_models.MongoClusterUpdateProperties"] = rest_field() + properties: Optional["_models.MongoClusterUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The resource-specific properties for this resource.""" @overload @@ -761,20 +978,20 @@ def __init__( *, tags: Optional[Dict[str, str]] = None, properties: Optional["_models.MongoClusterUpdateProperties"] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class MongoClusterUpdateProperties(_model_base.Model): +class MongoClusterUpdateProperties(_Model): """The updatable properties of the MongoCluster. :ivar administrator: The local administrator properties for the mongo cluster. @@ -795,29 +1012,59 @@ class MongoClusterUpdateProperties(_model_base.Model): :vartype compute: ~azure.mgmt.mongocluster.models.ComputeProperties :ivar backup: The backup properties of the mongo cluster. :vartype backup: ~azure.mgmt.mongocluster.models.BackupProperties + :ivar data_api: The Data API properties of the mongo cluster. + :vartype data_api: ~azure.mgmt.mongocluster.models.DataApiProperties :ivar preview_features: List of private endpoint connections. :vartype preview_features: list[str or ~azure.mgmt.mongocluster.models.PreviewFeature] + :ivar auth_config: The authentication configuration for the cluster. + :vartype auth_config: ~azure.mgmt.mongocluster.models.AuthConfigProperties """ - administrator: Optional["_models.AdministratorProperties"] = rest_field() + administrator: Optional["_models.AdministratorProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The local administrator properties for the mongo cluster.""" - server_version: Optional[str] = rest_field(name="serverVersion") + server_version: Optional[str] = rest_field( + name="serverVersion", visibility=["read", "create", "update", "delete", "query"] + ) """The Mongo DB server version. Defaults to the latest available version if not specified.""" - public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = rest_field(name="publicNetworkAccess") + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = rest_field( + name="publicNetworkAccess", visibility=["read", "create", "update", "delete", "query"] + ) """Whether or not public endpoint access is allowed for this mongo cluster. Known values are: \"Enabled\" and \"Disabled\".""" - high_availability: Optional["_models.HighAvailabilityProperties"] = rest_field(name="highAvailability") + high_availability: Optional["_models.HighAvailabilityProperties"] = rest_field( + name="highAvailability", visibility=["read", "create", "update", "delete", "query"] + ) """The high availability properties of the mongo cluster.""" - storage: Optional["_models.StorageProperties"] = rest_field() + storage: Optional["_models.StorageProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The storage properties of the mongo cluster.""" - sharding: Optional["_models.ShardingProperties"] = rest_field() + sharding: Optional["_models.ShardingProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The sharding properties of the mongo cluster.""" - compute: Optional["_models.ComputeProperties"] = rest_field() + compute: Optional["_models.ComputeProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The compute properties of the mongo cluster.""" - backup: Optional["_models.BackupProperties"] = rest_field() + backup: Optional["_models.BackupProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The backup properties of the mongo cluster.""" - preview_features: Optional[List[Union[str, "_models.PreviewFeature"]]] = rest_field(name="previewFeatures") + data_api: Optional["_models.DataApiProperties"] = rest_field( + name="dataApi", visibility=["read", "create", "update", "delete", "query"] + ) + """The Data API properties of the mongo cluster.""" + preview_features: Optional[List[Union[str, "_models.PreviewFeature"]]] = rest_field( + name="previewFeatures", visibility=["read", "create", "update", "delete", "query"] + ) """List of private endpoint connections.""" + auth_config: Optional["_models.AuthConfigProperties"] = rest_field( + name="authConfig", visibility=["read", "create", "update", "delete", "query"] + ) + """The authentication configuration for the cluster.""" @overload def __init__( @@ -831,24 +1078,24 @@ def __init__( sharding: Optional["_models.ShardingProperties"] = None, compute: Optional["_models.ComputeProperties"] = None, backup: Optional["_models.BackupProperties"] = None, + data_api: Optional["_models.DataApiProperties"] = None, preview_features: Optional[List[Union[str, "_models.PreviewFeature"]]] = None, - ): ... + auth_config: Optional["_models.AuthConfigProperties"] = None, + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class Operation(_model_base.Model): - """Details of a REST API operation, returned from the Resource Provider Operations API. - - Readonly variables are only populated by the server, and will be ignored when sending a request. +class Operation(_Model): + """REST API Operation. :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". @@ -874,13 +1121,15 @@ class Operation(_model_base.Model): is_data_action: Optional[bool] = rest_field(name="isDataAction", visibility=["read"]) """Whether the operation applies to data-plane. This is \"true\" for data-plane operations and \"false\" for Azure Resource Manager/control-plane operations.""" - display: Optional["_models.OperationDisplay"] = rest_field(visibility=["read"]) + display: Optional["_models.OperationDisplay"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Localized display information for this particular operation.""" origin: Optional[Union[str, "_models.Origin"]] = rest_field(visibility=["read"]) """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is \"user,system\". Known values are: \"user\", \"system\", and \"user,system\".""" - action_type: Optional[Union[str, "_models.ActionType"]] = rest_field(name="actionType") + action_type: Optional[Union[str, "_models.ActionType"]] = rest_field(name="actionType", visibility=["read"]) """Extensible enum. Indicates the action type. \"Internal\" refers to actions that are for internal only APIs. \"Internal\"""" @@ -888,25 +1137,23 @@ class Operation(_model_base.Model): def __init__( self, *, - action_type: Optional[Union[str, "_models.ActionType"]] = None, - ): ... + display: Optional["_models.OperationDisplay"] = None, + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class OperationDisplay(_model_base.Model): +class OperationDisplay(_Model): """Localized display information for and operation. - Readonly variables are only populated by the server, and will be ignored when sending a request. - :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". :vartype provider: str @@ -935,26 +1182,22 @@ class OperationDisplay(_model_base.Model): views.""" -class PrivateEndpoint(_model_base.Model): - """The Private Endpoint resource. +class PrivateEndpoint(_Model): + """The private endpoint resource. - Readonly variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource identifier for private endpoint. + :ivar id: The resource identifier of the private endpoint. :vartype id: str """ id: Optional[str] = rest_field(visibility=["read"]) - """The resource identifier for private endpoint.""" + """The resource identifier of the private endpoint.""" class PrivateEndpointConnection(Resource): """The private endpoint connection resource. - 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 + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -968,7 +1211,9 @@ class PrivateEndpointConnection(Resource): :vartype properties: ~azure.mgmt.mongocluster.models.PrivateEndpointConnectionProperties """ - properties: Optional["_models.PrivateEndpointConnectionProperties"] = rest_field() + properties: Optional["_models.PrivateEndpointConnectionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The private endpoint connection properties.""" @overload @@ -976,25 +1221,22 @@ def __init__( self, *, properties: Optional["_models.PrivateEndpointConnectionProperties"] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class PrivateEndpointConnectionProperties(_model_base.Model): +class PrivateEndpointConnectionProperties(_Model): """Properties of the private endpoint connection. - Readonly variables are only populated by the server, and will be ignored when sending a request. - - :ivar group_ids: The group ids for the private endpoint resource. :vartype group_ids: list[str] :ivar private_endpoint: The private endpoint resource. @@ -1011,10 +1253,12 @@ class PrivateEndpointConnectionProperties(_model_base.Model): group_ids: Optional[List[str]] = rest_field(name="groupIds", visibility=["read"]) """The group ids for the private endpoint resource.""" - private_endpoint: Optional["_models.PrivateEndpoint"] = rest_field(name="privateEndpoint") + private_endpoint: Optional["_models.PrivateEndpoint"] = rest_field( + name="privateEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) """The private endpoint resource.""" private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState" = rest_field( - name="privateLinkServiceConnectionState" + name="privateLinkServiceConnectionState", visibility=["read", "create", "update", "delete", "query"] ) """A collection of information about the state of the connection between service consumer and provider. Required.""" @@ -1030,16 +1274,16 @@ def __init__( *, private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState", private_endpoint: Optional["_models.PrivateEndpoint"] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -1047,10 +1291,8 @@ class PrivateEndpointConnectionResource(ProxyResource): """Concrete proxy resource types can be created by aliasing this type using a specific property type. - 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 + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1064,7 +1306,9 @@ class PrivateEndpointConnectionResource(ProxyResource): :vartype properties: ~azure.mgmt.mongocluster.models.PrivateEndpointConnectionProperties """ - properties: Optional["_models.PrivateEndpointConnectionProperties"] = rest_field() + properties: Optional["_models.PrivateEndpointConnectionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The resource-specific properties for this resource.""" @overload @@ -1072,16 +1316,16 @@ def __init__( self, *, properties: Optional["_models.PrivateEndpointConnectionProperties"] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -1089,10 +1333,8 @@ class PrivateLinkResource(ProxyResource): """Concrete proxy resource types can be created by aliasing this type using a specific property type. - 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 + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1106,7 +1348,9 @@ class PrivateLinkResource(ProxyResource): :vartype properties: ~azure.mgmt.mongocluster.models.PrivateLinkResourceProperties """ - properties: Optional["_models.PrivateLinkResourceProperties"] = rest_field() + properties: Optional["_models.PrivateLinkResourceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The resource-specific properties for this resource.""" @overload @@ -1114,24 +1358,22 @@ def __init__( self, *, properties: Optional["_models.PrivateLinkResourceProperties"] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class PrivateLinkResourceProperties(_model_base.Model): +class PrivateLinkResourceProperties(_Model): """Properties of a private link resource. - Readonly variables are only populated by the server, and will be ignored when sending a request. - :ivar group_id: The private link resource group id. :vartype group_id: str :ivar required_members: The private link resource required member names. @@ -1144,7 +1386,9 @@ class PrivateLinkResourceProperties(_model_base.Model): """The private link resource group id.""" required_members: Optional[List[str]] = rest_field(name="requiredMembers", visibility=["read"]) """The private link resource required member names.""" - required_zone_names: Optional[List[str]] = rest_field(name="requiredZoneNames") + required_zone_names: Optional[List[str]] = rest_field( + name="requiredZoneNames", visibility=["read", "create", "update", "delete", "query"] + ) """The private link resource private link DNS zone name.""" @overload @@ -1152,20 +1396,20 @@ def __init__( self, *, required_zone_names: Optional[List[str]] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class PrivateLinkServiceConnectionState(_model_base.Model): +class PrivateLinkServiceConnectionState(_Model): """A collection of information about the state of the connection between service consumer and provider. @@ -1179,12 +1423,16 @@ class PrivateLinkServiceConnectionState(_model_base.Model): :vartype actions_required: str """ - status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = rest_field() + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. Known values are: \"Pending\", \"Approved\", and \"Rejected\".""" - description: Optional[str] = rest_field() + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The reason for approval/rejection of the connection.""" - actions_required: Optional[str] = rest_field(name="actionsRequired") + actions_required: Optional[str] = rest_field( + name="actionsRequired", visibility=["read", "create", "update", "delete", "query"] + ) """A message indicating if changes on the service provider require any updates on the consumer.""" @overload @@ -1194,24 +1442,22 @@ def __init__( status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, description: Optional[str] = None, actions_required: Optional[str] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class PromoteReplicaRequest(_model_base.Model): +class PromoteReplicaRequest(_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 @@ -1219,9 +1465,13 @@ class PromoteReplicaRequest(_model_base.Model): :vartype mode: str or ~azure.mgmt.mongocluster.models.PromoteMode """ - promote_option: Union[str, "_models.PromoteOption"] = rest_field(name="promoteOption") + promote_option: Union[str, "_models.PromoteOption"] = rest_field( + name="promoteOption", visibility=["read", "create", "update", "delete", "query"] + ) """The promote option to apply to the operation. Required. \"Forced\"""" - mode: Optional[Union[str, "_models.PromoteMode"]] = rest_field() + mode: Optional[Union[str, "_models.PromoteMode"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The mode to apply to the promote operation. Value is optional and default value is 'Switchover'. \"Switchover\"""" @@ -1231,26 +1481,24 @@ def __init__( *, promote_option: Union[str, "_models.PromoteOption"], mode: Optional[Union[str, "_models.PromoteMode"]] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: 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 + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1264,7 +1512,9 @@ class Replica(ProxyResource): :vartype properties: ~azure.mgmt.mongocluster.models.MongoClusterProperties """ - properties: Optional["_models.MongoClusterProperties"] = rest_field() + properties: Optional["_models.MongoClusterProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The resource-specific properties for this resource.""" @overload @@ -1272,24 +1522,22 @@ def __init__( self, *, properties: Optional["_models.MongoClusterProperties"] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class ReplicationProperties(_model_base.Model): +class ReplicationProperties(_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", @@ -1312,7 +1560,7 @@ class ReplicationProperties(_model_base.Model): \"Provisioning\", \"Updating\", \"Broken\", and \"Reconfiguring\".""" -class ShardingProperties(_model_base.Model): +class ShardingProperties(_Model): """The sharding properties of the cluster. This includes the shard count and scaling options for the cluster. @@ -1320,7 +1568,9 @@ class ShardingProperties(_model_base.Model): :vartype shard_count: int """ - shard_count: Optional[int] = rest_field(name="shardCount") + shard_count: Optional[int] = rest_field( + name="shardCount", visibility=["read", "create", "update", "delete", "query"] + ) """Number of shards to provision on the cluster.""" @overload @@ -1328,49 +1578,71 @@ def __init__( self, *, shard_count: Optional[int] = None, - ): ... + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class StorageProperties(_model_base.Model): +class StorageProperties(_Model): """The storage properties of the cluster. This includes the data storage size and scaling applied to servers in the cluster. :ivar size_gb: The size of the data disk assigned to each server. :vartype size_gb: int + :ivar type: The type of storage to provision the cluster servers with. Known values are: + "PremiumSSD" and "PremiumSSDv2". + :vartype type: str or ~azure.mgmt.mongocluster.models.StorageType + :ivar iops: The IOPs of the storage assigned to each server. Only applicable if the type is + 'PremiumSSDv2'. + :vartype iops: int + :ivar throughput: The throughput of the storage assigned to each server. Only applicable if the + type is 'PremiumSSDv2'. + :vartype throughput: int """ - size_gb: Optional[int] = rest_field(name="sizeGb") + size_gb: Optional[int] = rest_field(name="sizeGb", visibility=["read", "create", "update", "delete", "query"]) """The size of the data disk assigned to each server.""" + type: Optional[Union[str, "_models.StorageType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The type of storage to provision the cluster servers with. Known values are: \"PremiumSSD\" and + \"PremiumSSDv2\".""" + iops: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The IOPs of the storage assigned to each server. Only applicable if the type is 'PremiumSSDv2'.""" + throughput: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The throughput of the storage assigned to each server. Only applicable if the type is + 'PremiumSSDv2'.""" @overload def __init__( self, *, size_gb: Optional[int] = None, - ): ... + type: Optional[Union[str, "_models.StorageType"]] = None, + iops: Optional[int] = None, + throughput: Optional[int] = None, + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class SystemData(_model_base.Model): +class SystemData(_Model): """Metadata pertaining to creation and last modification of the resource. :ivar created_by: The identity that created the resource. @@ -1389,19 +1661,29 @@ class SystemData(_model_base.Model): :vartype last_modified_at: ~datetime.datetime """ - created_by: Optional[str] = rest_field(name="createdBy") + created_by: Optional[str] = rest_field(name="createdBy", visibility=["read", "create", "update", "delete", "query"]) """The identity that created the resource.""" - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field(name="createdByType") + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="createdByType", visibility=["read", "create", "update", "delete", "query"] + ) """The type of identity that created the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" - created_at: Optional[datetime.datetime] = rest_field(name="createdAt", format="rfc3339") + created_at: Optional[datetime.datetime] = rest_field( + name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """The timestamp of resource creation (UTC).""" - last_modified_by: Optional[str] = rest_field(name="lastModifiedBy") + last_modified_by: Optional[str] = rest_field( + name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] + ) """The identity that last modified the resource.""" - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field(name="lastModifiedByType") + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] + ) """The type of identity that last modified the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" - last_modified_at: Optional[datetime.datetime] = rest_field(name="lastModifiedAt", format="rfc3339") + last_modified_at: Optional[datetime.datetime] = rest_field( + name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """The timestamp of resource last modification (UTC).""" @overload @@ -1414,14 +1696,100 @@ def __init__( last_modified_by: Optional[str] = None, last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, - ): ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class User(ProxyResource): + """Represents a Mongo cluster user. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar 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.UserProperties + """ + + properties: Optional["_models.UserProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The resource-specific properties for this resource.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.UserProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UserProperties(_Model): + """Definition of Mongo user resource on a cluster. + + :ivar provisioning_state: The provisioning state of the user. Known values are: "Succeeded", + "Failed", "Canceled", "InProgress", "Updating", and "Dropping". + :vartype provisioning_state: str or ~azure.mgmt.mongocluster.models.ProvisioningState + :ivar identity_provider: The user's identity provider definition. + :vartype identity_provider: ~azure.mgmt.mongocluster.models.IdentityProvider + :ivar roles: Database roles that are assigned to the user. + :vartype roles: list[~azure.mgmt.mongocluster.models.DatabaseRole] + """ + + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """The provisioning state of the user. Known values are: \"Succeeded\", \"Failed\", \"Canceled\", + \"InProgress\", \"Updating\", and \"Dropping\".""" + identity_provider: Optional["_models.IdentityProvider"] = rest_field( + name="identityProvider", visibility=["read", "create", "update", "delete", "query"] + ) + """The user's identity provider definition.""" + roles: Optional[List["_models.DatabaseRole"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Database roles that are assigned to the user.""" + + @overload + def __init__( + self, + *, + identity_provider: Optional["_models.IdentityProvider"] = None, + roles: Optional[List["_models.DatabaseRole"]] = None, + ) -> None: ... @overload - def __init__(self, mapping: Mapping[str, Any]): + def __init__(self, mapping: Mapping[str, Any]) -> None: """ :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 + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/models/_patch.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/models/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/models/_patch.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/models/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize 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 c2fa532ddd59..67346bccc6ff 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 @@ -5,16 +5,23 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._operations import Operations -from ._operations import MongoClustersOperations -from ._operations import FirewallRulesOperations -from ._operations import PrivateEndpointConnectionsOperations -from ._operations import PrivateLinksOperations -from ._operations import ReplicasOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import Operations # type: ignore +from ._operations import MongoClustersOperations # type: ignore +from ._operations import FirewallRulesOperations # type: ignore +from ._operations import PrivateEndpointConnectionsOperations # type: ignore +from ._operations import PrivateLinksOperations # type: ignore +from ._operations import ReplicasOperations # type: ignore +from ._operations import UsersOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -24,6 +31,7 @@ "PrivateEndpointConnectionsOperations", "PrivateLinksOperations", "ReplicasOperations", + "UsersOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _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 d5b197cabcde..eea06ad78bdd 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,12 +6,13 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase import json -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -32,17 +33,14 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._model_base import SdkJSONEncoder, _deserialize -from .._serialization import Serializer +from .._configuration import MongoClusterMgmtClientConfiguration +from .._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from .._utils.serialization import Deserializer, Serializer from .._validation import api_version_validation -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +JSON = MutableMapping[str, Any] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False @@ -52,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -73,11 +71,11 @@ 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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -102,11 +100,11 @@ 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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -133,11 +131,11 @@ 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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -163,11 +161,11 @@ 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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -191,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -216,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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -242,11 +240,11 @@ 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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/listConnectionStrings" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/listConnectionStrings" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -271,11 +269,11 @@ 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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/checkMongoClusterNameAvailability" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/locations/{location}/checkMongoClusterNameAvailability" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "location": _SERIALIZER.url("location", location, "str"), @@ -301,11 +299,11 @@ def build_mongo_clusters_promote_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-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 + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/promote" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -331,11 +329,11 @@ def build_firewall_rules_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/firewallRules/{firewallRuleName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/firewallRules/{firewallRuleName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -361,11 +359,11 @@ 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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/firewallRules/{firewallRuleName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/firewallRules/{firewallRuleName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -392,11 +390,11 @@ 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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/firewallRules/{firewallRuleName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/firewallRules/{firewallRuleName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -421,11 +419,11 @@ 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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/firewallRules" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/firewallRules" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -449,11 +447,11 @@ 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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateEndpointConnections" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateEndpointConnections" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -481,11 +479,11 @@ 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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateEndpointConnections/{privateEndpointConnectionName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateEndpointConnections/{privateEndpointConnectionName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -517,11 +515,11 @@ 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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateEndpointConnections/{privateEndpointConnectionName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateEndpointConnections/{privateEndpointConnectionName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -554,11 +552,11 @@ 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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateEndpointConnections/{privateEndpointConnectionName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateEndpointConnections/{privateEndpointConnectionName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -585,11 +583,11 @@ 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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateLinkResources" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/privateLinkResources" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -613,11 +611,129 @@ def build_replicas_list_by_parent_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-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-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 + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/replicas" + 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) + + +def build_users_get_request( + resource_group_name: str, mongo_cluster_name: str, user_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/users/{userName}" + 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"), + "userName": _SERIALIZER.url("user_name", user_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) + + +def build_users_create_or_update_request( + resource_group_name: str, mongo_cluster_name: str, user_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", "2025-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/users/{userName}" + 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"), + "userName": _SERIALIZER.url("user_name", user_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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_users_delete_request( + resource_group_name: str, mongo_cluster_name: str, user_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/users/{userName}" + 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"), + "userName": _SERIALIZER.url("user_name", user_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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_users_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", "2025-04-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/mongoClusters/{mongoClusterName}/users" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -645,17 +761,14 @@ class Operations: :attr:`operations` attribute. """ - def __init__(self, *args, **kwargs): + 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") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MongoClusterMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """List the operations for the provider. @@ -668,7 +781,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -715,7 +828,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Operation], deserialized["value"]) + list_of_elem = _deserialize(List[_models.Operation], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -731,7 +844,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -749,17 +862,14 @@ class MongoClustersOperations: :attr:`mongo_clusters` attribute. """ - def __init__(self, *args, **kwargs): + 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") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MongoClusterMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any) -> _models.MongoCluster: """Gets information about a mongo cluster. @@ -772,7 +882,7 @@ def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any) :rtype: ~azure.mgmt.mongocluster.models.MongoCluster :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -812,7 +922,7 @@ def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any) except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if _stream: @@ -825,9 +935,6 @@ def get(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any) return deserialized # type: ignore - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def _create_or_update_initial( self, resource_group_name: str, @@ -835,7 +942,7 @@ def _create_or_update_initial( resource: Union[_models.MongoCluster, JSON, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -884,7 +991,7 @@ def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -986,9 +1093,6 @@ def begin_create_or_update( """ @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def begin_create_or_update( self, resource_group_name: str, @@ -1064,9 +1168,6 @@ 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-06-01-preview": ["base_url"]}, - ) def _update_initial( self, resource_group_name: str, @@ -1074,7 +1175,7 @@ def _update_initial( properties: Union[_models.MongoClusterUpdate, JSON, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1123,7 +1224,7 @@ def _update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -1226,9 +1327,6 @@ def begin_update( """ @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def begin_update( self, resource_group_name: str, @@ -1304,11 +1402,8 @@ 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-06-01-preview": ["base_url"]}, - ) def _delete_initial(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1347,7 +1442,7 @@ def _delete_initial(self, resource_group_name: str, mongo_cluster_name: str, **k except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -1363,9 +1458,6 @@ def _delete_initial(self, resource_group_name: str, mongo_cluster_name: str, **k return deserialized # type: ignore @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def begin_delete(self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a mongo cluster. @@ -1423,9 +1515,6 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) 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. @@ -1441,7 +1530,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite cls: ClsType[List[_models.MongoCluster]] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1490,7 +1579,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.MongoCluster], deserialized["value"]) + list_of_elem = _deserialize(List[_models.MongoCluster], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -1506,7 +1595,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -1514,9 +1603,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def list(self, **kwargs: Any) -> Iterable["_models.MongoCluster"]: """List all the mongo clusters in a given subscription. @@ -1529,7 +1615,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.MongoCluster"]: cls: ClsType[List[_models.MongoCluster]] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1577,7 +1663,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.MongoCluster], deserialized["value"]) + list_of_elem = _deserialize(List[_models.MongoCluster], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -1593,7 +1679,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -1601,9 +1687,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def list_connection_strings( self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any ) -> _models.ListConnectionStringsResult: @@ -1620,7 +1703,7 @@ def list_connection_strings( :rtype: ~azure.mgmt.mongocluster.models.ListConnectionStringsResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1660,7 +1743,7 @@ def list_connection_strings( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if _stream: @@ -1736,9 +1819,6 @@ def check_name_availability( """ @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def check_name_availability( self, location: str, body: Union[_models.CheckNameAvailabilityRequest, JSON, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResponse: @@ -1754,7 +1834,7 @@ def check_name_availability( :rtype: ~azure.mgmt.mongocluster.models.CheckNameAvailabilityResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1803,7 +1883,7 @@ def check_name_availability( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if _stream: @@ -1820,7 +1900,6 @@ def check_name_availability( method_added_on="2024-06-01-preview", params_added_on={ "2024-06-01-preview": [ - "base_url", "api_version", "subscription_id", "resource_group_name", @@ -1837,7 +1916,7 @@ def _promote_initial( body: Union[_models.PromoteReplicaRequest, JSON, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1886,7 +1965,7 @@ def _promote_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -1986,7 +2065,6 @@ def begin_promote( method_added_on="2024-06-01-preview", params_added_on={ "2024-06-01-preview": [ - "base_url", "api_version", "subscription_id", "resource_group_name", @@ -2075,17 +2153,14 @@ class FirewallRulesOperations: :attr:`firewall_rules` attribute. """ - def __init__(self, *args, **kwargs): + 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") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MongoClusterMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def get( self, resource_group_name: str, mongo_cluster_name: str, firewall_rule_name: str, **kwargs: Any ) -> _models.FirewallRule: @@ -2102,7 +2177,7 @@ def get( :rtype: ~azure.mgmt.mongocluster.models.FirewallRule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2143,7 +2218,7 @@ def get( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if _stream: @@ -2156,9 +2231,6 @@ def get( return deserialized # type: ignore - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def _create_or_update_initial( self, resource_group_name: str, @@ -2167,7 +2239,7 @@ def _create_or_update_initial( resource: Union[_models.FirewallRule, JSON, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2217,7 +2289,7 @@ def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -2326,9 +2398,6 @@ def begin_create_or_update( """ @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def begin_create_or_update( self, resource_group_name: str, @@ -2407,13 +2476,10 @@ 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-06-01-preview": ["base_url"]}, - ) def _delete_initial( self, resource_group_name: str, mongo_cluster_name: str, firewall_rule_name: str, **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2453,7 +2519,7 @@ def _delete_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -2469,9 +2535,6 @@ def _delete_initial( return deserialized # type: ignore @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def begin_delete( self, resource_group_name: str, mongo_cluster_name: str, firewall_rule_name: str, **kwargs: Any ) -> LROPoller[None]: @@ -2534,9 +2597,6 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def list_by_mongo_cluster( self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any ) -> Iterable["_models.FirewallRule"]: @@ -2556,7 +2616,7 @@ def list_by_mongo_cluster( cls: ClsType[List[_models.FirewallRule]] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2606,7 +2666,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.FirewallRule], deserialized["value"]) + list_of_elem = _deserialize(List[_models.FirewallRule], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -2622,7 +2682,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -2640,17 +2700,14 @@ class PrivateEndpointConnectionsOperations: :attr:`private_endpoint_connections` attribute. """ - def __init__(self, *args, **kwargs): + 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") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MongoClusterMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def list_by_mongo_cluster( self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any ) -> Iterable["_models.PrivateEndpointConnectionResource"]: @@ -2671,7 +2728,7 @@ def list_by_mongo_cluster( cls: ClsType[List[_models.PrivateEndpointConnectionResource]] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2721,7 +2778,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.PrivateEndpointConnectionResource], deserialized["value"]) + list_of_elem = _deserialize(List[_models.PrivateEndpointConnectionResource], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -2737,7 +2794,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -2745,9 +2802,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def get( self, resource_group_name: str, mongo_cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnectionResource: @@ -2766,7 +2820,7 @@ def get( :rtype: ~azure.mgmt.mongocluster.models.PrivateEndpointConnectionResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2807,7 +2861,7 @@ def get( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if _stream: @@ -2820,9 +2874,6 @@ def get( return deserialized # type: ignore - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def _create_initial( self, resource_group_name: str, @@ -2831,7 +2882,7 @@ def _create_initial( resource: Union[_models.PrivateEndpointConnectionResource, JSON, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2881,7 +2932,7 @@ def _create_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -2996,9 +3047,6 @@ def begin_create( """ @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def begin_create( self, resource_group_name: str, @@ -3084,13 +3132,10 @@ 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-06-01-preview": ["base_url"]}, - ) def _delete_initial( self, resource_group_name: str, mongo_cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3130,7 +3175,7 @@ def _delete_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -3146,9 +3191,6 @@ def _delete_initial( return deserialized # type: ignore @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def begin_delete( self, resource_group_name: str, mongo_cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> LROPoller[None]: @@ -3222,17 +3264,14 @@ class PrivateLinksOperations: :attr:`private_links` attribute. """ - def __init__(self, *args, **kwargs): + 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") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MongoClusterMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - @api_version_validation( - params_added_on={"2024-06-01-preview": ["base_url"]}, - ) def list_by_mongo_cluster( self, resource_group_name: str, mongo_cluster_name: str, **kwargs: Any ) -> Iterable["_models.PrivateLinkResource"]: @@ -3252,7 +3291,7 @@ def list_by_mongo_cluster( cls: ClsType[List[_models.PrivateLinkResource]] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3302,7 +3341,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.PrivateLinkResource], deserialized["value"]) + list_of_elem = _deserialize(List[_models.PrivateLinkResource], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -3318,7 +3357,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -3336,19 +3375,18 @@ class ReplicasOperations: :attr:`replicas` attribute. """ - def __init__(self, *args, **kwargs): + 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") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MongoClusterMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace @api_version_validation( method_added_on="2024-06-01-preview", params_added_on={ "2024-06-01-preview": [ - "base_url", "api_version", "subscription_id", "resource_group_name", @@ -3376,7 +3414,7 @@ def list_by_parent( cls: ClsType[List[_models.Replica]] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3426,7 +3464,626 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Replica], deserialized["value"]) + list_of_elem = _deserialize(List[_models.Replica], deserialized.get("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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class UsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mongocluster.MongoClusterMgmtClient`'s + :attr:`users` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: MongoClusterMgmtClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "user_name", + "accept", + ] + }, + ) + def get(self, resource_group_name: str, mongo_cluster_name: str, user_name: str, **kwargs: Any) -> _models.User: + """Gets the defintion of a Mongo cluster user. + + :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 user_name: The name of the mongo cluster user. Required. + :type user_name: str + :return: User. The User is compatible with MutableMapping + :rtype: ~azure.mgmt.mongocluster.models.User + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.User] = kwargs.pop("cls", None) + + _request = build_users_get_request( + resource_group_name=resource_group_name, + mongo_cluster_name=mongo_cluster_name, + user_name=user_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.User, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "user_name", + "content_type", + "accept", + ] + }, + ) + def _create_or_update_initial( + self, + resource_group_name: str, + mongo_cluster_name: str, + user_name: str, + resource: Union[_models.User, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = 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(resource, (IOBase, bytes)): + _content = resource + else: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_users_create_or_update_request( + resource_group_name=resource_group_name, + mongo_cluster_name=mongo_cluster_name, + user_name=user_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + 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_create_or_update( + self, + resource_group_name: str, + mongo_cluster_name: str, + user_name: str, + resource: _models.User, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user on a 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 + :param user_name: The name of the mongo cluster user. Required. + :type user_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.mongocluster.models.User + :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 User. The User is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mongocluster.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + mongo_cluster_name: str, + user_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user on a 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 + :param user_name: The name of the mongo cluster user. Required. + :type user_name: str + :param resource: Resource create parameters. Required. + :type resource: 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 User. The User is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mongocluster.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + mongo_cluster_name: str, + user_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user on a 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 + :param user_name: The name of the mongo cluster user. Required. + :type user_name: str + :param resource: Resource create parameters. Required. + :type resource: 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 User. The User is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mongocluster.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "user_name", + "content_type", + "accept", + ] + }, + ) + def begin_create_or_update( + self, + resource_group_name: str, + mongo_cluster_name: str, + user_name: str, + resource: Union[_models.User, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.User]: + """Creates a new user or updates an existing user on a 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 + :param user_name: The name of the mongo cluster user. Required. + :type user_name: str + :param resource: Resource create parameters. Is one of the following types: User, JSON, + IO[bytes] Required. + :type resource: ~azure.mgmt.mongocluster.models.User or JSON or IO[bytes] + :return: An instance of LROPoller that returns User. The User is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mongocluster.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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[_models.User] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + mongo_cluster_name=mongo_cluster_name, + user_name=user_name, + resource=resource, + 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): + response = pipeline_response.http_response + deserialized = _deserialize(_models.User, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.User].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.User]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "user_name", + "accept", + ] + }, + ) + def _delete_initial( + self, resource_group_name: str, mongo_cluster_name: str, user_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_users_delete_request( + resource_group_name=resource_group_name, + mongo_cluster_name=mongo_cluster_name, + user_name=user_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "mongo_cluster_name", + "user_name", + "accept", + ] + }, + ) + def begin_delete( + self, resource_group_name: str, mongo_cluster_name: str, user_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a mongo cluster user. + + :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 user_name: The name of the mongo cluster user. Required. + :type user_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + mongo_cluster_name=mongo_cluster_name, + user_name=user_name, + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2025-04-01-preview", + params_added_on={ + "2025-04-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.User"]: + """List all the users on a 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 User + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mongocluster.models.User] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.User]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_users_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, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.User], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -3442,7 +4099,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize(_models.ErrorResponse, response.json()) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/operations/_patch.py b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/operations/_patch.py index f7dd32510333..8bcb627aa475 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/operations/_patch.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/operations/_patch.py @@ -1,7 +1,8 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_create.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_create.py index 0c9ca9ac7a68..16c3f26487b1 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_create.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_create.py @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: 2024-07-01/MongoClusters_Create.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_Create.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_create_geo_replica.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_create_geo_replica.py index 478375d13e19..285f7ccf373c 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_create_geo_replica.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_create_geo_replica.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -47,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: 2024-07-01/MongoClusters_CreateGeoReplica.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_CreateGeoReplica.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_create_pitr.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_create_pitr.py index bbc19a418909..b512a9bb0e19 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_create_pitr.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_create_pitr.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -47,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: 2024-07-01/MongoClusters_CreatePITR.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_CreatePITR.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_delete.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_delete.py index 8c9dedf1d90f..e0bded30bcb0 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_delete.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: 2024-07-01/MongoClusters_Delete.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_Delete.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_firewall_rule_create.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_firewall_rule_create.py index 8c37ec59ae62..fe8f6540654a 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_firewall_rule_create.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_firewall_rule_create.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: 2024-07-01/MongoClusters_FirewallRuleCreate.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_FirewallRuleCreate.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_firewall_rule_delete.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_firewall_rule_delete.py index 8a01ba9d6a91..14606148f450 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_firewall_rule_delete.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_firewall_rule_delete.py @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: 2024-07-01/MongoClusters_FirewallRuleDelete.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_FirewallRuleDelete.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_firewall_rule_get.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_firewall_rule_get.py index e1fa3973c747..98f33f146003 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_firewall_rule_get.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_firewall_rule_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: 2024-07-01/MongoClusters_FirewallRuleGet.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_FirewallRuleGet.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_firewall_rule_list.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_firewall_rule_list.py index 2f8d653da357..6ff56987b8b0 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_firewall_rule_list.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_firewall_rule_list.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: 2024-07-01/MongoClusters_FirewallRuleList.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_FirewallRuleList.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_force_promote_replica.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_force_promote_replica.py index 18d52b74fefa..ff74ed3abfe7 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_force_promote_replica.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_force_promote_replica.py @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: 2024-07-01/MongoClusters_ForcePromoteReplica.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_ForcePromoteReplica.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_get.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_get.py index 0aadca7b500e..9d27acaede52 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_get.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2024-07-01/MongoClusters_Get.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_Get.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_list.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_list.py index 7a526e9e56a1..c5d932195984 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_list.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_list.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: 2024-07-01/MongoClusters_List.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_List.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_list_by_resource_group.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_list_by_resource_group.py index fd3668444f5a..79d168bb0bde 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_list_by_resource_group.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_list_by_resource_group.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: 2024-07-01/MongoClusters_ListByResourceGroup.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_list_connection_strings.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_list_connection_strings.py index 7fcbf7399c6d..d8dd1d35eefb 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_list_connection_strings.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_list_connection_strings.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2024-07-01/MongoClusters_ListConnectionStrings.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_ListConnectionStrings.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_name_availability.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_name_availability.py index b346f7ce5939..9fdfbdd79458 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_name_availability.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_name_availability.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2024-07-01/MongoClusters_NameAvailability.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_NameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_name_availability_already_exists.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_name_availability_already_exists.py index d55107e72039..ccb304610322 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_name_availability_already_exists.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_name_availability_already_exists.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2024-07-01/MongoClusters_NameAvailability_AlreadyExists.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_NameAvailability_AlreadyExists.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_patch_data_api.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_patch_data_api.py new file mode 100644 index 000000000000..acdf22bba7f3 --- /dev/null +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_patch_data_api.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.mongocluster import MongoClusterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mongocluster +# USAGE + python mongo_clusters_patch_data_api.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MongoClusterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.mongo_clusters.begin_update( + resource_group_name="TestResourceGroup", + mongo_cluster_name="myMongoCluster", + properties={"properties": {"dataApi": {"mode": "Enabled"}}}, + ).result() + print(response) + + +# x-ms-original-file: 2025-04-01-preview/MongoClusters_PatchDataApi.json +if __name__ == "__main__": + main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_patch_disk_size.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_patch_disk_size.py index d5b050f071af..b7e920863e88 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_patch_disk_size.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_patch_disk_size.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: 2024-07-01/MongoClusters_PatchDiskSize.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_PatchDiskSize.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_patch_private_network_access.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_patch_private_network_access.py index 1a3e65678149..7a2874610cf4 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_patch_private_network_access.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_patch_private_network_access.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: 2024-07-01/MongoClusters_PatchPrivateNetworkAccess.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_PatchPrivateNetworkAccess.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_private_endpoint_connection_delete.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_private_endpoint_connection_delete.py index 088f48dc338a..521d1f86793a 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_private_endpoint_connection_delete.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_private_endpoint_connection_delete.py @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: 2024-07-01/MongoClusters_PrivateEndpointConnectionDelete.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_PrivateEndpointConnectionDelete.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_private_endpoint_connection_get.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_private_endpoint_connection_get.py index 4b25e0b76332..434a2ae644e9 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_private_endpoint_connection_get.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_private_endpoint_connection_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: 2024-07-01/MongoClusters_PrivateEndpointConnectionGet.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_PrivateEndpointConnectionGet.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_private_endpoint_connection_list.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_private_endpoint_connection_list.py index 875ed7c6d7f5..6122264b82b5 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_private_endpoint_connection_list.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_private_endpoint_connection_list.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: 2024-07-01/MongoClusters_PrivateEndpointConnectionList.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_PrivateEndpointConnectionList.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_private_endpoint_connection_put.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_private_endpoint_connection_put.py index 07f5a9a2bd78..6f20c90e0fa4 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_private_endpoint_connection_put.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_private_endpoint_connection_put.py @@ -41,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: 2024-07-01/MongoClusters_PrivateEndpointConnectionPut.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_PrivateEndpointConnectionPut.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_private_link_resource_list.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_private_link_resource_list.py index 2026fb4bfffe..4afea747a211 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_private_link_resource_list.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_private_link_resource_list.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: 2024-07-01/MongoClusters_PrivateLinkResourceList.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_PrivateLinkResourceList.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_replica_list.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_replica_list.py index f22f11480bd7..4559d7f18d7f 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_replica_list.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_replica_list.py @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: 2024-07-01/MongoClusters_ReplicaList.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_ReplicaList.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_reset_password.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_reset_password.py index d5eaa01866e2..153d119ca891 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_reset_password.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_reset_password.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: 2024-07-01/MongoClusters_ResetPassword.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_ResetPassword.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_update.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_update.py index 16bbc5422c0c..2776c17f712f 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_update.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_update.py @@ -49,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: 2024-07-01/MongoClusters_Update.json +# x-ms-original-file: 2025-04-01-preview/MongoClusters_Update.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_user_create_or_update.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_user_create_or_update.py new file mode 100644 index 000000000000..b7ebc1679954 --- /dev/null +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_user_create_or_update.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.mongocluster import MongoClusterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mongocluster +# USAGE + python mongo_clusters_user_create_or_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MongoClusterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.users.begin_create_or_update( + resource_group_name="TestGroup", + mongo_cluster_name="myMongoCluster", + user_name="uuuuuuuu-uuuu-uuuu-uuuu-uuuuuuuuuuuu", + resource={ + "properties": { + "identityProvider": {"properties": {"principalType": "User"}, "type": "MicrosoftEntraID"}, + "roles": [{"db": "admin", "role": "dbOwner"}], + } + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-04-01-preview/MongoClusters_UserCreateOrUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_user_delete.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_user_delete.py new file mode 100644 index 000000000000..4cc952ef463f --- /dev/null +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_user_delete.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.mongocluster import MongoClusterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mongocluster +# USAGE + python mongo_clusters_user_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MongoClusterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.users.begin_delete( + resource_group_name="TestGroup", + mongo_cluster_name="myMongoCluster", + user_name="uuuuuuuu-uuuu-uuuu-uuuu-uuuuuuuuuuuu", + ).result() + + +# x-ms-original-file: 2025-04-01-preview/MongoClusters_UserDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_user_get.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_user_get.py new file mode 100644 index 000000000000..9dd1a5bab651 --- /dev/null +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_user_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.mongocluster import MongoClusterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mongocluster +# USAGE + python mongo_clusters_user_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MongoClusterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.users.get( + resource_group_name="TestGroup", + mongo_cluster_name="myMongoCluster", + user_name="uuuuuuuu-uuuu-uuuu-uuuu-uuuuuuuuuuuu", + ) + print(response) + + +# x-ms-original-file: 2025-04-01-preview/MongoClusters_UserGet.json +if __name__ == "__main__": + main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_user_list.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_user_list.py new file mode 100644 index 000000000000..a763145cab58 --- /dev/null +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/mongo_clusters_user_list.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.mongocluster import MongoClusterMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mongocluster +# USAGE + python mongo_clusters_user_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = MongoClusterMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.users.list_by_mongo_cluster( + resource_group_name="TestGroup", + mongo_cluster_name="myMongoCluster", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2025-04-01-preview/MongoClusters_UserList.json +if __name__ == "__main__": + main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/operations_list.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/operations_list.py index 062d83ab92c3..a03d8f99f5e4 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/operations_list.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_samples/operations_list.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: 2024-07-01/Operations_List.json +# x-ms-original-file: 2025-04-01-preview/Operations_List.json if __name__ == "__main__": main() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_tests/test_mongo_cluster_mgmt_mongo_clusters_operations.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_tests/test_mongo_cluster_mgmt_mongo_clusters_operations.py index a70bf65845e6..0a1109bcb1ce 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_tests/test_mongo_cluster_mgmt_mongo_clusters_operations.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_tests/test_mongo_cluster_mgmt_mongo_clusters_operations.py @@ -41,11 +41,13 @@ def test_mongo_clusters_begin_create_or_update(self, resource_group): "name": "str", "properties": { "administrator": {"password": "str", "userName": "str"}, + "authConfig": {"allowedModes": ["str"]}, "backup": {"earliestRestoreTime": "str"}, "clusterStatus": "str", "compute": {"tier": "str"}, "connectionString": "str", "createMode": "str", + "dataApi": {"mode": "str"}, "highAvailability": {"targetMode": "str"}, "infrastructureVersion": "str", "previewFeatures": ["str"], @@ -81,7 +83,7 @@ def test_mongo_clusters_begin_create_or_update(self, resource_group): "restoreParameters": {"pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str"}, "serverVersion": "str", "sharding": {"shardCount": 0}, - "storage": {"sizeGb": 0}, + "storage": {"iops": 0, "sizeGb": 0, "throughput": 0, "type": "str"}, }, "systemData": { "createdAt": "2020-02-20 00:00:00", @@ -108,14 +110,16 @@ def test_mongo_clusters_begin_update(self, resource_group): properties={ "properties": { "administrator": {"password": "str", "userName": "str"}, + "authConfig": {"allowedModes": ["str"]}, "backup": {"earliestRestoreTime": "str"}, "compute": {"tier": "str"}, + "dataApi": {"mode": "str"}, "highAvailability": {"targetMode": "str"}, "previewFeatures": ["str"], "publicNetworkAccess": "str", "serverVersion": "str", "sharding": {"shardCount": 0}, - "storage": {"sizeGb": 0}, + "storage": {"iops": 0, "sizeGb": 0, "throughput": 0, "type": "str"}, }, "tags": {"str": "str"}, }, diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_tests/test_mongo_cluster_mgmt_mongo_clusters_operations_async.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_tests/test_mongo_cluster_mgmt_mongo_clusters_operations_async.py index 854e0d8a44d1..0806285c97cb 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/generated_tests/test_mongo_cluster_mgmt_mongo_clusters_operations_async.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_tests/test_mongo_cluster_mgmt_mongo_clusters_operations_async.py @@ -43,11 +43,13 @@ async def test_mongo_clusters_begin_create_or_update(self, resource_group): "name": "str", "properties": { "administrator": {"password": "str", "userName": "str"}, + "authConfig": {"allowedModes": ["str"]}, "backup": {"earliestRestoreTime": "str"}, "clusterStatus": "str", "compute": {"tier": "str"}, "connectionString": "str", "createMode": "str", + "dataApi": {"mode": "str"}, "highAvailability": {"targetMode": "str"}, "infrastructureVersion": "str", "previewFeatures": ["str"], @@ -83,7 +85,7 @@ async def test_mongo_clusters_begin_create_or_update(self, resource_group): "restoreParameters": {"pointInTimeUTC": "2020-02-20 00:00:00", "sourceResourceId": "str"}, "serverVersion": "str", "sharding": {"shardCount": 0}, - "storage": {"sizeGb": 0}, + "storage": {"iops": 0, "sizeGb": 0, "throughput": 0, "type": "str"}, }, "systemData": { "createdAt": "2020-02-20 00:00:00", @@ -112,14 +114,16 @@ async def test_mongo_clusters_begin_update(self, resource_group): properties={ "properties": { "administrator": {"password": "str", "userName": "str"}, + "authConfig": {"allowedModes": ["str"]}, "backup": {"earliestRestoreTime": "str"}, "compute": {"tier": "str"}, + "dataApi": {"mode": "str"}, "highAvailability": {"targetMode": "str"}, "previewFeatures": ["str"], "publicNetworkAccess": "str", "serverVersion": "str", "sharding": {"shardCount": 0}, - "storage": {"sizeGb": 0}, + "storage": {"iops": 0, "sizeGb": 0, "throughput": 0, "type": "str"}, }, "tags": {"str": "str"}, }, diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_tests/test_mongo_cluster_mgmt_users_operations.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_tests/test_mongo_cluster_mgmt_users_operations.py new file mode 100644 index 000000000000..ae9a7d77a8c1 --- /dev/null +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_tests/test_mongo_cluster_mgmt_users_operations.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.mongocluster import MongoClusterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMongoClusterMgmtUsersOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MongoClusterMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_users_get(self, resource_group): + response = self.client.users.get( + resource_group_name=resource_group.name, + mongo_cluster_name="str", + user_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_users_begin_create_or_update(self, resource_group): + response = self.client.users.begin_create_or_update( + resource_group_name=resource_group.name, + mongo_cluster_name="str", + user_name="str", + resource={ + "id": "str", + "name": "str", + "properties": { + "identityProvider": "identity_provider", + "provisioningState": "str", + "roles": [{"db": "str", "role": "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", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_users_begin_delete(self, resource_group): + response = self.client.users.begin_delete( + resource_group_name=resource_group.name, + mongo_cluster_name="str", + user_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_users_list_by_mongo_cluster(self, resource_group): + response = self.client.users.list_by_mongo_cluster( + resource_group_name=resource_group.name, + mongo_cluster_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/generated_tests/test_mongo_cluster_mgmt_users_operations_async.py b/sdk/mongocluster/azure-mgmt-mongocluster/generated_tests/test_mongo_cluster_mgmt_users_operations_async.py new file mode 100644 index 000000000000..83e10b4654dd --- /dev/null +++ b/sdk/mongocluster/azure-mgmt-mongocluster/generated_tests/test_mongo_cluster_mgmt_users_operations_async.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.mongocluster.aio import MongoClusterMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestMongoClusterMgmtUsersOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MongoClusterMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_users_get(self, resource_group): + response = await self.client.users.get( + resource_group_name=resource_group.name, + mongo_cluster_name="str", + user_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_users_begin_create_or_update(self, resource_group): + response = await ( + await self.client.users.begin_create_or_update( + resource_group_name=resource_group.name, + mongo_cluster_name="str", + user_name="str", + resource={ + "id": "str", + "name": "str", + "properties": { + "identityProvider": "identity_provider", + "provisioningState": "str", + "roles": [{"db": "str", "role": "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", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_users_begin_delete(self, resource_group): + response = await ( + await self.client.users.begin_delete( + resource_group_name=resource_group.name, + mongo_cluster_name="str", + user_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_users_list_by_mongo_cluster(self, resource_group): + response = self.client.users.list_by_mongo_cluster( + resource_group_name=resource_group.name, + mongo_cluster_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/sdk_packaging.toml b/sdk/mongocluster/azure-mgmt-mongocluster/sdk_packaging.toml index fe93999c88c1..7ddab9afcdde 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/sdk_packaging.toml +++ b/sdk/mongocluster/azure-mgmt-mongocluster/sdk_packaging.toml @@ -3,7 +3,7 @@ package_name = "azure-mgmt-mongocluster" package_nspkg = "azure-mgmt-nspkg" package_pprint_name = "Mongocluster Management" package_doc_id = "" -is_stable = true +is_stable = false is_arm = true need_msrestazure = false need_azuremgmtcore = true diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/setup.py b/sdk/mongocluster/azure-mgmt-mongocluster/setup.py index e977f9f289c3..18c42468898b 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/setup.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/setup.py @@ -49,11 +49,10 @@ url="https://github.com/Azure/azure-sdk-for-python", keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product classifiers=[ - "Development Status :: 5 - Production/Stable", + "Development Status :: 4 - Beta", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -77,7 +76,7 @@ "isodate>=0.6.1", "typing-extensions>=4.6.0", "azure-common>=1.1", - "azure-mgmt-core>=1.3.2", + "azure-mgmt-core>=1.5.0", ], - python_requires=">=3.8", + python_requires=">=3.9", ) diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/tests/test_cli_mgmt_mongocluster_lro_test.py b/sdk/mongocluster/azure-mgmt-mongocluster/tests/test_cli_mgmt_mongocluster_lro_test.py index 24e1c5fa4afe..b16765ccc8de 100644 --- a/sdk/mongocluster/azure-mgmt-mongocluster/tests/test_cli_mgmt_mongocluster_lro_test.py +++ b/sdk/mongocluster/azure-mgmt-mongocluster/tests/test_cli_mgmt_mongocluster_lro_test.py @@ -5,6 +5,7 @@ AZURE_LOCATION = "westus2" Mongo_Cluster_Name = "pythonmongoclustertest" + @pytest.mark.live_test_only class TestMgmtMongoCluster(AzureMgmtRecordedTestCase): @@ -63,4 +64,4 @@ def test_mongo_clusters_mgmt(self, resource_group): response = self.client.mongo_clusters.begin_delete( resource_group_name=resource_group.name, mongo_cluster_name=Mongo_Cluster_Name, - ).result() \ No newline at end of file + ).result() diff --git a/sdk/mongocluster/azure-mgmt-mongocluster/tsp-location.yaml b/sdk/mongocluster/azure-mgmt-mongocluster/tsp-location.yaml index 13cd4360ebd3..1e924bd2bbb4 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: f93850874010501f216ceadf19459402efd16d9e +commit: 713682507acfafd4e56645790022ae6fd18312f2 repo: Azure/azure-rest-api-specs additionalDirectories: