From 1201b6748dec55fa8bafe9ebfbec665a616280d4 Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Sat, 20 Jun 2026 14:24:45 +0000 Subject: [PATCH] Configurations: 'specification/liftrmongodb/MongoDB.Atlas.Management/tspconfig.yaml', API Version: 2026-03-01-preview, SDK Release Type: beta, and CommitSHA: '18ebae7ea8f6aefd83268aacdb1f480b24842726' in SpecRepo: 'https://github.com/Azure/azure-rest-api-specs' Pipeline run: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=6461788 Refer to https://eng.ms/docs/products/azure-developer-experience/develop/sdk-release/sdk-release-prerequisites to prepare for SDK release. --- .../azure-mgmt-mongodbatlas/CHANGELOG.md | 20 + .../azure-mgmt-mongodbatlas/MANIFEST.in | 8 +- .../azure-mgmt-mongodbatlas/README.md | 6 +- .../azure-mgmt-mongodbatlas/_metadata.json | 10 +- .../azure-mgmt-mongodbatlas/api.md | 1092 ++++++++++ .../azure-mgmt-mongodbatlas/api.metadata.yml | 3 + .../apiview-properties.json | 37 +- .../azure-mgmt-mongodbatlas/azure/__init__.py | 2 +- .../azure/mgmt/__init__.py | 2 +- .../azure/mgmt/mongodbatlas/_client.py | 36 +- .../azure/mgmt/mongodbatlas/_configuration.py | 16 +- .../azure/mgmt/mongodbatlas/_patch.py | 4 +- .../mgmt/mongodbatlas/_utils/model_base.py | 729 ++++++- .../mgmt/mongodbatlas/_utils/serialization.py | 72 +- .../azure/mgmt/mongodbatlas/_validation.py | 66 + .../azure/mgmt/mongodbatlas/_version.py | 2 +- .../azure/mgmt/mongodbatlas/aio/_client.py | 36 +- .../mgmt/mongodbatlas/aio/_configuration.py | 16 +- .../azure/mgmt/mongodbatlas/aio/_patch.py | 4 +- .../mongodbatlas/aio/operations/__init__.py | 4 + .../aio/operations/_operations.py | 1609 +++++++++++++- .../mongodbatlas/aio/operations/_patch.py | 4 +- .../mgmt/mongodbatlas/models/__init__.py | 20 + .../azure/mgmt/mongodbatlas/models/_enums.py | 21 +- .../azure/mgmt/mongodbatlas/models/_models.py | 377 +++- .../azure/mgmt/mongodbatlas/models/_patch.py | 4 +- .../mgmt/mongodbatlas/operations/__init__.py | 4 + .../mongodbatlas/operations/_operations.py | 1920 ++++++++++++++++- .../mgmt/mongodbatlas/operations/_patch.py | 4 +- ...usters_create_or_update_maximum_set_gen.py | 45 + .../clusters_delete_maximum_set_gen.py | 43 + .../clusters_get_maximum_set_gen.py | 44 + .../clusters_list_maximum_set_gen.py | 44 + .../operations_list_maximum_set_gen.py | 2 +- .../operations_list_minimum_set_gen.py | 2 +- ...ations_create_or_update_maximum_set_gen.py | 2 +- .../organizations_delete_maximum_set_gen.py | 2 +- .../organizations_get_maximum_set_gen.py | 2 +- ..._list_by_resource_group_maximum_set_gen.py | 2 +- ..._list_by_resource_group_minimum_set_gen.py | 2 +- ...ns_list_by_subscription_maximum_set_gen.py | 2 +- ...ns_list_by_subscription_minimum_set_gen.py | 2 +- .../organizations_update_maximum_set_gen.py | 2 +- ...ojects_create_or_update_maximum_set_gen.py | 44 + .../projects_delete_maximum_set_gen.py | 42 + .../projects_get_maximum_set_gen.py | 43 + ...st_cluster_tier_regions_maximum_set_gen.py | 43 + .../projects_list_maximum_set_gen.py | 43 + ...ects_tier_limit_reached_maximum_set_gen.py | 43 + ...mongo_db_atlas_mgmt_clusters_operations.py | 92 + ...db_atlas_mgmt_clusters_operations_async.py | 97 + ...mongo_db_atlas_mgmt_projects_operations.py | 110 + ...db_atlas_mgmt_projects_operations_async.py | 115 + .../azure-mgmt-mongodbatlas/pyproject.toml | 82 + .../sdk_packaging.toml | 12 - .../azure-mgmt-mongodbatlas/setup.py | 82 - .../azure-mgmt-mongodbatlas/tsp-location.yaml | 2 +- 57 files changed, 6796 insertions(+), 378 deletions(-) create mode 100644 sdk/mongodbatlas/azure-mgmt-mongodbatlas/api.md create mode 100644 sdk/mongodbatlas/azure-mgmt-mongodbatlas/api.metadata.yml create mode 100644 sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_validation.py create mode 100644 sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/clusters_create_or_update_maximum_set_gen.py create mode 100644 sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/clusters_delete_maximum_set_gen.py create mode 100644 sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/clusters_get_maximum_set_gen.py create mode 100644 sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/clusters_list_maximum_set_gen.py create mode 100644 sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_create_or_update_maximum_set_gen.py create mode 100644 sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_delete_maximum_set_gen.py create mode 100644 sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_get_maximum_set_gen.py create mode 100644 sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_list_cluster_tier_regions_maximum_set_gen.py create mode 100644 sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_list_maximum_set_gen.py create mode 100644 sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_tier_limit_reached_maximum_set_gen.py create mode 100644 sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_tests/test_mongo_db_atlas_mgmt_clusters_operations.py create mode 100644 sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_tests/test_mongo_db_atlas_mgmt_clusters_operations_async.py create mode 100644 sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_tests/test_mongo_db_atlas_mgmt_projects_operations.py create mode 100644 sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_tests/test_mongo_db_atlas_mgmt_projects_operations_async.py delete mode 100644 sdk/mongodbatlas/azure-mgmt-mongodbatlas/sdk_packaging.toml delete mode 100644 sdk/mongodbatlas/azure-mgmt-mongodbatlas/setup.py diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/CHANGELOG.md b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/CHANGELOG.md index 275b15038527..871b24f0073c 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/CHANGELOG.md +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/CHANGELOG.md @@ -1,5 +1,25 @@ # Release History +## 1.1.0b1 (2026-06-20) + +### Features Added + + - Client `MongoDBAtlasMgmtClient` added parameter `cloud_setting` in method `__init__` + - Client `MongoDBAtlasMgmtClient` added operation group `projects` + - Client `MongoDBAtlasMgmtClient` added operation group `clusters` + - Added model `Cluster` + - Added model `ClusterProperties` + - Added enum `ClusterTier` + - Added model `Project` + - Added model `ProjectLimitStatus` + - Added model `ProjectProperties` + - Added model `ProxyResource` + - Added model `RegionsByTierResponse` + - Added model `TierLimitReachedResponse` + - Added model `TierRegions` + - Added model `ClustersOperations` + - Added model `ProjectsOperations` + ## 1.0.0 (2025-07-02) ### Features Added diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/MANIFEST.in b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/MANIFEST.in index 7be80e4c3a82..a90be5866591 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/MANIFEST.in +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/MANIFEST.in @@ -1,7 +1,7 @@ -recursive-include tests *.py *.json -recursive-include samples *.py *.md include *.md -include azure/__init__.py -include azure/mgmt/__init__.py include LICENSE include azure/mgmt/mongodbatlas/py.typed +recursive-include tests *.py +recursive-include samples *.py *.md +include azure/__init__.py +include azure/mgmt/__init__.py diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/README.md b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/README.md index 27e5b41c3b50..84362f10ab2f 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/README.md +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Mongodbatlas Management Client Library. -This package has been tested with Python 3.9+. +This package has been tested with Python 3.10+. 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.9+ is required to use this package. +- Python 3.10+ 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 configuration of the following environment variables. +By default, [Microsoft Entra](https://learn.microsoft.com/entra/fundamentals/what-is-entra) 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/mongodbatlas/azure-mgmt-mongodbatlas/_metadata.json b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/_metadata.json index 5d79a28a77b3..b3d606b6ca66 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/_metadata.json +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/_metadata.json @@ -1,7 +1,11 @@ { - "apiVersion": "2025-06-01", - "commit": "fa6fa40e4b84fded374f3aff1e591fa217a82fe8", + "apiVersion": "2026-03-01-preview", + "apiVersions": { + "MongoDB.Atlas": "2026-03-01-preview" + }, + "commit": "18ebae7ea8f6aefd83268aacdb1f480b24842726", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "typespec_src": "specification/liftrmongodb/MongoDB.Atlas.Management", - "emitterVersion": "0.45.5" + "emitterVersion": "0.63.1", + "httpClientPythonVersion": "^0.32.0" } \ No newline at end of file diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/api.md b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/api.md new file mode 100644 index 000000000000..082c9a354261 --- /dev/null +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/api.md @@ -0,0 +1,1092 @@ +```py +namespace azure.mgmt.mongodbatlas + + class azure.mgmt.mongodbatlas.MongoDBAtlasMgmtClient: implements ContextManager + clusters: ClustersOperations + operations: Operations + organizations: OrganizationsOperations + projects: ProjectsOperations + + def __init__( + self, + credential: TokenCredential, + subscription_id: str, + base_url: Optional[str] = None, + *, + api_version: str = ..., + cloud_setting: Optional[AzureClouds] = ..., + polling_interval: Optional[int] = ..., + **kwargs: Any + ) -> None: ... + + def close(self) -> None: ... + + def send_request( + self, + request: HttpRequest, + *, + stream: bool = False, + **kwargs: Any + ) -> HttpResponse: ... + + +namespace azure.mgmt.mongodbatlas.aio + + class azure.mgmt.mongodbatlas.aio.MongoDBAtlasMgmtClient: implements AsyncContextManager + clusters: ClustersOperations + operations: Operations + organizations: OrganizationsOperations + projects: ProjectsOperations + + def __init__( + self, + credential: AsyncTokenCredential, + subscription_id: str, + base_url: Optional[str] = None, + *, + api_version: str = ..., + cloud_setting: Optional[AzureClouds] = ..., + polling_interval: Optional[int] = ..., + **kwargs: Any + ) -> None: ... + + async def close(self) -> None: ... + + def send_request( + self, + request: HttpRequest, + *, + stream: bool = False, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: ... + + +namespace azure.mgmt.mongodbatlas.aio.operations + + class azure.mgmt.mongodbatlas.aio.operations.ClustersOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + cluster_name: str, + resource: Cluster, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Cluster]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + cluster_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Cluster]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + cluster_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Cluster]: ... + + @distributed_trace_async + @api_version_validation(method_added_on='2026-03-01-preview', params_added_on={'2026-03-01-preview': ['api_version', 'subscription_id', 'resource_group_name', 'organization_name', 'project_name', 'cluster_name']}, api_versions_list=['2026-03-01-preview']) + async def begin_delete( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + cluster_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: ... + + @distributed_trace_async + @api_version_validation(method_added_on='2026-03-01-preview', params_added_on={'2026-03-01-preview': ['api_version', 'subscription_id', 'resource_group_name', 'organization_name', 'project_name', 'cluster_name', 'accept']}, api_versions_list=['2026-03-01-preview']) + async def get( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + cluster_name: str, + **kwargs: Any + ) -> Cluster: ... + + @distributed_trace + @api_version_validation(method_added_on='2026-03-01-preview', params_added_on={'2026-03-01-preview': ['api_version', 'subscription_id', 'resource_group_name', 'organization_name', 'project_name', 'accept']}, api_versions_list=['2026-03-01-preview']) + def list( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + **kwargs: Any + ) -> AsyncItemPaged[Cluster]: ... + + + class azure.mgmt.mongodbatlas.aio.operations.Operations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged[Operation]: ... + + + class azure.mgmt.mongodbatlas.aio.operations.OrganizationsOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + resource: OrganizationResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[OrganizationResource]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[OrganizationResource]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[OrganizationResource]: ... + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + organization_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: ... + + @overload + async def begin_update( + self, + resource_group_name: str, + organization_name: str, + properties: OrganizationResourceUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[OrganizationResource]: ... + + @overload + async def begin_update( + self, + resource_group_name: str, + organization_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[OrganizationResource]: ... + + @overload + async def begin_update( + self, + resource_group_name: str, + organization_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[OrganizationResource]: ... + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + organization_name: str, + **kwargs: Any + ) -> OrganizationResource: ... + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncItemPaged[OrganizationResource]: ... + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged[OrganizationResource]: ... + + + class azure.mgmt.mongodbatlas.aio.operations.ProjectsOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + resource: Project, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Project]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Project]: ... + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[Project]: ... + + @distributed_trace_async + @api_version_validation(method_added_on='2026-03-01-preview', params_added_on={'2026-03-01-preview': ['api_version', 'subscription_id', 'resource_group_name', 'organization_name', 'project_name']}, api_versions_list=['2026-03-01-preview']) + async def begin_delete( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: ... + + @distributed_trace_async + @api_version_validation(method_added_on='2026-03-01-preview', params_added_on={'2026-03-01-preview': ['api_version', 'subscription_id', 'resource_group_name', 'organization_name', 'project_name', 'accept']}, api_versions_list=['2026-03-01-preview']) + async def get( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + **kwargs: Any + ) -> Project: ... + + @distributed_trace + @api_version_validation(method_added_on='2026-03-01-preview', params_added_on={'2026-03-01-preview': ['api_version', 'subscription_id', 'resource_group_name', 'organization_name', 'accept']}, api_versions_list=['2026-03-01-preview']) + def list( + self, + resource_group_name: str, + organization_name: str, + **kwargs: Any + ) -> AsyncItemPaged[Project]: ... + + @distributed_trace_async + @api_version_validation(method_added_on='2026-03-01-preview', params_added_on={'2026-03-01-preview': ['api_version', 'subscription_id', 'resource_group_name', 'organization_name', 'project_name', 'accept']}, api_versions_list=['2026-03-01-preview']) + async def list_cluster_tier_regions( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + **kwargs: Any + ) -> RegionsByTierResponse: ... + + @distributed_trace_async + @api_version_validation(method_added_on='2026-03-01-preview', params_added_on={'2026-03-01-preview': ['api_version', 'subscription_id', 'resource_group_name', 'organization_name', 'project_name', 'accept']}, api_versions_list=['2026-03-01-preview']) + async def tier_limit_reached( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + **kwargs: Any + ) -> TierLimitReachedResponse: ... + + +namespace azure.mgmt.mongodbatlas.models + + class azure.mgmt.mongodbatlas.models.ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + INTERNAL = "Internal" + + + class azure.mgmt.mongodbatlas.models.Cluster(ProxyResource): + id: str + name: str + properties: Optional[ClusterProperties] + system_data: SystemData + type: str + + @overload + def __init__( + self, + *, + properties: Optional[ClusterProperties] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.mongodbatlas.models.ClusterProperties(_Model): + backups: Optional[bool] + cluster_name: Optional[str] + cluster_tier: Union[str, ClusterTier] + mongo_db_version: Optional[str] + provisioning_state: Optional[Union[str, ResourceProvisioningState]] + region_name: str + state: Optional[str] + + @overload + def __init__( + self, + *, + cluster_tier: Union[str, ClusterTier], + region_name: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.mongodbatlas.models.ClusterTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + FLEX = "FLEX" + FREE = "FREE" + M10 = "M10" + M30 = "M30" + + + class azure.mgmt.mongodbatlas.models.CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + APPLICATION = "Application" + KEY = "Key" + MANAGED_IDENTITY = "ManagedIdentity" + USER = "User" + + + class azure.mgmt.mongodbatlas.models.ErrorAdditionalInfo(_Model): + info: Optional[Any] + type: Optional[str] + + + class azure.mgmt.mongodbatlas.models.ErrorDetail(_Model): + additional_info: Optional[list[ErrorAdditionalInfo]] + code: Optional[str] + details: Optional[list[ErrorDetail]] + message: Optional[str] + target: Optional[str] + + + class azure.mgmt.mongodbatlas.models.ErrorResponse(_Model): + error: Optional[ErrorDetail] + + @overload + def __init__( + self, + *, + error: Optional[ErrorDetail] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.mongodbatlas.models.ManagedServiceIdentity(_Model): + principal_id: Optional[str] + tenant_id: Optional[str] + type: Union[str, ManagedServiceIdentityType] + user_assigned_identities: Optional[dict[str, UserAssignedIdentity]] + + @overload + def __init__( + self, + *, + type: Union[str, ManagedServiceIdentityType], + user_assigned_identities: Optional[dict[str, UserAssignedIdentity]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.mongodbatlas.models.ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + USER_ASSIGNED = "UserAssigned" + + + class azure.mgmt.mongodbatlas.models.MarketplaceDetails(_Model): + offer_details: OfferDetails + subscription_id: str + subscription_status: Optional[Union[str, MarketplaceSubscriptionStatus]] + + @overload + def __init__( + self, + *, + offer_details: OfferDetails, + subscription_id: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.mongodbatlas.models.MarketplaceSubscriptionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + PENDING_FULFILLMENT_START = "PendingFulfillmentStart" + SUBSCRIBED = "Subscribed" + SUSPENDED = "Suspended" + UNSUBSCRIBED = "Unsubscribed" + + + class azure.mgmt.mongodbatlas.models.OfferDetails(_Model): + offer_id: str + plan_id: str + plan_name: Optional[str] + publisher_id: str + term_id: Optional[str] + term_unit: Optional[str] + + @overload + def __init__( + self, + *, + offer_id: str, + plan_id: str, + plan_name: Optional[str] = ..., + publisher_id: str, + term_id: Optional[str] = ..., + term_unit: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.mongodbatlas.models.Operation(_Model): + action_type: Optional[Union[str, ActionType]] + display: Optional[OperationDisplay] + is_data_action: Optional[bool] + name: Optional[str] + origin: Optional[Union[str, Origin]] + + @overload + def __init__( + self, + *, + display: Optional[OperationDisplay] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.mongodbatlas.models.OperationDisplay(_Model): + description: Optional[str] + operation: Optional[str] + provider: Optional[str] + resource: Optional[str] + + + class azure.mgmt.mongodbatlas.models.OrganizationProperties(_Model): + marketplace: MarketplaceDetails + partner_properties: Optional[PartnerProperties] + provisioning_state: Optional[Union[str, ResourceProvisioningState]] + user: UserDetails + + @overload + def __init__( + self, + *, + marketplace: MarketplaceDetails, + partner_properties: Optional[PartnerProperties] = ..., + user: UserDetails + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.mongodbatlas.models.OrganizationResource(TrackedResource): + id: str + identity: Optional[ManagedServiceIdentity] + location: str + name: str + properties: Optional[OrganizationProperties] + system_data: SystemData + tags: dict[str, str] + type: str + + @overload + def __init__( + self, + *, + identity: Optional[ManagedServiceIdentity] = ..., + location: str, + properties: Optional[OrganizationProperties] = ..., + tags: Optional[dict[str, str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.mongodbatlas.models.OrganizationResourceUpdate(_Model): + identity: Optional[ManagedServiceIdentity] + properties: Optional[OrganizationResourceUpdateProperties] + tags: Optional[dict[str, str]] + + @overload + def __init__( + self, + *, + identity: Optional[ManagedServiceIdentity] = ..., + properties: Optional[OrganizationResourceUpdateProperties] = ..., + tags: Optional[dict[str, str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.mongodbatlas.models.OrganizationResourceUpdateProperties(_Model): + partner_properties: Optional[PartnerProperties] + user: Optional[UserDetails] + + @overload + def __init__( + self, + *, + partner_properties: Optional[PartnerProperties] = ..., + user: Optional[UserDetails] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.mongodbatlas.models.Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + SYSTEM = "system" + USER = "user" + USER_SYSTEM = "user,system" + + + class azure.mgmt.mongodbatlas.models.PartnerProperties(_Model): + organization_id: Optional[str] + organization_name: str + redirect_url: Optional[str] + + @overload + def __init__( + self, + *, + organization_id: Optional[str] = ..., + organization_name: str, + redirect_url: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.mongodbatlas.models.Project(ProxyResource): + id: str + name: str + properties: Optional[ProjectProperties] + system_data: SystemData + type: str + + @overload + def __init__( + self, + *, + properties: Optional[ProjectProperties] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.mongodbatlas.models.ProjectLimitStatus(_Model): + current: int + is_reached: bool + maximum: int + type: Union[str, ClusterTier] + + @overload + def __init__( + self, + *, + current: int, + is_reached: bool, + maximum: int, + type: Union[str, ClusterTier] + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.mongodbatlas.models.ProjectProperties(_Model): + cluster_count: Optional[int] + organization_id: Optional[str] + project_id: Optional[str] + project_name: Optional[str] + provisioning_state: Optional[Union[str, ResourceProvisioningState]] + + + class azure.mgmt.mongodbatlas.models.ProxyResource(Resource): + id: str + name: str + system_data: SystemData + type: str + + + class azure.mgmt.mongodbatlas.models.RegionsByTierResponse(_Model): + organization_id: str + project_id: str + regions_by_tier: list[TierRegions] + + + class azure.mgmt.mongodbatlas.models.Resource(_Model): + id: Optional[str] + name: Optional[str] + system_data: Optional[SystemData] + type: Optional[str] + + + class azure.mgmt.mongodbatlas.models.ResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + CANCELED = "Canceled" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + + + class azure.mgmt.mongodbatlas.models.SystemData(_Model): + created_at: Optional[datetime] + created_by: Optional[str] + created_by_type: Optional[Union[str, CreatedByType]] + last_modified_at: Optional[datetime] + last_modified_by: Optional[str] + last_modified_by_type: Optional[Union[str, CreatedByType]] + + @overload + def __init__( + self, + *, + created_at: Optional[datetime] = ..., + created_by: Optional[str] = ..., + created_by_type: Optional[Union[str, CreatedByType]] = ..., + last_modified_at: Optional[datetime] = ..., + last_modified_by: Optional[str] = ..., + last_modified_by_type: Optional[Union[str, CreatedByType]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.mongodbatlas.models.TierLimitReachedResponse(_Model): + limits: list[ProjectLimitStatus] + + + class azure.mgmt.mongodbatlas.models.TierRegions(_Model): + regions: list[str] + tier: Union[str, ClusterTier] + + @overload + def __init__( + self, + *, + regions: list[str], + tier: Union[str, ClusterTier] + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.mongodbatlas.models.TrackedResource(Resource): + id: str + location: str + name: str + system_data: SystemData + tags: Optional[dict[str, str]] + type: str + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.mgmt.mongodbatlas.models.UserAssignedIdentity(_Model): + client_id: Optional[str] + principal_id: Optional[str] + + + class azure.mgmt.mongodbatlas.models.UserDetails(_Model): + company_name: Optional[str] + email_address: str + first_name: str + last_name: str + phone_number: Optional[str] + upn: Optional[str] + + @overload + def __init__( + self, + *, + company_name: Optional[str] = ..., + email_address: str, + first_name: str, + last_name: str, + phone_number: Optional[str] = ..., + upn: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + +namespace azure.mgmt.mongodbatlas.operations + + class azure.mgmt.mongodbatlas.operations.ClustersOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + cluster_name: str, + resource: Cluster, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Cluster]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + cluster_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Cluster]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + cluster_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Cluster]: ... + + @distributed_trace + @api_version_validation(method_added_on='2026-03-01-preview', params_added_on={'2026-03-01-preview': ['api_version', 'subscription_id', 'resource_group_name', 'organization_name', 'project_name', 'cluster_name']}, api_versions_list=['2026-03-01-preview']) + def begin_delete( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + cluster_name: str, + **kwargs: Any + ) -> LROPoller[None]: ... + + @distributed_trace + @api_version_validation(method_added_on='2026-03-01-preview', params_added_on={'2026-03-01-preview': ['api_version', 'subscription_id', 'resource_group_name', 'organization_name', 'project_name', 'cluster_name', 'accept']}, api_versions_list=['2026-03-01-preview']) + def get( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + cluster_name: str, + **kwargs: Any + ) -> Cluster: ... + + @distributed_trace + @api_version_validation(method_added_on='2026-03-01-preview', params_added_on={'2026-03-01-preview': ['api_version', 'subscription_id', 'resource_group_name', 'organization_name', 'project_name', 'accept']}, api_versions_list=['2026-03-01-preview']) + def list( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + **kwargs: Any + ) -> ItemPaged[Cluster]: ... + + + class azure.mgmt.mongodbatlas.operations.Operations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged[Operation]: ... + + + class azure.mgmt.mongodbatlas.operations.OrganizationsOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + resource: OrganizationResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[OrganizationResource]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[OrganizationResource]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[OrganizationResource]: ... + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + organization_name: str, + **kwargs: Any + ) -> LROPoller[None]: ... + + @overload + def begin_update( + self, + resource_group_name: str, + organization_name: str, + properties: OrganizationResourceUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[OrganizationResource]: ... + + @overload + def begin_update( + self, + resource_group_name: str, + organization_name: str, + properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[OrganizationResource]: ... + + @overload + def begin_update( + self, + resource_group_name: str, + organization_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[OrganizationResource]: ... + + @distributed_trace + def get( + self, + resource_group_name: str, + organization_name: str, + **kwargs: Any + ) -> OrganizationResource: ... + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> ItemPaged[OrganizationResource]: ... + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> ItemPaged[OrganizationResource]: ... + + + class azure.mgmt.mongodbatlas.operations.ProjectsOperations: + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + resource: Project, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Project]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Project]: ... + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[Project]: ... + + @distributed_trace + @api_version_validation(method_added_on='2026-03-01-preview', params_added_on={'2026-03-01-preview': ['api_version', 'subscription_id', 'resource_group_name', 'organization_name', 'project_name']}, api_versions_list=['2026-03-01-preview']) + def begin_delete( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + **kwargs: Any + ) -> LROPoller[None]: ... + + @distributed_trace + @api_version_validation(method_added_on='2026-03-01-preview', params_added_on={'2026-03-01-preview': ['api_version', 'subscription_id', 'resource_group_name', 'organization_name', 'project_name', 'accept']}, api_versions_list=['2026-03-01-preview']) + def get( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + **kwargs: Any + ) -> Project: ... + + @distributed_trace + @api_version_validation(method_added_on='2026-03-01-preview', params_added_on={'2026-03-01-preview': ['api_version', 'subscription_id', 'resource_group_name', 'organization_name', 'accept']}, api_versions_list=['2026-03-01-preview']) + def list( + self, + resource_group_name: str, + organization_name: str, + **kwargs: Any + ) -> ItemPaged[Project]: ... + + @distributed_trace + @api_version_validation(method_added_on='2026-03-01-preview', params_added_on={'2026-03-01-preview': ['api_version', 'subscription_id', 'resource_group_name', 'organization_name', 'project_name', 'accept']}, api_versions_list=['2026-03-01-preview']) + def list_cluster_tier_regions( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + **kwargs: Any + ) -> RegionsByTierResponse: ... + + @distributed_trace + @api_version_validation(method_added_on='2026-03-01-preview', params_added_on={'2026-03-01-preview': ['api_version', 'subscription_id', 'resource_group_name', 'organization_name', 'project_name', 'accept']}, api_versions_list=['2026-03-01-preview']) + def tier_limit_reached( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + **kwargs: Any + ) -> TierLimitReachedResponse: ... + + +``` \ No newline at end of file diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/api.metadata.yml b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/api.metadata.yml new file mode 100644 index 000000000000..5209753d3c63 --- /dev/null +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/api.metadata.yml @@ -0,0 +1,3 @@ +apiMdSha256: 8bbcdf25aa6b6f05d8ed9419a1415bd4fec7ee905577eacf01b42eff9852b146 +parserVersion: 0.3.28 +pythonVersion: 3.13.13 diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/apiview-properties.json b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/apiview-properties.json index f344dd418f08..a6cf9cb0a073 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/apiview-properties.json +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/apiview-properties.json @@ -1,6 +1,10 @@ { "CrossLanguagePackageId": "MongoDB.Atlas", "CrossLanguageDefinitionId": { + "azure.mgmt.mongodbatlas.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", + "azure.mgmt.mongodbatlas.models.ProxyResource": "Azure.ResourceManager.CommonTypes.ProxyResource", + "azure.mgmt.mongodbatlas.models.Cluster": "MongoDB.Atlas.Cluster", + "azure.mgmt.mongodbatlas.models.ClusterProperties": "MongoDB.Atlas.ClusterProperties", "azure.mgmt.mongodbatlas.models.ErrorAdditionalInfo": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", "azure.mgmt.mongodbatlas.models.ErrorDetail": "Azure.ResourceManager.CommonTypes.ErrorDetail", "azure.mgmt.mongodbatlas.models.ErrorResponse": "Azure.ResourceManager.CommonTypes.ErrorResponse", @@ -10,13 +14,18 @@ "azure.mgmt.mongodbatlas.models.Operation": "Azure.ResourceManager.CommonTypes.Operation", "azure.mgmt.mongodbatlas.models.OperationDisplay": "Azure.ResourceManager.CommonTypes.OperationDisplay", "azure.mgmt.mongodbatlas.models.OrganizationProperties": "MongoDB.Atlas.OrganizationProperties", - "azure.mgmt.mongodbatlas.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", "azure.mgmt.mongodbatlas.models.TrackedResource": "Azure.ResourceManager.CommonTypes.TrackedResource", "azure.mgmt.mongodbatlas.models.OrganizationResource": "MongoDB.Atlas.OrganizationResource", "azure.mgmt.mongodbatlas.models.OrganizationResourceUpdate": "Azure.ResourceManager.Foundations.ResourceUpdateModel", "azure.mgmt.mongodbatlas.models.OrganizationResourceUpdateProperties": "Azure.ResourceManager.Foundations.ResourceUpdateModelProperties", "azure.mgmt.mongodbatlas.models.PartnerProperties": "MongoDB.Atlas.PartnerProperties", + "azure.mgmt.mongodbatlas.models.Project": "MongoDB.Atlas.Project", + "azure.mgmt.mongodbatlas.models.ProjectLimitStatus": "MongoDB.Atlas.ProjectLimitStatus", + "azure.mgmt.mongodbatlas.models.ProjectProperties": "MongoDB.Atlas.ProjectProperties", + "azure.mgmt.mongodbatlas.models.RegionsByTierResponse": "MongoDB.Atlas.RegionsByTierResponse", "azure.mgmt.mongodbatlas.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData", + "azure.mgmt.mongodbatlas.models.TierLimitReachedResponse": "MongoDB.Atlas.TierLimitReachedResponse", + "azure.mgmt.mongodbatlas.models.TierRegions": "MongoDB.Atlas.TierRegions", "azure.mgmt.mongodbatlas.models.UserAssignedIdentity": "Azure.ResourceManager.CommonTypes.UserAssignedIdentity", "azure.mgmt.mongodbatlas.models.UserDetails": "MongoDB.Atlas.UserDetails", "azure.mgmt.mongodbatlas.models.Origin": "Azure.ResourceManager.CommonTypes.Origin", @@ -25,6 +34,7 @@ "azure.mgmt.mongodbatlas.models.MarketplaceSubscriptionStatus": "LiftrBase.MarketplaceSubscriptionStatus", "azure.mgmt.mongodbatlas.models.ResourceProvisioningState": "Azure.ResourceManager.ResourceProvisioningState", "azure.mgmt.mongodbatlas.models.ManagedServiceIdentityType": "Azure.ResourceManager.CommonTypes.ManagedServiceIdentityType", + "azure.mgmt.mongodbatlas.models.ClusterTier": "MongoDB.Atlas.ClusterTier", "azure.mgmt.mongodbatlas.operations.Operations.list": "Azure.ResourceManager.Operations.list", "azure.mgmt.mongodbatlas.aio.operations.Operations.list": "Azure.ResourceManager.Operations.list", "azure.mgmt.mongodbatlas.operations.OrganizationsOperations.get": "MongoDB.Atlas.Organizations.get", @@ -38,6 +48,27 @@ "azure.mgmt.mongodbatlas.operations.OrganizationsOperations.list_by_resource_group": "MongoDB.Atlas.Organizations.listByResourceGroup", "azure.mgmt.mongodbatlas.aio.operations.OrganizationsOperations.list_by_resource_group": "MongoDB.Atlas.Organizations.listByResourceGroup", "azure.mgmt.mongodbatlas.operations.OrganizationsOperations.list_by_subscription": "MongoDB.Atlas.Organizations.listBySubscription", - "azure.mgmt.mongodbatlas.aio.operations.OrganizationsOperations.list_by_subscription": "MongoDB.Atlas.Organizations.listBySubscription" - } + "azure.mgmt.mongodbatlas.aio.operations.OrganizationsOperations.list_by_subscription": "MongoDB.Atlas.Organizations.listBySubscription", + "azure.mgmt.mongodbatlas.operations.ProjectsOperations.get": "MongoDB.Atlas.Projects.get", + "azure.mgmt.mongodbatlas.aio.operations.ProjectsOperations.get": "MongoDB.Atlas.Projects.get", + "azure.mgmt.mongodbatlas.operations.ProjectsOperations.begin_create_or_update": "MongoDB.Atlas.Projects.createOrUpdate", + "azure.mgmt.mongodbatlas.aio.operations.ProjectsOperations.begin_create_or_update": "MongoDB.Atlas.Projects.createOrUpdate", + "azure.mgmt.mongodbatlas.operations.ProjectsOperations.begin_delete": "MongoDB.Atlas.Projects.delete", + "azure.mgmt.mongodbatlas.aio.operations.ProjectsOperations.begin_delete": "MongoDB.Atlas.Projects.delete", + "azure.mgmt.mongodbatlas.operations.ProjectsOperations.list": "MongoDB.Atlas.Projects.list", + "azure.mgmt.mongodbatlas.aio.operations.ProjectsOperations.list": "MongoDB.Atlas.Projects.list", + "azure.mgmt.mongodbatlas.operations.ProjectsOperations.tier_limit_reached": "MongoDB.Atlas.Projects.tierLimitReached", + "azure.mgmt.mongodbatlas.aio.operations.ProjectsOperations.tier_limit_reached": "MongoDB.Atlas.Projects.tierLimitReached", + "azure.mgmt.mongodbatlas.operations.ProjectsOperations.list_cluster_tier_regions": "MongoDB.Atlas.Projects.listClusterTierRegions", + "azure.mgmt.mongodbatlas.aio.operations.ProjectsOperations.list_cluster_tier_regions": "MongoDB.Atlas.Projects.listClusterTierRegions", + "azure.mgmt.mongodbatlas.operations.ClustersOperations.begin_create_or_update": "MongoDB.Atlas.Clusters.createOrUpdate", + "azure.mgmt.mongodbatlas.aio.operations.ClustersOperations.begin_create_or_update": "MongoDB.Atlas.Clusters.createOrUpdate", + "azure.mgmt.mongodbatlas.operations.ClustersOperations.begin_delete": "MongoDB.Atlas.Clusters.delete", + "azure.mgmt.mongodbatlas.aio.operations.ClustersOperations.begin_delete": "MongoDB.Atlas.Clusters.delete", + "azure.mgmt.mongodbatlas.operations.ClustersOperations.list": "MongoDB.Atlas.Clusters.list", + "azure.mgmt.mongodbatlas.aio.operations.ClustersOperations.list": "MongoDB.Atlas.Clusters.list", + "azure.mgmt.mongodbatlas.operations.ClustersOperations.get": "MongoDB.Atlas.Clusters.get", + "azure.mgmt.mongodbatlas.aio.operations.ClustersOperations.get": "MongoDB.Atlas.Clusters.get" + }, + "CrossLanguageVersion": "ab11d5347e15" } \ No newline at end of file diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/__init__.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/__init__.py index 8db66d3d0f0f..d55ccad1f573 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/__init__.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/__init__.py @@ -1 +1 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/__init__.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/__init__.py index 8db66d3d0f0f..d55ccad1f573 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/__init__.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/__init__.py @@ -1 +1 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_client.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_client.py index 0b9c1d34ae85..ca6787792527 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_client.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_client.py @@ -7,8 +7,8 @@ # -------------------------------------------------------------------------- from copy import deepcopy +import sys 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 @@ -19,9 +19,15 @@ from ._configuration import MongoDBAtlasMgmtClientConfiguration from ._utils.serialization import Deserializer, Serializer -from .operations import Operations, OrganizationsOperations +from .operations import ClustersOperations, Operations, OrganizationsOperations, ProjectsOperations + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self # type: ignore if TYPE_CHECKING: + from azure.core import AzureClouds from azure.core.credentials import TokenCredential @@ -32,24 +38,39 @@ class MongoDBAtlasMgmtClient: :vartype operations: azure.mgmt.mongodbatlas.operations.Operations :ivar organizations: OrganizationsOperations operations :vartype organizations: azure.mgmt.mongodbatlas.operations.OrganizationsOperations + :ivar projects: ProjectsOperations operations + :vartype projects: azure.mgmt.mongodbatlas.operations.ProjectsOperations + :ivar clusters: ClustersOperations operations + :vartype clusters: azure.mgmt.mongodbatlas.operations.ClustersOperations :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 None. :type base_url: str - :keyword api_version: The API version to use for this operation. Default value is "2025-06-01". - Note that overriding this default value may result in unsupported behavior. + :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :paramtype cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2026-03-01-preview" and None. Default value is None. If not set, the operation's default API + version will be used. 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: Optional[str] = None, **kwargs: Any + self, + credential: "TokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + *, + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any ) -> None: _endpoint = "{endpoint}" - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore _endpoints = get_arm_endpoints(_cloud) if not base_url: base_url = _endpoints["resource_manager"] @@ -58,6 +79,7 @@ def __init__( credential=credential, subscription_id=subscription_id, base_url=cast(str, base_url), + cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs ) @@ -87,6 +109,8 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.organizations = OrganizationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.projects = ProjectsOperations(self._client, self._config, self._serialize, self._deserialize) + self.clusters = ClustersOperations(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/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_configuration.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_configuration.py index 0f469ad8f8d9..2d03930f385e 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_configuration.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_configuration.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -14,6 +14,7 @@ from ._version import VERSION if TYPE_CHECKING: + from azure.core import AzureClouds from azure.core.credentials import TokenCredential @@ -29,8 +30,13 @@ class MongoDBAtlasMgmtClientConfiguration: # 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 "2025-06-01". - Note that overriding this default value may result in unsupported behavior. + :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :type cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2026-03-01-preview" and None. Default value is None. If not set, the operation's default API + version will be used. Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ @@ -39,9 +45,10 @@ def __init__( credential: "TokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", + cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "2025-06-01") + api_version: str = kwargs.pop("api_version", "2026-03-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,6 +58,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.base_url = base_url + self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-mongodbatlas/{}".format(VERSION)) diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_patch.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_patch.py index 8bcb627aa475..87676c65a8f0 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_patch.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_patch.py @@ -7,9 +7,9 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_utils/model_base.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_utils/model_base.py index 49d5c7259389..d725c55906d3 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_utils/model_base.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_utils/model_base.py @@ -1,4 +1,4 @@ -# 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. @@ -23,19 +23,26 @@ 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 from azure.core import CaseInsensitiveEnumMeta from azure.core.pipeline import PipelineResponse from azure.core.serialization import _Null +from azure.core.rest import HttpResponse + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + _LOGGER = logging.getLogger(__name__) __all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] TZ_UTC = timezone.utc _T = typing.TypeVar("_T") +_NONE_TYPE = type(None) def _timedelta_as_isostr(td: timedelta) -> str: @@ -170,6 +177,21 @@ def default(self, o): # pylint: disable=too-many-return-statements r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" ) +_ARRAY_ENCODE_MAPPING = { + "pipeDelimited": "|", + "spaceDelimited": " ", + "commaDelimited": ",", + "newlineDelimited": "\n", +} + + +def _deserialize_array_encoded(delimit: str, attr): + if isinstance(attr, str): + if attr == "": + return [] + return attr.split(delimit) + return attr + def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: """Deserialize ISO-8601 formatted string into Datetime object. @@ -201,7 +223,7 @@ def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: test_utc = date_obj.utctimetuple() if test_utc.tm_year > 9999 or test_utc.tm_year < 1: raise OverflowError("Hit max or min date") - return date_obj + return date_obj # type: ignore[no-any-return] def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: @@ -255,7 +277,7 @@ def _deserialize_time(attr: typing.Union[str, time]) -> time: """ if isinstance(attr, time): return attr - return isodate.parse_time(attr) + return isodate.parse_time(attr) # type: ignore[no-any-return] def _deserialize_bytes(attr): @@ -314,6 +336,8 @@ def _deserialize_int_as_str(attr): def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): if annotation is int and rf and rf._format == "str": return _deserialize_int_as_str + if annotation is str and rf and rf._format in _ARRAY_ENCODE_MAPPING: + return functools.partial(_deserialize_array_encoded, _ARRAY_ENCODE_MAPPING[rf._format]) if rf and rf._format: return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore @@ -345,16 +369,46 @@ def _get_model(module_name: str, model_name: str): class _MyMutableMapping(MutableMapping[str, typing.Any]): - def __init__(self, data: typing.Dict[str, typing.Any]) -> None: + def __init__(self, data: dict[str, typing.Any]) -> None: self._data = data def __contains__(self, key: typing.Any) -> bool: return key in self._data def __getitem__(self, key: str) -> typing.Any: + # If this key has been deserialized (for mutable types), we need to handle serialization + if hasattr(self, "_attr_to_rest_field"): + cache_attr = f"_deserialized_{key}" + if hasattr(self, cache_attr): + rf = _get_rest_field(getattr(self, "_attr_to_rest_field"), key) + if rf: + value = self._data.get(key) + if isinstance(value, (dict, list, set)): + # For mutable types, serialize and return + # But also update _data with serialized form and clear flag + # so mutations via this returned value affect _data + serialized = _serialize(value, rf._format) + # If serialized form is same type (no transformation needed), + # return _data directly so mutations work + if isinstance(serialized, type(value)) and serialized == value: + return self._data.get(key) + # Otherwise return serialized copy and clear flag + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + # Store serialized form back + self._data[key] = serialized + return serialized return self._data.__getitem__(key) def __setitem__(self, key: str, value: typing.Any) -> None: + # Clear any cached deserialized value when setting through dictionary access + cache_attr = f"_deserialized_{key}" + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass self._data.__setitem__(key, value) def __delitem__(self, key: str) -> None: @@ -425,7 +479,7 @@ def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: return self._data.pop(key) return self._data.pop(key, default) - def popitem(self) -> typing.Tuple[str, typing.Any]: + def popitem(self) -> tuple[str, typing.Any]: """ Removes and returns some (key, value) pair :returns: The (key, value) pair. @@ -466,6 +520,8 @@ def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: return self._data.setdefault(key, default) def __eq__(self, other: typing.Any) -> bool: + if isinstance(other, _MyMutableMapping): + return self._data == other._data try: other_model = self.__class__(other) except Exception: @@ -482,6 +538,8 @@ def _is_model(obj: typing.Any) -> bool: def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements if isinstance(o, list): + if format in _ARRAY_ENCODE_MAPPING and all(isinstance(x, str) for x in o): + return _ARRAY_ENCODE_MAPPING[format].join(o) return [_serialize(x, format) for x in o] if isinstance(o, dict): return {k: _serialize(v, format) for k, v in o.items()} @@ -513,9 +571,7 @@ def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-m return o -def _get_rest_field( - attr_to_rest_field: typing.Dict[str, "_RestField"], rest_name: str -) -> typing.Optional["_RestField"]: +def _get_rest_field(attr_to_rest_field: dict[str, "_RestField"], rest_name: str) -> typing.Optional["_RestField"]: try: return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) except StopIteration: @@ -534,69 +590,253 @@ def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typin return _serialize(value, rf._format) +# ============================================================================ +# Fast-path scalar deserializer functions for rest_field(deserializer=...) +# These are referenced from rest_field declarations to bypass the generic +# _deserialize -> _deserialize_with_callable chain. +# Only simple/primitive types — no models or container types. +# ============================================================================ + + +def _xml_deser_str(value): + if isinstance(value, ET.Element): + return value.text or "" + return str(value) if value is not None else None + + +def _xml_deser_int(value): + if isinstance(value, ET.Element): + return int(value.text) if value.text else None + return int(value) if value is not None else None + + +def _xml_deser_float(value): + if isinstance(value, ET.Element): + return float(value.text) if value.text else None + return float(value) if value is not None else None + + +def _xml_deser_bool(value): + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + if text in (True, False): + return text + return text.lower() == "true" + + +# pylint: disable=docstring-missing-param +def _xml_deser_bytes(value): + """Deserialize bytes from XML (base64).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_bytes(text) + + +def _xml_deser_bytes_base64url(value): + """Deserialize bytes from XML (base64url).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_bytes_base64(text) + + +def _xml_deser_datetime(value): + """Deserialize a datetime from XML (ISO 8601 / rfc3339).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_datetime(text) + + +def _xml_deser_datetime_rfc7231(value): + """Deserialize a datetime from XML (RFC7231 format).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_datetime_rfc7231(text) + + +def _xml_deser_datetime_unix_timestamp(value): + """Deserialize a datetime from XML (Unix timestamp).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_datetime_unix_timestamp(float(text)) + + +def _xml_deser_date(value): + """Deserialize a date from XML (ISO 8601).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_date(text) + + +def _xml_deser_time(value): + """Deserialize a time from XML (ISO 8601).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_time(text) + + +def _xml_deser_duration(value): + """Deserialize a timedelta from XML (ISO 8601 duration).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_duration(text) + + +def _xml_deser_decimal(value): + """Deserialize a Decimal from XML.""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_decimal(text) + + +def _xml_deser_enum_or_str(enum_cls, value): + """Deserialize a Union[EnumType, str] from XML.""" + text = value.text if isinstance(value, ET.Element) else value + if text is None: + return None + try: + return enum_cls(text) + except ValueError: + return text + + +def _extract_xml_model_type(rf_type): + """Extract the concrete Model class from a resolved rf._type partial chain. + + Unwraps ``Optional[Model]`` and ``_deserialize_model(Model, ...)`` + wrappers. Only handles Model and Optional[Model] — other composite + types (List, Dict, Union, etc.) return None and fall through to the + generic ``_deserialize`` path at runtime. + """ + if rf_type is None: + return None + if isinstance(rf_type, type) and _is_model(rf_type): + return rf_type + if not isinstance(rf_type, functools.partial): + return None + func = rf_type.func + args = rf_type.args + if func is _deserialize_with_optional and args: + return _extract_xml_model_type(args[0]) + if func is _deserialize_model and args: + cls = args[0] + return cls if isinstance(cls, type) and _is_model(cls) else None + return None + + +def _build_xml_field_plan( # pylint: disable=docstring-missing-return, docstring-missing-rtype, unused-variable + cls, attr_to_rest_field: dict +) -> list: + """Build a precomputed XML field plan for fast _init_from_xml iteration. + + Called once per model class in __new__. Returns a list of tuples: + (rest_name, xml_name, kind, deser, rf_type, is_optional, items_name) + + kind: 0=wrapped, 1=attribute, 2=unwrapped, 3=text + + For Model and Optional[Model] fields that lack a scalar + ``_deserializer``, this function precomputes the Model class as the + deserializer so ``_init_from_xml`` can call ``ModelClass(element)`` + directly instead of going through the expensive + ``_get_deserialize_callable_from_annotation`` chain at runtime. + """ + model_meta = getattr(cls, "_xml", {}) + model_ns = model_meta.get("ns") or model_meta.get("namespace") + plan = [] + + for rf in attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + deser = rf._deserializer + + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + is_optional = rf._is_optional + + # For Model / Optional[Model] fields without a scalar deserializer, + # precompute the Model class as the deserializer. + if deser is None and rf._type is not None: + model_cls = _extract_xml_model_type(rf._type) + if model_cls is not None: + deser = model_cls + + if prop_meta.get("attribute", False): + plan.append((rf._rest_name, xml_name, 1, deser, rf._type, is_optional, None)) + elif prop_meta.get("unwrapped", False): + items_name = prop_meta.get("itemsName") + if items_name: + items_ns = prop_meta.get("itemsNs") + if items_ns is not None: + xml_ns = items_ns + if xml_ns: + items_name = "{" + xml_ns + "}" + items_name + else: + items_name = xml_name + plan.append((rf._rest_name, xml_name, 2, deser, rf._type, is_optional, items_name)) + elif prop_meta.get("text", False): + plan.append((rf._rest_name, xml_name, 3, deser, rf._type, is_optional, None)) + else: + plan.append((rf._rest_name, xml_name, 0, deser, rf._type, is_optional, None)) + + return plan + + +# pylint: enable=docstring-missing-param class Model(_MyMutableMapping): _is_model = True # label whether current class's _attr_to_rest_field has been calculated # could not see _attr_to_rest_field directly because subclass inherits it from parent class - _calculated: typing.Set[str] = set() + _calculated: set[str] = set() def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: class_name = self.__class__.__name__ if len(args) > 1: raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") - dict_to_pass = { - rest_field._rest_name: rest_field._default - for rest_field in self._attr_to_rest_field.values() - if rest_field._default is not _UNSET - } - if args: # pylint: disable=too-many-nested-blocks + dict_to_pass: dict[str, typing.Any] = {} + if args: if isinstance(args[0], ET.Element): - existed_attr_keys = [] - model_meta = getattr(self, "_xml", {}) - - for rf in self._attr_to_rest_field.values(): - prop_meta = getattr(rf, "_xml", {}) - xml_name = prop_meta.get("name", rf._rest_name) - xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) - if xml_ns: - xml_name = "{" + xml_ns + "}" + xml_name - - # attribute - if prop_meta.get("attribute", False) and args[0].get(xml_name) is not None: - existed_attr_keys.append(xml_name) - dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].get(xml_name)) - continue - - # unwrapped element is array - if prop_meta.get("unwrapped", False): - # unwrapped array could either use prop items meta/prop meta - if prop_meta.get("itemsName"): - xml_name = prop_meta.get("itemsName") - xml_ns = prop_meta.get("itemNs") - if xml_ns: - xml_name = "{" + xml_ns + "}" + xml_name - items = args[0].findall(xml_name) # pyright: ignore - if len(items) > 0: - existed_attr_keys.append(xml_name) - dict_to_pass[rf._rest_name] = _deserialize(rf._type, items) - continue - - # text element is primitive type - if prop_meta.get("text", False): - if args[0].text is not None: - dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].text) - continue - - # wrapped element could be normal property or array, it should only have one element - item = args[0].find(xml_name) - if item is not None: - existed_attr_keys.append(xml_name) - dict_to_pass[rf._rest_name] = _deserialize(rf._type, item) - - # rest thing is additional properties - for e in args[0]: - if e.tag not in existed_attr_keys: - dict_to_pass[e.tag] = _convert_element(e) + dict_to_pass.update(self._init_from_xml(args[0])) else: dict_to_pass.update( {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} @@ -613,8 +853,117 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: if v is not None } ) + # Apply client default values for fields the caller didn't set so that + # defaults are part of `_data` and therefore included during serialization. + for rf in self._attr_to_rest_field.values(): + if rf._default is _UNSET: + continue + if rf._rest_name in dict_to_pass: + continue + dict_to_pass[rf._rest_name] = _create_value(rf, rf._default) super().__init__(dict_to_pass) + def _init_from_xml( # pylint: disable=too-many-branches, too-many-statements + self, element: ET.Element + ) -> dict[str, typing.Any]: + """Deserialize an XML element into a dict mapping rest field names to values. + + :param ET.Element element: The XML element to deserialize from. + :returns: A dictionary of rest_name to deserialized value pairs. + :rtype: dict + """ + result: dict[str, typing.Any] = {} + existed_attr_keys: list[str] = [] + + field_plan = getattr(self, "_xml_field_plan", None) + if field_plan: + for rest_name, xml_name, kind, deser, rf_type, is_optional, items_name in field_plan: + if kind == 0: # wrapped element (most common) + item = element.find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + if deser: + result[rest_name] = deser(item) + else: + result[rest_name] = _deserialize(rf_type, item) + elif kind == 1: # attribute + attr_val = element.get(xml_name) + if attr_val is not None: + existed_attr_keys.append(xml_name) + if deser: + result[rest_name] = deser(attr_val) + else: + result[rest_name] = attr_val + elif kind == 2: # unwrapped array + items = element.findall(items_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(items_name) + if deser: + result[rest_name] = deser(items) + else: + result[rest_name] = _deserialize(rf_type, items) + elif not is_optional: + existed_attr_keys.append(items_name) + result[rest_name] = [] + elif kind == 3: # text + if element.text is not None: + if deser: + result[rest_name] = deser(element.text) + else: + result[rest_name] = element.text + else: + model_meta = getattr(self, "_xml", {}) + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and element.get(xml_name) is not None: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, element.get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + _items_name = prop_meta.get("itemsName") + if _items_name: + xml_name = _items_name + _items_ns = prop_meta.get("itemsNs") + if _items_ns is not None: + xml_ns = _items_ns + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = element.findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, items) + elif not rf._is_optional: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = [] + continue + + # text element is primitive type + if prop_meta.get("text", False): + if element.text is not None: + result[rf._rest_name] = _deserialize(rf._type, element.text) + continue + + # wrapped element could be normal property or array + item = element.find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in element: + if e.tag not in existed_attr_keys: + result[e.tag] = _convert_element(e) + + return result + def copy(self) -> "Model": return Model(self.__dict__) @@ -623,7 +972,7 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order - attr_to_rest_field: typing.Dict[str, _RestField] = { # map attribute name to rest_field property + attr_to_rest_field: dict[str, _RestField] = { # map attribute name to rest_field property k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") } annotations = { @@ -638,7 +987,10 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) if not rf._rest_name_input: rf._rest_name_input = attr - cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) + cls._attr_to_rest_field: dict[str, _RestField] = dict(attr_to_rest_field.items()) + # Build XML field plan for fast _init_from_xml (only for XML models) + if getattr(cls, "_xml", None): + cls._xml_field_plan = _build_xml_field_plan(cls, attr_to_rest_field) cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") return super().__new__(cls) @@ -667,7 +1019,7 @@ def _deserialize(cls, data, exist_discriminators): model_meta = getattr(cls, "_xml", {}) prop_meta = getattr(discriminator, "_xml", {}) xml_name = prop_meta.get("name", discriminator._rest_name) - xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) if xml_ns: xml_name = "{" + xml_ns + "}" + xml_name @@ -680,7 +1032,7 @@ def _deserialize(cls, data, exist_discriminators): mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member return mapped_cls._deserialize(data, exist_discriminators) - def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]: + def as_dict(self, *, exclude_readonly: bool = False) -> dict[str, typing.Any]: """Return a dict that can be turned into json using json.dump. :keyword bool exclude_readonly: Whether to remove the readonly properties. @@ -740,7 +1092,7 @@ def _deserialize_with_union(deserializers, obj): def _deserialize_dict( value_deserializer: typing.Optional[typing.Callable], module: typing.Optional[str], - obj: typing.Dict[typing.Any, typing.Any], + obj: dict[typing.Any, typing.Any], ): if obj is None: return obj @@ -750,7 +1102,7 @@ def _deserialize_dict( def _deserialize_multiple_sequence( - entry_deserializers: typing.List[typing.Optional[typing.Callable]], + entry_deserializers: list[typing.Optional[typing.Callable]], module: typing.Optional[str], obj, ): @@ -759,6 +1111,14 @@ def _deserialize_multiple_sequence( return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) +def _is_array_encoded_deserializer(deserializer: functools.partial) -> bool: + return ( + isinstance(deserializer, functools.partial) + and isinstance(deserializer.args[0], functools.partial) + and deserializer.args[0].func == _deserialize_array_encoded # pylint: disable=comparison-with-callable + ) + + def _deserialize_sequence( deserializer: typing.Optional[typing.Callable], module: typing.Optional[str], @@ -768,17 +1128,30 @@ def _deserialize_sequence( return obj if isinstance(obj, ET.Element): obj = list(obj) + + # encoded string may be deserialized to sequence + if isinstance(obj, str) and isinstance(deserializer, functools.partial): + # for list[str] + if _is_array_encoded_deserializer(deserializer): + return deserializer(obj) + + # for list[Union[...]] + if isinstance(deserializer.args[0], list): + for sub_deserializer in deserializer.args[0]: + if _is_array_encoded_deserializer(sub_deserializer): + return sub_deserializer(obj) + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) -def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.Any]: +def _sorted_annotations(types: list[typing.Any]) -> list[typing.Any]: return sorted( types, key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), ) -def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-branches +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-statements, too-many-branches annotation: typing.Any, module: typing.Optional[str], rf: typing.Optional["_RestField"] = None, @@ -818,16 +1191,18 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur # is it optional? try: - if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore + if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore + if rf: + rf._is_optional = True if len(annotation.__args__) <= 2: # pyright: ignore if_obj_deserializer = _get_deserialize_callable_from_annotation( - next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore + next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore ) return functools.partial(_deserialize_with_optional, if_obj_deserializer) # the type is Optional[Union[...]], we need to remove the None type from the Union annotation_copy = copy.copy(annotation) - annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a is not _NONE_TYPE] # pyright: ignore return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) except AttributeError: pass @@ -843,7 +1218,10 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur return functools.partial(_deserialize_with_union, deserializers) try: - if annotation._name == "Dict": # pyright: ignore + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() == "dict": value_deserializer = _get_deserialize_callable_from_annotation( annotation.__args__[1], module, rf # pyright: ignore ) @@ -856,7 +1234,10 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur except (AttributeError, IndexError): pass try: - if annotation._name in ["List", "Set", "Tuple", "Sequence"]: # pyright: ignore + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() in ["list", "set", "tuple", "sequence"]: if len(annotation.__args__) > 1: # pyright: ignore entry_deserializers = [ _get_deserialize_callable_from_annotation(dt, module, rf) @@ -905,16 +1286,20 @@ def _deserialize_with_callable( return float(value.text) if value.text else None if deserializer is bool: return value.text == "true" if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING.values(): + return deserializer(value.text) if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING_WITHFORMAT.values(): + return deserializer(value.text) if value.text else None if deserializer is None: return value if deserializer in [int, float, bool]: return deserializer(value) if isinstance(deserializer, CaseInsensitiveEnumMeta): try: - return deserializer(value) + return deserializer(value.text if isinstance(value, ET.Element) else value) except ValueError: # for unknown value, return raw value - return value + return value.text if isinstance(value, ET.Element) else value if isinstance(deserializer, type) and issubclass(deserializer, Model): return deserializer._deserialize(value, []) return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) @@ -940,14 +1325,14 @@ def _deserialize( def _failsafe_deserialize( deserializer: typing.Any, - value: typing.Any, + response: HttpResponse, 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: + return _deserialize(deserializer, response.json(), module, rf, format) + except Exception: # pylint: disable=broad-except _LOGGER.warning( "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True ) @@ -956,17 +1341,18 @@ def _failsafe_deserialize( def _failsafe_deserialize_xml( deserializer: typing.Any, - value: typing.Any, + response: HttpResponse, ) -> typing.Any: try: - return _deserialize_xml(deserializer, value) - except DeserializationError: + return _deserialize_xml(deserializer, response.text()) + except Exception: # pylint: disable=broad-except _LOGGER.warning( "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True ) return None +# pylint: disable=too-many-instance-attributes class _RestField: def __init__( self, @@ -974,11 +1360,12 @@ def __init__( name: typing.Optional[str] = None, type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin is_discriminator: bool = False, - visibility: typing.Optional[typing.List[str]] = None, + visibility: typing.Optional[list[str]] = None, default: typing.Any = _UNSET, format: typing.Optional[str] = None, is_multipart_file_input: bool = False, - xml: typing.Optional[typing.Dict[str, typing.Any]] = None, + xml: typing.Optional[dict[str, typing.Any]] = None, + deserializer: typing.Optional[typing.Callable] = None, ): self._type = type self._rest_name_input = name @@ -986,14 +1373,20 @@ def __init__( self._is_discriminator = is_discriminator self._visibility = visibility self._is_model = False + self._is_optional = False self._default = default self._format = format self._is_multipart_file_input = is_multipart_file_input self._xml = xml if xml is not None else {} + self._deserializer = deserializer @property def _class_type(self) -> typing.Any: - return getattr(self._type, "args", [None])[0] + result = getattr(self._type, "args", [None])[0] + # type may be wrapped by nested functools.partial so we need to check for that + if isinstance(result, functools.partial): + return getattr(result, "args", [None])[0] + return result @property def _rest_name(self) -> str: @@ -1004,14 +1397,44 @@ def _rest_name(self) -> str: def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin # by this point, type and rest_name will have a value bc we default # them in __new__ of the Model class - item = obj.get(self._rest_name) + # Use _data.get() directly to avoid triggering __getitem__ which clears the cache + item = obj._data.get(self._rest_name, _UNSET) + if item is _UNSET: + # Field not set by user; return the client default if one exists, otherwise None + return self._default if self._default is not _UNSET else None if item is None: return item if self._is_model: return item - return _deserialize(self._type, _serialize(item, self._format), rf=self) + + # For mutable types, we want mutations to directly affect _data + # Check if we've already deserialized this value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + # Return the value from _data directly (it's been deserialized in place) + return obj._data.get(self._rest_name) + + # Fast path: use _deserializer directly (avoids _serialize/_deserialize chain) + if self._deserializer: + deserialized = self._deserializer(item) + else: + deserialized = _deserialize(self._type, _serialize(item, self._format), rf=self) + + # For mutable types, store the deserialized value back in _data + # so mutations directly affect _data + if isinstance(deserialized, (dict, list, set)): + obj._data[self._rest_name] = deserialized + object.__setattr__(obj, cache_attr, True) # Mark as deserialized + return deserialized + + return deserialized def __set__(self, obj: Model, value) -> None: + # Clear the cached deserialized object when setting a new value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + object.__delattr__(obj, cache_attr) + if value is None: # we want to wipe out entries if users set attr to None try: @@ -1036,11 +1459,12 @@ def rest_field( *, name: typing.Optional[str] = None, type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin - visibility: typing.Optional[typing.List[str]] = None, + visibility: typing.Optional[list[str]] = None, default: typing.Any = _UNSET, format: typing.Optional[str] = None, is_multipart_file_input: bool = False, - xml: typing.Optional[typing.Dict[str, typing.Any]] = None, + xml: typing.Optional[dict[str, typing.Any]] = None, + deserializer: typing.Optional[typing.Callable] = None, ) -> typing.Any: return _RestField( name=name, @@ -1050,6 +1474,7 @@ def rest_field( format=format, is_multipart_file_input=is_multipart_file_input, xml=xml, + deserializer=deserializer, ) @@ -1057,8 +1482,8 @@ def rest_discriminator( *, name: typing.Optional[str] = None, type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin - visibility: typing.Optional[typing.List[str]] = None, - xml: typing.Optional[typing.Dict[str, typing.Any]] = None, + visibility: typing.Optional[list[str]] = None, + xml: typing.Optional[dict[str, typing.Any]] = None, ) -> typing.Any: return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) @@ -1074,21 +1499,77 @@ def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore +def _get_xml_ns(meta: dict[str, typing.Any]) -> typing.Optional[str]: + """Return the XML namespace from a metadata dict, checking both 'ns' (old-style) and 'namespace' (DPG) keys. + + :param dict meta: The metadata dictionary to extract namespace from. + :returns: The namespace string if 'ns' or 'namespace' key is present, None otherwise. + :rtype: str or None + """ + ns = meta.get("ns") + if ns is None: + ns = meta.get("namespace") + return ns + + +def _resolve_xml_ns( + prop_meta: dict[str, typing.Any], model_meta: typing.Optional[dict[str, typing.Any]] = None +) -> typing.Optional[str]: + """Resolve XML namespace for a property, falling back to model namespace when appropriate. + + Checks the property metadata first; if no namespace is found and the model does not declare + an explicit prefix, falls back to the model-level namespace. + + :param dict prop_meta: The property metadata dictionary. + :param dict model_meta: The model metadata dictionary, used as fallback. + :returns: The resolved namespace string, or None. + :rtype: str or None + """ + ns = _get_xml_ns(prop_meta) + if ns is None and model_meta is not None and not model_meta.get("prefix"): + ns = _get_xml_ns(model_meta) + return ns + + +def _set_xml_attribute(element: ET.Element, name: str, value: typing.Any, prop_meta: dict[str, typing.Any]) -> None: + """Set an XML attribute on an element, handling namespace prefix registration. + + :param ET.Element element: The element to set the attribute on. + :param str name: The default attribute name (wire name). + :param any value: The attribute value. + :param dict prop_meta: The property metadata dictionary. + """ + xml_name = prop_meta.get("name", name) + _attr_ns = _get_xml_ns(prop_meta) + if _attr_ns: + _attr_prefix = prop_meta.get("prefix") + if _attr_prefix: + _safe_register_namespace(_attr_prefix, _attr_ns) + xml_name = "{" + _attr_ns + "}" + xml_name + element.set(xml_name, _get_primitive_type_value(value)) + + def _get_element( o: typing.Any, exclude_readonly: bool = False, - parent_meta: typing.Optional[typing.Dict[str, typing.Any]] = None, + parent_meta: typing.Optional[dict[str, typing.Any]] = None, wrapped_element: typing.Optional[ET.Element] = None, -) -> typing.Union[ET.Element, typing.List[ET.Element]]: +) -> typing.Union[ET.Element, list[ET.Element]]: if _is_model(o): model_meta = getattr(o, "_xml", {}) # if prop is a model, then use the prop element directly, else generate a wrapper of model if wrapped_element is None: + # When serializing as an array item (parent_meta is set), check if the parent has an + # explicit itemsName. This ensures correct element names for unwrapped arrays (where + # the element tag is the property/items name, not the model type name). + _items_name = parent_meta.get("itemsName") if parent_meta is not None else None + element_name = _items_name if _items_name else (model_meta.get("name") or o.__class__.__name__) + _model_ns = _get_xml_ns(model_meta) wrapped_element = _create_xml_element( - model_meta.get("name", o.__class__.__name__), + element_name, model_meta.get("prefix"), - model_meta.get("ns"), + _model_ns, ) readonly_props = [] @@ -1110,7 +1591,9 @@ def _get_element( # additional properties will not have rest field, use the wire name as xml name prop_meta = {"name": k} - # if no ns for prop, use model's + # Propagate model namespace to properties only for old-style "ns"-keyed models. + # DPG-generated models use the "namespace" key and explicitly declare namespace on + # each property that needs it, so propagation is intentionally skipped for them. if prop_meta.get("ns") is None and model_meta.get("ns"): prop_meta["ns"] = model_meta.get("ns") prop_meta["prefix"] = model_meta.get("prefix") @@ -1122,12 +1605,7 @@ def _get_element( # text could only set on primitive type wrapped_element.text = _get_primitive_type_value(v) elif prop_meta.get("attribute", False): - xml_name = prop_meta.get("name", k) - if prop_meta.get("ns"): - ET.register_namespace(prop_meta.get("prefix"), prop_meta.get("ns")) # pyright: ignore - xml_name = "{" + prop_meta.get("ns") + "}" + xml_name # pyright: ignore - # attribute should be primitive type - wrapped_element.set(xml_name, _get_primitive_type_value(v)) + _set_xml_attribute(wrapped_element, k, v, prop_meta) else: # other wrapped prop element wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) @@ -1136,6 +1614,7 @@ def _get_element( return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore if isinstance(o, dict): result = [] + _dict_ns = _get_xml_ns(parent_meta) if parent_meta else None for k, v in o.items(): result.append( _get_wrapped_element( @@ -1143,7 +1622,7 @@ def _get_element( exclude_readonly, { "name": k, - "ns": parent_meta.get("ns") if parent_meta else None, + "ns": _dict_ns, "prefix": parent_meta.get("prefix") if parent_meta else None, }, ) @@ -1152,13 +1631,16 @@ def _get_element( # primitive case need to create element based on parent_meta if parent_meta: + _items_ns = parent_meta.get("itemsNs") + if _items_ns is None: + _items_ns = _get_xml_ns(parent_meta) return _get_wrapped_element( o, exclude_readonly, { "name": parent_meta.get("itemsName", parent_meta.get("name")), "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), - "ns": parent_meta.get("itemsNs", parent_meta.get("ns")), + "ns": _items_ns, }, ) @@ -1168,10 +1650,11 @@ def _get_element( def _get_wrapped_element( v: typing.Any, exclude_readonly: bool, - meta: typing.Optional[typing.Dict[str, typing.Any]], + meta: typing.Optional[dict[str, typing.Any]], ) -> ET.Element: + _meta_ns = _get_xml_ns(meta) if meta else None wrapped_element = _create_xml_element( - meta.get("name") if meta else None, meta.get("prefix") if meta else None, meta.get("ns") if meta else None + meta.get("name") if meta else None, meta.get("prefix") if meta else None, _meta_ns ) if isinstance(v, (dict, list)): wrapped_element.extend(_get_element(v, exclude_readonly, meta)) @@ -1179,7 +1662,7 @@ def _get_wrapped_element( _get_element(v, exclude_readonly, meta, wrapped_element) else: wrapped_element.text = _get_primitive_type_value(v) - return wrapped_element + return wrapped_element # type: ignore[no-any-return] def _get_primitive_type_value(v) -> str: @@ -1192,9 +1675,29 @@ def _get_primitive_type_value(v) -> str: return str(v) -def _create_xml_element(tag, prefix=None, ns=None): - if prefix and ns: +def _safe_register_namespace(prefix: str, ns: str) -> None: + """Register an XML namespace prefix, handling reserved prefix patterns. + + Some prefixes (e.g. 'ns2') match Python's reserved 'ns\\d+' pattern used for + auto-generated prefixes, causing register_namespace to raise ValueError. + Falls back to directly registering in the internal namespace map. + + :param str prefix: The namespace prefix to register. + :param str ns: The namespace URI. + """ + try: ET.register_namespace(prefix, ns) + except ValueError: + _ns_map = getattr(ET, "_namespace_map", None) + if _ns_map is not None: + _ns_map[ns] = prefix + + +def _create_xml_element( + tag: typing.Any, prefix: typing.Optional[str] = None, ns: typing.Optional[str] = None +) -> ET.Element: + if prefix and ns: + _safe_register_namespace(prefix, ns) if ns: return ET.Element("{" + ns + "}" + tag) return ET.Element(tag) @@ -1205,13 +1708,15 @@ def _deserialize_xml( value: str, ) -> typing.Any: element = ET.fromstring(value) # nosec + if _is_model(deserializer): + return deserializer._deserialize(element, []) return _deserialize(deserializer, element) def _convert_element(e: ET.Element): # dict case if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: - dict_result: typing.Dict[str, typing.Any] = {} + dict_result: dict[str, typing.Any] = {} for child in e: if dict_result.get(child.tag) is not None: if isinstance(dict_result[child.tag], list): @@ -1224,7 +1729,7 @@ def _convert_element(e: ET.Element): return dict_result # array case if len(e) > 0: - array_result: typing.List[typing.Any] = [] + array_result: list[typing.Any] = [] for child in e: array_result.append(_convert_element(child)) return array_result diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_utils/serialization.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_utils/serialization.py index eb86ea23c965..a088671e9c51 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_utils/serialization.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_utils/serialization.py @@ -21,7 +21,6 @@ import sys import codecs from typing import ( - Dict, Any, cast, Optional, @@ -31,7 +30,6 @@ Mapping, Callable, MutableMapping, - List, ) try: @@ -41,11 +39,15 @@ 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 +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") JSON = MutableMapping[str, Any] @@ -229,12 +231,12 @@ class Model: serialization and deserialization. """ - _subtype_map: Dict[str, Dict[str, Any]] = {} - _attribute_map: Dict[str, Dict[str, Any]] = {} - _validation: Dict[str, Dict[str, Any]] = {} + _subtype_map: dict[str, dict[str, Any]] = {} + _attribute_map: dict[str, dict[str, Any]] = {} + _validation: dict[str, dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Optional[Dict[str, Any]] = {} + self.additional_properties: Optional[dict[str, Any]] = {} for k in kwargs: # pylint: disable=consider-using-dict-items if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -311,7 +313,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: def as_dict( self, keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + key_transformer: Callable[[str, dict[str, Any], Any], Any] = attribute_transformer, **kwargs: Any ) -> JSON: """Return a dict that can be serialized using json.dump. @@ -380,7 +382,7 @@ def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: def from_dict( cls, data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + key_extractors: Optional[Callable[[str, dict[str, Any], Any], Any]] = None, content_type: Optional[str] = None, ) -> Self: """Parse a dict using given key extractor return a model. @@ -414,7 +416,7 @@ def _flatten_subtype(cls, key, objects): return {} result = dict(cls._subtype_map[key]) for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access + result |= objects[valuetype]._flatten_subtype(key, objects) # pylint: disable=protected-access return result @classmethod @@ -528,7 +530,7 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.dependencies: dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -579,7 +581,7 @@ def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, to if attr_name == "additional_properties" and attr_desc["key"] == "": if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) + serialized |= target_obj.additional_properties continue try: @@ -789,7 +791,7 @@ def serialize_data(self, data, data_type, **kwargs): # If dependencies is empty, try with current data class # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) + enum_type = self.dependencies.get(data_type, cast(type, data.__class__)) if issubclass(enum_type, Enum): return Serializer.serialize_enum(data, enum_obj=enum_type) @@ -823,13 +825,20 @@ def serialize_basic(cls, data, data_type, **kwargs): :param str data_type: Type of object in the iterable. :rtype: str, int, float, bool :return: serialized object + :raises TypeError: raise if data_type is not one of str, int, float, bool. """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used + if data_type == "int": + return int(data) + if data_type == "float": + return float(data) + if data_type == "bool": + return bool(data) + raise TypeError("Unknown basic data type: {}".format(data_type)) @classmethod def serialize_unicode(cls, data): @@ -1184,7 +1193,7 @@ def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argumen while "." in key: # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) + dict_keys = cast(list[str], _FLATTEN.split(key)) if len(dict_keys) == 1: key = _decode_attribute_map_key(dict_keys[0]) break @@ -1386,7 +1395,7 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.dependencies: dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1396,7 +1405,7 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: # Otherwise, result are unexpected self.additional_properties_detection = True - def __call__(self, target_obj, response_data, content_type=None): + def __call__(self, target_obj, response_data, content_type=None): # pylint: disable=too-many-return-statements """Call the deserializer to process a REST response. :param str target_obj: Target data type to deserialize to. @@ -1406,6 +1415,27 @@ def __call__(self, target_obj, response_data, content_type=None): :return: Deserialized object. :rtype: object """ + # Fast path for header deserialization: response_data is a plain str or None + # and target_obj is a simple scalar type. This avoids the expensive + # _unpack_content → _deserialize → _classify_target → deserialize_data chain. + if response_data is None: + return None + if target_obj == "str" and isinstance(response_data, str): + return response_data + if isinstance(response_data, str): + if target_obj == "int": + return int(response_data) + if target_obj == "bool": + if response_data in ("true", "1", "True"): + return True + if response_data in ("false", "0", "False"): + return False + return bool(response_data) + if target_obj == "rfc-1123": + return Deserializer.deserialize_rfc(response_data) + if target_obj == "bytearray": + return Deserializer.deserialize_bytearray(response_data) + data = self._unpack_content(response_data, content_type) return self._deserialize(target_obj, data) @@ -1759,7 +1789,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 or data_type is not one of str, int, float, bool. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1785,7 +1815,11 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used + if data_type == "int": + return int(attr) + if data_type == "float": + return float(attr) + raise TypeError("Unknown basic data type: {}".format(data_type)) @staticmethod def deserialize_unicode(data): diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_validation.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_validation.py new file mode 100644 index 000000000000..f5af3a4eb8a2 --- /dev/null +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_validation.py @@ -0,0 +1,66 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools + + +def api_version_validation(**kwargs): + params_added_on = kwargs.pop("params_added_on", {}) + method_added_on = kwargs.pop("method_added_on", "") + api_versions_list = kwargs.pop("api_versions_list", []) + + def _index_with_default(value: str, default: int = -1) -> int: + """Get the index of value in lst, or return default if not found. + + :param value: The value to search for in the api_versions_list. + :type value: str + :param default: The default value to return if the value is not found. + :type default: int + :return: The index of the value in the list, or the default value if not found. + :rtype: int + """ + try: + return api_versions_list.index(value) + except ValueError: + return default + + def decorator(func): + @functools.wraps(func) + def wrapper(*args, **kwargs): + try: + # this assumes the client has an _api_version attribute + client = args[0] + client_api_version = client._config.api_version # pylint: disable=protected-access + except AttributeError: + return func(*args, **kwargs) + + if _index_with_default(method_added_on) > _index_with_default(client_api_version): + raise ValueError( + f"'{func.__name__}' is not available in API version " + f"{client_api_version}. Pass service API version {method_added_on} or newer to your client." + ) + + unsupported = { + parameter: api_version + for api_version, parameters in params_added_on.items() + for parameter in parameters + if parameter in kwargs and _index_with_default(api_version) > _index_with_default(client_api_version) + } + if unsupported: + raise ValueError( + "".join( + [ + f"'{param}' is not available in API version {client_api_version}. " + f"Use service API version {version} or newer.\n" + for param, version in unsupported.items() + ] + ) + ) + return func(*args, **kwargs) + + return wrapper + + return decorator diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_version.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_version.py index 0ec13ea52bbf..a1f432eddc4e 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_version.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/_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/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/_client.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/_client.py index acc71fd09bf8..1088583034e3 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/_client.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/_client.py @@ -7,8 +7,8 @@ # -------------------------------------------------------------------------- from copy import deepcopy +import sys 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 @@ -19,9 +19,15 @@ from .._utils.serialization import Deserializer, Serializer from ._configuration import MongoDBAtlasMgmtClientConfiguration -from .operations import Operations, OrganizationsOperations +from .operations import ClustersOperations, Operations, OrganizationsOperations, ProjectsOperations + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self # type: ignore if TYPE_CHECKING: + from azure.core import AzureClouds from azure.core.credentials_async import AsyncTokenCredential @@ -32,24 +38,39 @@ class MongoDBAtlasMgmtClient: :vartype operations: azure.mgmt.mongodbatlas.aio.operations.Operations :ivar organizations: OrganizationsOperations operations :vartype organizations: azure.mgmt.mongodbatlas.aio.operations.OrganizationsOperations + :ivar projects: ProjectsOperations operations + :vartype projects: azure.mgmt.mongodbatlas.aio.operations.ProjectsOperations + :ivar clusters: ClustersOperations operations + :vartype clusters: azure.mgmt.mongodbatlas.aio.operations.ClustersOperations :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 None. :type base_url: str - :keyword api_version: The API version to use for this operation. Default value is "2025-06-01". - Note that overriding this default value may result in unsupported behavior. + :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :paramtype cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2026-03-01-preview" and None. Default value is None. If not set, the operation's default API + version will be used. 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: Optional[str] = None, **kwargs: Any + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + *, + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any ) -> None: _endpoint = "{endpoint}" - _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore _endpoints = get_arm_endpoints(_cloud) if not base_url: base_url = _endpoints["resource_manager"] @@ -58,6 +79,7 @@ def __init__( credential=credential, subscription_id=subscription_id, base_url=cast(str, base_url), + cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs ) @@ -89,6 +111,8 @@ def __init__( self._serialize.client_side_validation = False self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.organizations = OrganizationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.projects = ProjectsOperations(self._client, self._config, self._serialize, self._deserialize) + self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize) def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/_configuration.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/_configuration.py index c8d8c31a1620..39e5c50b1635 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/_configuration.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/_configuration.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -14,6 +14,7 @@ from .._version import VERSION if TYPE_CHECKING: + from azure.core import AzureClouds from azure.core.credentials_async import AsyncTokenCredential @@ -29,8 +30,13 @@ class MongoDBAtlasMgmtClientConfiguration: # 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 "2025-06-01". - Note that overriding this default value may result in unsupported behavior. + :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :type cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2026-03-01-preview" and None. Default value is None. If not set, the operation's default API + version will be used. Note that overriding this default value may result in unsupported + behavior. :paramtype api_version: str """ @@ -39,9 +45,10 @@ def __init__( credential: "AsyncTokenCredential", subscription_id: str, base_url: str = "https://management.azure.com", + cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: - api_version: str = kwargs.pop("api_version", "2025-06-01") + api_version: str = kwargs.pop("api_version", "2026-03-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,6 +58,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.base_url = base_url + self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-mongodbatlas/{}".format(VERSION)) diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/_patch.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/_patch.py index 8bcb627aa475..87676c65a8f0 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/_patch.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/_patch.py @@ -7,9 +7,9 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/operations/__init__.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/operations/__init__.py index 72e76f8318ab..849fc45b425c 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/operations/__init__.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/operations/__init__.py @@ -14,6 +14,8 @@ from ._operations import Operations # type: ignore from ._operations import OrganizationsOperations # type: ignore +from ._operations import ProjectsOperations # type: ignore +from ._operations import ClustersOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * @@ -22,6 +24,8 @@ __all__ = [ "Operations", "OrganizationsOperations", + "ProjectsOperations", + "ClustersOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/operations/_operations.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/operations/_operations.py index 20ef70abc98b..94f3c2f181a1 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/operations/_operations.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/operations/_operations.py @@ -9,7 +9,7 @@ from collections.abc import MutableMapping from io import IOBase import json -from typing import Any, AsyncIterator, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core import AsyncPipelineClient @@ -36,7 +36,12 @@ from ... import models as _models 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_clusters_create_or_update_request, + build_clusters_delete_request, + build_clusters_get_request, + build_clusters_list_request, build_operations_list_request, build_organizations_create_or_update_request, build_organizations_delete_request, @@ -44,12 +49,19 @@ build_organizations_list_by_resource_group_request, build_organizations_list_by_subscription_request, build_organizations_update_request, + build_projects_create_or_update_request, + build_projects_delete_request, + build_projects_get_request, + build_projects_list_cluster_tier_regions_request, + build_projects_list_request, + build_projects_tier_limit_reached_request, ) from .._configuration import MongoDBAtlasMgmtClientConfiguration T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] JSON = MutableMapping[str, Any] +List = list class Operations: @@ -116,7 +128,10 @@ def prepare_request(next_link=None): ) _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 + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -129,7 +144,10 @@ 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.get("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) @@ -145,7 +163,10 @@ 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -211,6 +232,7 @@ async def get( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -225,11 +247,14 @@ async def get( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.OrganizationResource, response.json()) @@ -281,6 +306,7 @@ async def _create_or_update_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -294,7 +320,10 @@ async def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -304,7 +333,7 @@ async def _create_or_update_initial( ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -517,6 +546,7 @@ async def _update_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -530,7 +560,10 @@ async def _update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -538,7 +571,7 @@ async def _update_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -738,6 +771,7 @@ async def _delete_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -751,7 +785,10 @@ async def _delete_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -759,7 +796,7 @@ async def _delete_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -880,7 +917,10 @@ def prepare_request(next_link=None): ) _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 + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -893,7 +933,10 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.OrganizationResource], deserialized.get("value", [])) + list_of_elem = _deserialize( + List[_models.OrganizationResource], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -909,7 +952,10 @@ 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -965,7 +1011,10 @@ def prepare_request(next_link=None): ) _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 + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -978,7 +1027,10 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.OrganizationResource], deserialized.get("value", [])) + list_of_elem = _deserialize( + List[_models.OrganizationResource], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -994,9 +1046,1528 @@ 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) + + +class ProjectsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mongodbatlas.aio.MongoDBAtlasMgmtClient`'s + :attr:`projects` 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: MongoDBAtlasMgmtClientConfiguration = 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="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "accept", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + async def get( + self, resource_group_name: str, organization_name: str, project_name: str, **kwargs: Any + ) -> _models.Project: + """Get a Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :return: Project. The Project is compatible with MutableMapping + :rtype: ~azure.mgmt.mongodbatlas.models.Project + :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.Project] = kwargs.pop("cls", None) + + _request = build_projects_get_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_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) + + _decompress = kwargs.pop("decompress", True) + _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, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Project, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + async def _create_or_update_initial( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + resource: Union[_models.Project, 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_projects_create_or_update_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_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) + + _decompress = kwargs.pop("decompress", True) + _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, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + organization_name: str, + project_name: str, + resource: _models.Project, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Project]: + """Create a Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.mongodbatlas.models.Project + :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 Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mongodbatlas.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Project]: + """Create a Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_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 Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mongodbatlas.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Project]: + """Create a Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_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 Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mongodbatlas.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + async def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + resource: Union[_models.Project, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Project]: + """Create a Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :param resource: Resource create parameters. Is one of the following types: Project, JSON, + IO[bytes] Required. + :type resource: ~azure.mgmt.mongodbatlas.models.Project or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mongodbatlas.models.Project] + :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.Project] = 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, + organization_name=organization_name, + project_name=project_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.Project, 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.Project].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Project]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + async def _delete_initial( + self, resource_group_name: str, organization_name: str, project_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_projects_delete_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_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) + + _decompress = kwargs.pop("decompress", True) + _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, + ) + 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 _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + async def begin_delete( + self, resource_group_name: str, organization_name: str, project_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_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, + organization_name=organization_name, + project_name=project_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="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "accept", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + def list( + self, resource_group_name: str, organization_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Project"]: + """List Project resources by OrganizationResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :return: An iterator like instance of Project + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mongodbatlas.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Project]] = 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_projects_list_request( + resource_group_name=resource_group_name, + organization_name=organization_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), + headers=_headers, + 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.Project], + 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, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "accept", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + async def tier_limit_reached( + self, resource_group_name: str, organization_name: str, project_name: str, **kwargs: Any + ) -> _models.TierLimitReachedResponse: + """Check if tier limit is reached for the project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :return: TierLimitReachedResponse. The TierLimitReachedResponse is compatible with + MutableMapping + :rtype: ~azure.mgmt.mongodbatlas.models.TierLimitReachedResponse + :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.TierLimitReachedResponse] = kwargs.pop("cls", None) + + _request = build_projects_tier_limit_reached_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_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) + + _decompress = kwargs.pop("decompress", True) + _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, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TierLimitReachedResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "accept", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + async def list_cluster_tier_regions( + self, resource_group_name: str, organization_name: str, project_name: str, **kwargs: Any + ) -> _models.RegionsByTierResponse: + """List available regions by cluster tier for the project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :return: RegionsByTierResponse. The RegionsByTierResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.mongodbatlas.models.RegionsByTierResponse + :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.RegionsByTierResponse] = kwargs.pop("cls", None) + + _request = build_projects_list_cluster_tier_regions_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_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) + + _decompress = kwargs.pop("decompress", True) + _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, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RegionsByTierResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ClustersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mongodbatlas.aio.MongoDBAtlasMgmtClient`'s + :attr:`clusters` 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: MongoDBAtlasMgmtClientConfiguration = 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") + + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "cluster_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + async def _create_or_update_initial( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + cluster_name: str, + resource: Union[_models.Cluster, 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_clusters_create_or_update_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_name, + cluster_name=cluster_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) + + _decompress = kwargs.pop("decompress", True) + _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, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + organization_name: str, + project_name: str, + cluster_name: str, + resource: _models.Cluster, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Create a Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :param cluster_name: Name of the MongoDB Atlas Cluster resource. Required. + :type cluster_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.mongodbatlas.models.Cluster + :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 Cluster. The Cluster is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mongodbatlas.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + cluster_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Create a Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :param cluster_name: Name of the MongoDB Atlas Cluster resource. Required. + :type cluster_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 Cluster. The Cluster is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mongodbatlas.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + cluster_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Create a Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :param cluster_name: Name of the MongoDB Atlas Cluster resource. Required. + :type cluster_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 Cluster. The Cluster is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mongodbatlas.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "cluster_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + async def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + cluster_name: str, + resource: Union[_models.Cluster, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Create a Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :param cluster_name: Name of the MongoDB Atlas Cluster resource. Required. + :type cluster_name: str + :param resource: Resource create parameters. Is one of the following types: Cluster, JSON, + IO[bytes] Required. + :type resource: ~azure.mgmt.mongodbatlas.models.Cluster or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Cluster. The Cluster is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.mongodbatlas.models.Cluster] + :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.Cluster] = 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, + organization_name=organization_name, + project_name=project_name, + cluster_name=cluster_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.Cluster, 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.Cluster].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Cluster]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "cluster_name", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + async def _delete_initial( + self, resource_group_name: str, organization_name: str, project_name: str, cluster_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_clusters_delete_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_name, + cluster_name=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) + + _decompress = kwargs.pop("decompress", True) + _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, + ) + 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 _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "cluster_name", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + async def begin_delete( + self, resource_group_name: str, organization_name: str, project_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :param cluster_name: Name of the MongoDB Atlas Cluster resource. Required. + :type cluster_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, + organization_name=organization_name, + project_name=project_name, + cluster_name=cluster_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="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "accept", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + def list( + self, resource_group_name: str, organization_name: str, project_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Cluster"]: + """List Cluster resources by Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :return: An iterator like instance of Cluster + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.mongodbatlas.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Cluster]] = 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_clusters_list_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_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), + headers=_headers, + 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.Cluster], + 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, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "cluster_name", + "accept", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + async def get( + self, resource_group_name: str, organization_name: str, project_name: str, cluster_name: str, **kwargs: Any + ) -> _models.Cluster: + """Get a Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :param cluster_name: Name of the MongoDB Atlas Cluster resource. Required. + :type cluster_name: str + :return: Cluster. The Cluster is compatible with MutableMapping + :rtype: ~azure.mgmt.mongodbatlas.models.Cluster + :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.Cluster] = kwargs.pop("cls", None) + + _request = build_clusters_get_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_name, + cluster_name=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) + + _decompress = kwargs.pop("decompress", True) + _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, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Cluster, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/operations/_patch.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/operations/_patch.py index 8bcb627aa475..87676c65a8f0 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/operations/_patch.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/aio/operations/_patch.py @@ -7,9 +7,9 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/models/__init__.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/models/__init__.py index 4cc8124b48fb..0049d0679747 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/models/__init__.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/models/__init__.py @@ -14,6 +14,8 @@ from ._models import ( # type: ignore + Cluster, + ClusterProperties, ErrorAdditionalInfo, ErrorDetail, ErrorResponse, @@ -27,8 +29,15 @@ OrganizationResourceUpdate, OrganizationResourceUpdateProperties, PartnerProperties, + Project, + ProjectLimitStatus, + ProjectProperties, + ProxyResource, + RegionsByTierResponse, Resource, SystemData, + TierLimitReachedResponse, + TierRegions, TrackedResource, UserAssignedIdentity, UserDetails, @@ -36,6 +45,7 @@ from ._enums import ( # type: ignore ActionType, + ClusterTier, CreatedByType, ManagedServiceIdentityType, MarketplaceSubscriptionStatus, @@ -47,6 +57,8 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ + "Cluster", + "ClusterProperties", "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", @@ -60,12 +72,20 @@ "OrganizationResourceUpdate", "OrganizationResourceUpdateProperties", "PartnerProperties", + "Project", + "ProjectLimitStatus", + "ProjectProperties", + "ProxyResource", + "RegionsByTierResponse", "Resource", "SystemData", + "TierLimitReachedResponse", + "TierRegions", "TrackedResource", "UserAssignedIdentity", "UserDetails", "ActionType", + "ClusterTier", "CreatedByType", "ManagedServiceIdentityType", "MarketplaceSubscriptionStatus", diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/models/_enums.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/models/_enums.py index b1e1e2f4dc65..ec635e582c9f 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/models/_enums.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/models/_enums.py @@ -19,6 +19,19 @@ class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Actions are for internal-only APIs.""" +class ClusterTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Cluster tier options for MongoDB Atlas.""" + + FREE = "FREE" + """Free tier cluster.""" + FLEX = "FLEX" + """Flex tier cluster.""" + M10 = "M10" + """M10 tier cluster.""" + M30 = "M30" + """M30 tier cluster.""" + + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The kind of entity that created the resource.""" @@ -51,13 +64,13 @@ class MarketplaceSubscriptionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta """Marketplace subscription status of a resource.""" PENDING_FULFILLMENT_START = "PendingFulfillmentStart" - """Purchased but not yet activated""" + """Purchased but not yet activated.""" SUBSCRIBED = "Subscribed" - """Marketplace subscription is activated""" + """Marketplace subscription is activated.""" SUSPENDED = "Suspended" - """This state indicates that a customer's payment for the Marketplace service was not received""" + """This state indicates that a customer's payment for the Marketplace service was not received.""" UNSUBSCRIBED = "Unsubscribed" - """Customer has cancelled the subscription""" + """Customer has cancelled the subscription.""" class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/models/_models.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/models/_models.py index dd165bd29b42..2454681603af 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/models/_models.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/models/_models.py @@ -1,4 +1,4 @@ -# pylint: disable=line-too-long,useless-suppression +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -9,7 +9,7 @@ # pylint: disable=useless-super-delegation import datetime -from typing import Any, Dict, List, Mapping, Optional, TYPE_CHECKING, Union, overload +from typing import Any, Mapping, Optional, TYPE_CHECKING, Union, overload from .._utils.model_base import Model as _Model, rest_field @@ -17,6 +17,152 @@ from .. import models as _models +class Resource(_Model): + """Resource. + + :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.mongodbatlas.models.SystemData + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Fully qualified resource ID for the resource. Ex - + /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"]) + """The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or + \"Microsoft.Storage/storageAccounts\".""" + system_data: Optional["_models.SystemData"] = rest_field(name="systemData", visibility=["read"]) + """Azure Resource Manager metadata containing createdBy and modifiedBy information.""" + + +class ProxyResource(Resource): + """Proxy Resource. + + :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.mongodbatlas.models.SystemData + """ + + +class Cluster(ProxyResource): + """The MongoDB Atlas Cluster resource type. A cluster is a managed database deployment within a + project. + + :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.mongodbatlas.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.mongodbatlas.models.ClusterProperties + """ + + properties: Optional["_models.ClusterProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The resource-specific properties for this resource.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.ClusterProperties"] = 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 ClusterProperties(_Model): + """Properties specific to a MongoDB Atlas Cluster. + + :ivar cluster_name: Name of the MongoDB Atlas Cluster. + :vartype cluster_name: str + :ivar cluster_tier: Cluster tier (FREE, FLEX, M10, M30). Required. Known values are: "FREE", + "FLEX", "M10", and "M30". + :vartype cluster_tier: str or ~azure.mgmt.mongodbatlas.models.ClusterTier + :ivar region_name: Azure region where the cluster is deployed. Required. + :vartype region_name: str + :ivar mongo_db_version: MongoDB version running on the cluster. + :vartype mongo_db_version: str + :ivar backups: Whether backups are active for the cluster; null if undetermined. + :vartype backups: bool + :ivar state: Current state of the cluster. + :vartype state: str + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Succeeded", + "Failed", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.mongodbatlas.models.ResourceProvisioningState + """ + + cluster_name: Optional[str] = rest_field(name="clusterName", visibility=["read"]) + """Name of the MongoDB Atlas Cluster.""" + cluster_tier: Union[str, "_models.ClusterTier"] = rest_field(name="clusterTier", visibility=["read", "create"]) + """Cluster tier (FREE, FLEX, M10, M30). Required. Known values are: \"FREE\", \"FLEX\", \"M10\", + and \"M30\".""" + region_name: str = rest_field(name="regionName", visibility=["read", "create"]) + """Azure region where the cluster is deployed. Required.""" + mongo_db_version: Optional[str] = rest_field(name="mongoDbVersion", visibility=["read"]) + """MongoDB version running on the cluster.""" + backups: Optional[bool] = rest_field(visibility=["read"]) + """Whether backups are active for the cluster; null if undetermined.""" + state: Optional[str] = rest_field(visibility=["read"]) + """Current state of the cluster.""" + provisioning_state: Optional[Union[str, "_models.ResourceProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the resource. Known values are: \"Succeeded\", \"Failed\", and + \"Canceled\".""" + + @overload + def __init__( + self, + *, + cluster_tier: Union[str, "_models.ClusterTier"], + region_name: 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 ErrorAdditionalInfo(_Model): """The resource management error additional info. @@ -53,9 +199,9 @@ class ErrorDetail(_Model): """The error message.""" target: Optional[str] = rest_field(visibility=["read"]) """The error target.""" - details: Optional[List["_models.ErrorDetail"]] = rest_field(visibility=["read"]) + details: Optional[list["_models.ErrorDetail"]] = rest_field(visibility=["read"]) """The error details.""" - additional_info: Optional[List["_models.ErrorAdditionalInfo"]] = rest_field( + additional_info: Optional[list["_models.ErrorAdditionalInfo"]] = rest_field( name="additionalInfo", visibility=["read"] ) """The error additional info.""" @@ -117,7 +263,7 @@ class ManagedServiceIdentity(_Model): ) """The type of managed identity assigned to this resource. Required. Known values are: \"None\", \"SystemAssigned\", \"UserAssigned\", and \"SystemAssigned,UserAssigned\".""" - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = rest_field( + user_assigned_identities: Optional[dict[str, "_models.UserAssignedIdentity"]] = rest_field( name="userAssignedIdentities", visibility=["read", "create", "update", "delete", "query"] ) """The identities assigned to this resource by the user.""" @@ -127,7 +273,7 @@ def __init__( self, *, type: Union[str, "_models.ManagedServiceIdentityType"], - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, + user_assigned_identities: Optional[dict[str, "_models.UserAssignedIdentity"]] = None, ) -> None: ... @overload @@ -297,7 +443,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class OperationDisplay(_Model): - """Localized display information for and operation. + """Localized display information for an operation. :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". @@ -375,34 +521,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class Resource(_Model): - """Resource. - - :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.mongodbatlas.models.SystemData - """ - - id: Optional[str] = rest_field(visibility=["read"]) - """Fully qualified resource ID for the resource. Ex - - /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"]) - """The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or - \"Microsoft.Storage/storageAccounts\".""" - system_data: Optional["_models.SystemData"] = rest_field(name="systemData", visibility=["read"]) - """Azure Resource Manager metadata containing createdBy and modifiedBy information.""" - - class TrackedResource(Resource): """Tracked Resource. @@ -423,7 +541,7 @@ class TrackedResource(Resource): :vartype location: str """ - tags: Optional[Dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + 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.""" @@ -433,7 +551,7 @@ def __init__( self, *, location: str, - tags: Optional[Dict[str, str]] = None, + tags: Optional[dict[str, str]] = None, ) -> None: ... @overload @@ -485,7 +603,7 @@ def __init__( self, *, location: str, - tags: Optional[Dict[str, str]] = None, + tags: Optional[dict[str, str]] = None, properties: Optional["_models.OrganizationProperties"] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, ) -> None: ... @@ -516,7 +634,7 @@ class OrganizationResourceUpdate(_Model): visibility=["read", "create", "update", "delete", "query"] ) """The managed service identities assigned to this resource.""" - tags: Optional[Dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Resource tags.""" properties: Optional["_models.OrganizationResourceUpdateProperties"] = rest_field( visibility=["read", "create", "update", "delete", "query"] @@ -528,7 +646,7 @@ def __init__( self, *, identity: Optional["_models.ManagedServiceIdentity"] = None, - tags: Optional[Dict[str, str]] = None, + tags: Optional[dict[str, str]] = None, properties: Optional["_models.OrganizationResourceUpdateProperties"] = None, ) -> None: ... @@ -622,6 +740,141 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) +class Project(ProxyResource): + """The MongoDB Atlas Project resource type. A project is a logical grouping of clusters within an + organization. + + :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.mongodbatlas.models.SystemData + :ivar properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.mongodbatlas.models.ProjectProperties + """ + + properties: Optional["_models.ProjectProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The resource-specific properties for this resource.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.ProjectProperties"] = 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 ProjectLimitStatus(_Model): + """Usage and limit status for a resource quota in a MongoDB Atlas project. + + :ivar type: Type of the limit. Required. Known values are: "FREE", "FLEX", "M10", and "M30". + :vartype type: str or ~azure.mgmt.mongodbatlas.models.ClusterTier + :ivar maximum: Maximum allowed value. Required. + :vartype maximum: int + :ivar current: Current value. Required. + :vartype current: int + :ivar is_reached: Whether the limit has been reached. Required. + :vartype is_reached: bool + """ + + type: Union[str, "_models.ClusterTier"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Type of the limit. Required. Known values are: \"FREE\", \"FLEX\", \"M10\", and \"M30\".""" + maximum: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Maximum allowed value. Required.""" + current: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Current value. Required.""" + is_reached: bool = rest_field(name="isReached", visibility=["read", "create", "update", "delete", "query"]) + """Whether the limit has been reached. Required.""" + + @overload + def __init__( + self, + *, + type: Union[str, "_models.ClusterTier"], + maximum: int, + current: int, + is_reached: bool, + ) -> 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 ProjectProperties(_Model): + """Properties specific to a MongoDB Atlas Project. + + :ivar project_id: Atlas project id. + :vartype project_id: str + :ivar project_name: Atlas project name. + :vartype project_name: str + :ivar organization_id: Atlas organization id. + :vartype organization_id: str + :ivar cluster_count: Number of clusters in the project. + :vartype cluster_count: int + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Succeeded", + "Failed", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.mongodbatlas.models.ResourceProvisioningState + """ + + project_id: Optional[str] = rest_field(name="projectId", visibility=["read"]) + """Atlas project id.""" + project_name: Optional[str] = rest_field(name="projectName", visibility=["read"]) + """Atlas project name.""" + organization_id: Optional[str] = rest_field(name="organizationId", visibility=["read"]) + """Atlas organization id.""" + cluster_count: Optional[int] = rest_field(name="clusterCount", visibility=["read"]) + """Number of clusters in the project.""" + provisioning_state: Optional[Union[str, "_models.ResourceProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the resource. Known values are: \"Succeeded\", \"Failed\", and + \"Canceled\".""" + + +class RegionsByTierResponse(_Model): + """Response for regions by cluster tier. + + :ivar organization_id: Atlas organization id. Required. + :vartype organization_id: str + :ivar project_id: Atlas project id. Required. + :vartype project_id: str + :ivar regions_by_tier: List of cluster tiers and their supported regions. Required. + :vartype regions_by_tier: list[~azure.mgmt.mongodbatlas.models.TierRegions] + """ + + organization_id: str = rest_field(name="organizationId", visibility=["read"]) + """Atlas organization id. Required.""" + project_id: str = rest_field(name="projectId", visibility=["read"]) + """Atlas project id. Required.""" + regions_by_tier: list["_models.TierRegions"] = rest_field(name="regionsByTier", visibility=["read"]) + """List of cluster tiers and their supported regions. Required.""" + + class SystemData(_Model): """Metadata pertaining to creation and last modification of the resource. @@ -689,6 +942,50 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) +class TierLimitReachedResponse(_Model): + """Response for tier limit check. + + :ivar limits: List of project limit statuses. Required. + :vartype limits: list[~azure.mgmt.mongodbatlas.models.ProjectLimitStatus] + """ + + limits: list["_models.ProjectLimitStatus"] = rest_field(visibility=["read"]) + """List of project limit statuses. Required.""" + + +class TierRegions(_Model): + """Cluster tier and its supported regions. + + :ivar tier: Cluster tier name. Required. Known values are: "FREE", "FLEX", "M10", and "M30". + :vartype tier: str or ~azure.mgmt.mongodbatlas.models.ClusterTier + :ivar regions: Supported region names. Required. + :vartype regions: list[str] + """ + + tier: Union[str, "_models.ClusterTier"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Cluster tier name. Required. Known values are: \"FREE\", \"FLEX\", \"M10\", and \"M30\".""" + regions: list[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Supported region names. Required.""" + + @overload + def __init__( + self, + *, + tier: Union[str, "_models.ClusterTier"], + regions: list[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 UserAssignedIdentity(_Model): """User assigned identity properties. diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/models/_patch.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/models/_patch.py index 8bcb627aa475..87676c65a8f0 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/models/_patch.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/models/_patch.py @@ -7,9 +7,9 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/operations/__init__.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/operations/__init__.py index 72e76f8318ab..849fc45b425c 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/operations/__init__.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/operations/__init__.py @@ -14,6 +14,8 @@ from ._operations import Operations # type: ignore from ._operations import OrganizationsOperations # type: ignore +from ._operations import ProjectsOperations # type: ignore +from ._operations import ClustersOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * @@ -22,6 +24,8 @@ __all__ = [ "Operations", "OrganizationsOperations", + "ProjectsOperations", + "ClustersOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/operations/_operations.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/operations/_operations.py index bfa6113107f3..6af73de235da 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/operations/_operations.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/operations/_operations.py @@ -9,7 +9,7 @@ from collections.abc import MutableMapping from io import IOBase import json -from typing import Any, Callable, Dict, IO, Iterator, List, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core import PipelineClient @@ -36,10 +36,12 @@ from .._configuration import MongoDBAtlasMgmtClientConfiguration from .._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from .._utils.serialization import Deserializer, Serializer +from .._validation import api_version_validation T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] JSON = MutableMapping[str, Any] +List = list _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False @@ -49,7 +51,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", "2025-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +72,7 @@ def build_organizations_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", "2025-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,7 +101,7 @@ def build_organizations_create_or_update_request( # pylint: disable=name-too-lo _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-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -130,7 +132,7 @@ def build_organizations_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", "2025-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -157,12 +159,9 @@ def build_organizations_update_request( def build_organizations_delete_request( resource_group_name: str, organization_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-06-01")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-03-01-preview")) # Construct URL _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}" path_format_arguments = { @@ -176,10 +175,7 @@ def build_organizations_delete_request( # 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) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_organizations_list_by_resource_group_request( # pylint: disable=name-too-long @@ -188,7 +184,7 @@ def build_organizations_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", "2025-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -215,7 +211,7 @@ def build_organizations_list_by_subscription_request( # pylint: disable=name-to _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-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-03-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -235,6 +231,307 @@ def build_organizations_list_by_subscription_request( # pylint: disable=name-to return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) +def build_projects_get_request( + resource_group_name: str, organization_name: str, project_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", "2026-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}/projects/{projectName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_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_projects_create_or_update_request( + resource_group_name: str, organization_name: str, project_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", "2026-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}/projects/{projectName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_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_projects_delete_request( + resource_group_name: str, organization_name: str, project_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}/projects/{projectName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_projects_list_request( + resource_group_name: str, organization_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", "2026-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}/projects" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "organizationName": _SERIALIZER.url("organization_name", organization_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_projects_tier_limit_reached_request( # pylint: disable=name-too-long + resource_group_name: str, organization_name: str, project_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", "2026-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}/projects/{projectName}/tierLimitReached" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_projects_list_cluster_tier_regions_request( # pylint: disable=name-too-long + resource_group_name: str, organization_name: str, project_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", "2026-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}/projects/{projectName}/clusterTierRegions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_clusters_create_or_update_request( + resource_group_name: str, + organization_name: str, + project_name: str, + cluster_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}/projects/{projectName}/clusters/{clusterName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_clusters_delete_request( + resource_group_name: str, + organization_name: str, + project_name: str, + cluster_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}/projects/{projectName}/clusters/{clusterName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_clusters_list_request( + resource_group_name: str, organization_name: str, project_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", "2026-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}/projects/{projectName}/clusters" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_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_clusters_get_request( + resource_group_name: str, + organization_name: str, + project_name: str, + cluster_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2026-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}/projects/{projectName}/clusters/{clusterName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "organizationName": _SERIALIZER.url("organization_name", organization_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + class Operations: """ .. warning:: @@ -299,7 +596,10 @@ def prepare_request(next_link=None): ) _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 + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -312,7 +612,10 @@ 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.get("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) @@ -328,7 +631,10 @@ 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -392,6 +698,7 @@ def get(self, resource_group_name: str, organization_name: str, **kwargs: Any) - } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -406,11 +713,14 @@ def get(self, resource_group_name: str, organization_name: str, **kwargs: Any) - except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if _stream: - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: deserialized = _deserialize(_models.OrganizationResource, response.json()) @@ -462,6 +772,7 @@ def _create_or_update_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -475,7 +786,10 @@ def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -485,7 +799,7 @@ def _create_or_update_initial( ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -694,6 +1008,7 @@ def _update_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -707,7 +1022,10 @@ def _update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -715,7 +1033,7 @@ def _update_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -909,6 +1227,7 @@ def _delete_initial(self, resource_group_name: str, organization_name: str, **kw } _request.url = self._client.format_url(_request.url, **path_format_arguments) + _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs @@ -922,7 +1241,10 @@ def _delete_initial(self, resource_group_name: str, organization_name: str, **kw except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -930,7 +1252,7 @@ def _delete_initial(self, resource_group_name: str, organization_name: str, **kw response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = response.iter_bytes() + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1048,7 +1370,10 @@ def prepare_request(next_link=None): ) _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 + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -1061,7 +1386,10 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.OrganizationResource], deserialized.get("value", [])) + list_of_elem = _deserialize( + List[_models.OrganizationResource], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -1077,7 +1405,10 @@ 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -1132,7 +1463,10 @@ def prepare_request(next_link=None): ) _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 + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) path_format_arguments = { "endpoint": self._serialize.url( @@ -1145,7 +1479,10 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.OrganizationResource], deserialized.get("value", [])) + list_of_elem = _deserialize( + List[_models.OrganizationResource], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -1161,9 +1498,1526 @@ 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 = _failsafe_deserialize(_models.ErrorResponse, response.json()) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) + + +class ProjectsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mongodbatlas.MongoDBAtlasMgmtClient`'s + :attr:`projects` 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: MongoDBAtlasMgmtClientConfiguration = 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="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "accept", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + def get( + self, resource_group_name: str, organization_name: str, project_name: str, **kwargs: Any + ) -> _models.Project: + """Get a Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :return: Project. The Project is compatible with MutableMapping + :rtype: ~azure.mgmt.mongodbatlas.models.Project + :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.Project] = kwargs.pop("cls", None) + + _request = build_projects_get_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_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) + + _decompress = kwargs.pop("decompress", True) + _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, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Project, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + def _create_or_update_initial( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + resource: Union[_models.Project, 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_projects_create_or_update_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_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) + + _decompress = kwargs.pop("decompress", True) + _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, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + organization_name: str, + project_name: str, + resource: _models.Project, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Project]: + """Create a Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.mongodbatlas.models.Project + :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 Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mongodbatlas.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Project]: + """Create a Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_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 Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mongodbatlas.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Project]: + """Create a Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_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 Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mongodbatlas.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + resource: Union[_models.Project, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Project]: + """Create a Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :param resource: Resource create parameters. Is one of the following types: Project, JSON, + IO[bytes] Required. + :type resource: ~azure.mgmt.mongodbatlas.models.Project or JSON or IO[bytes] + :return: An instance of LROPoller that returns Project. The Project is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mongodbatlas.models.Project] + :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.Project] = 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, + organization_name=organization_name, + project_name=project_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.Project, 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.Project].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Project]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + def _delete_initial( + self, resource_group_name: str, organization_name: str, project_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_projects_delete_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_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) + + _decompress = kwargs.pop("decompress", True) + _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, + ) + 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 _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + def begin_delete( + self, resource_group_name: str, organization_name: str, project_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete a Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_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, + organization_name=organization_name, + project_name=project_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="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "accept", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + def list(self, resource_group_name: str, organization_name: str, **kwargs: Any) -> ItemPaged["_models.Project"]: + """List Project resources by OrganizationResource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :return: An iterator like instance of Project + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mongodbatlas.models.Project] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Project]] = 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_projects_list_request( + resource_group_name=resource_group_name, + organization_name=organization_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), + headers=_headers, + 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.Project], + 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, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "accept", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + def tier_limit_reached( + self, resource_group_name: str, organization_name: str, project_name: str, **kwargs: Any + ) -> _models.TierLimitReachedResponse: + """Check if tier limit is reached for the project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :return: TierLimitReachedResponse. The TierLimitReachedResponse is compatible with + MutableMapping + :rtype: ~azure.mgmt.mongodbatlas.models.TierLimitReachedResponse + :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.TierLimitReachedResponse] = kwargs.pop("cls", None) + + _request = build_projects_tier_limit_reached_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_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) + + _decompress = kwargs.pop("decompress", True) + _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, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TierLimitReachedResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "accept", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + def list_cluster_tier_regions( + self, resource_group_name: str, organization_name: str, project_name: str, **kwargs: Any + ) -> _models.RegionsByTierResponse: + """List available regions by cluster tier for the project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :return: RegionsByTierResponse. The RegionsByTierResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.mongodbatlas.models.RegionsByTierResponse + :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.RegionsByTierResponse] = kwargs.pop("cls", None) + + _request = build_projects_list_cluster_tier_regions_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_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) + + _decompress = kwargs.pop("decompress", True) + _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, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RegionsByTierResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ClustersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.mongodbatlas.MongoDBAtlasMgmtClient`'s + :attr:`clusters` 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: MongoDBAtlasMgmtClientConfiguration = 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") + + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "cluster_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + def _create_or_update_initial( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + cluster_name: str, + resource: Union[_models.Cluster, 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_clusters_create_or_update_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_name, + cluster_name=cluster_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) + + _decompress = kwargs.pop("decompress", True) + _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, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + organization_name: str, + project_name: str, + cluster_name: str, + resource: _models.Cluster, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Create a Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :param cluster_name: Name of the MongoDB Atlas Cluster resource. Required. + :type cluster_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.mongodbatlas.models.Cluster + :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 Cluster. The Cluster is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mongodbatlas.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + cluster_name: str, + resource: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Create a Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :param cluster_name: Name of the MongoDB Atlas Cluster resource. Required. + :type cluster_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 Cluster. The Cluster is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mongodbatlas.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + cluster_name: str, + resource: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Create a Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :param cluster_name: Name of the MongoDB Atlas Cluster resource. Required. + :type cluster_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 Cluster. The Cluster is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mongodbatlas.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "cluster_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + def begin_create_or_update( + self, + resource_group_name: str, + organization_name: str, + project_name: str, + cluster_name: str, + resource: Union[_models.Cluster, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Create a Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :param cluster_name: Name of the MongoDB Atlas Cluster resource. Required. + :type cluster_name: str + :param resource: Resource create parameters. Is one of the following types: Cluster, JSON, + IO[bytes] Required. + :type resource: ~azure.mgmt.mongodbatlas.models.Cluster or JSON or IO[bytes] + :return: An instance of LROPoller that returns Cluster. The Cluster is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.mongodbatlas.models.Cluster] + :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.Cluster] = 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, + organization_name=organization_name, + project_name=project_name, + cluster_name=cluster_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.Cluster, 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.Cluster].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Cluster]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "cluster_name", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + def _delete_initial( + self, resource_group_name: str, organization_name: str, project_name: str, cluster_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_clusters_delete_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_name, + cluster_name=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) + + _decompress = kwargs.pop("decompress", True) + _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, + ) + 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 _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "cluster_name", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + def begin_delete( + self, resource_group_name: str, organization_name: str, project_name: str, cluster_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete a Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :param cluster_name: Name of the MongoDB Atlas Cluster resource. Required. + :type cluster_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, + organization_name=organization_name, + project_name=project_name, + cluster_name=cluster_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="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "accept", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + def list( + self, resource_group_name: str, organization_name: str, project_name: str, **kwargs: Any + ) -> ItemPaged["_models.Cluster"]: + """List Cluster resources by Project. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :return: An iterator like instance of Cluster + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.mongodbatlas.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Cluster]] = 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_clusters_list_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_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), + headers=_headers, + 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.Cluster], + 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, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + @api_version_validation( + method_added_on="2026-03-01-preview", + params_added_on={ + "2026-03-01-preview": [ + "api_version", + "subscription_id", + "resource_group_name", + "organization_name", + "project_name", + "cluster_name", + "accept", + ] + }, + api_versions_list=["2026-03-01-preview"], + ) + def get( + self, resource_group_name: str, organization_name: str, project_name: str, cluster_name: str, **kwargs: Any + ) -> _models.Cluster: + """Get a Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param organization_name: Name of the Organization resource. Required. + :type organization_name: str + :param project_name: Name of the MongoDB Atlas Project resource. Required. + :type project_name: str + :param cluster_name: Name of the MongoDB Atlas Cluster resource. Required. + :type cluster_name: str + :return: Cluster. The Cluster is compatible with MutableMapping + :rtype: ~azure.mgmt.mongodbatlas.models.Cluster + :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.Cluster] = kwargs.pop("cls", None) + + _request = build_clusters_get_request( + resource_group_name=resource_group_name, + organization_name=organization_name, + project_name=project_name, + cluster_name=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) + + _decompress = kwargs.pop("decompress", True) + _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, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Cluster, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/operations/_patch.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/operations/_patch.py index 8bcb627aa475..87676c65a8f0 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/operations/_patch.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/azure/mgmt/mongodbatlas/operations/_patch.py @@ -7,9 +7,9 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/clusters_create_or_update_maximum_set_gen.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/clusters_create_or_update_maximum_set_gen.py new file mode 100644 index 000000000000..cefdc5fde77b --- /dev/null +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/clusters_create_or_update_maximum_set_gen.py @@ -0,0 +1,45 @@ +# 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.mongodbatlas import MongoDBAtlasMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mongodbatlas +# USAGE + python clusters_create_or_update_maximum_set_gen.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 = MongoDBAtlasMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.clusters.begin_create_or_update( + resource_group_name="rgopenapi", + organization_name="myOrganization", + project_name="myProject", + cluster_name="myCluster", + resource={"properties": {"clusterTier": "FREE", "regionName": "eastus"}}, + ).result() + print(response) + + +# x-ms-original-file: 2026-03-01-preview/Clusters_CreateOrUpdate_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/clusters_delete_maximum_set_gen.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/clusters_delete_maximum_set_gen.py new file mode 100644 index 000000000000..b85516773706 --- /dev/null +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/clusters_delete_maximum_set_gen.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.mongodbatlas import MongoDBAtlasMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mongodbatlas +# USAGE + python clusters_delete_maximum_set_gen.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 = MongoDBAtlasMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.clusters.begin_delete( + resource_group_name="rgopenapi", + organization_name="myOrganization", + project_name="myProject", + cluster_name="myCluster", + ).result() + + +# x-ms-original-file: 2026-03-01-preview/Clusters_Delete_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/clusters_get_maximum_set_gen.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/clusters_get_maximum_set_gen.py new file mode 100644 index 000000000000..9bea1fd6f289 --- /dev/null +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/clusters_get_maximum_set_gen.py @@ -0,0 +1,44 @@ +# 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.mongodbatlas import MongoDBAtlasMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mongodbatlas +# USAGE + python clusters_get_maximum_set_gen.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 = MongoDBAtlasMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.clusters.get( + resource_group_name="rgopenapi", + organization_name="myOrganization", + project_name="myProject", + cluster_name="myCluster", + ) + print(response) + + +# x-ms-original-file: 2026-03-01-preview/Clusters_Get_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/clusters_list_maximum_set_gen.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/clusters_list_maximum_set_gen.py new file mode 100644 index 000000000000..bd85f6f7cd5c --- /dev/null +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/clusters_list_maximum_set_gen.py @@ -0,0 +1,44 @@ +# 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.mongodbatlas import MongoDBAtlasMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mongodbatlas +# USAGE + python clusters_list_maximum_set_gen.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 = MongoDBAtlasMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.clusters.list( + resource_group_name="rgopenapi", + organization_name="myOrganization", + project_name="myProject", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2026-03-01-preview/Clusters_List_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/operations_list_maximum_set_gen.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/operations_list_maximum_set_gen.py index fbf2059c1aa5..885f1a5533ef 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/operations_list_maximum_set_gen.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/operations_list_maximum_set_gen.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: 2025-06-01/Operations_List_MaximumSet_Gen.json +# x-ms-original-file: 2026-03-01-preview/Operations_List_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/operations_list_minimum_set_gen.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/operations_list_minimum_set_gen.py index 8f7ff40b821a..1c5c3f987901 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/operations_list_minimum_set_gen.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/operations_list_minimum_set_gen.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: 2025-06-01/Operations_List_MinimumSet_Gen.json +# x-ms-original-file: 2026-03-01-preview/Operations_List_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_create_or_update_maximum_set_gen.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_create_or_update_maximum_set_gen.py index aac23b19a110..c1d76f561934 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_create_or_update_maximum_set_gen.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_create_or_update_maximum_set_gen.py @@ -69,6 +69,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01/Organizations_CreateOrUpdate_MaximumSet_Gen.json +# x-ms-original-file: 2026-03-01-preview/Organizations_CreateOrUpdate_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_delete_maximum_set_gen.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_delete_maximum_set_gen.py index a2d212c45595..da636a20b00c 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_delete_maximum_set_gen.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_delete_maximum_set_gen.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: 2025-06-01/Organizations_Delete_MaximumSet_Gen.json +# x-ms-original-file: 2026-03-01-preview/Organizations_Delete_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_get_maximum_set_gen.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_get_maximum_set_gen.py index 5e27903b9251..33409cdeba8b 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_get_maximum_set_gen.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_get_maximum_set_gen.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01/Organizations_Get_MaximumSet_Gen.json +# x-ms-original-file: 2026-03-01-preview/Organizations_Get_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_list_by_resource_group_maximum_set_gen.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_list_by_resource_group_maximum_set_gen.py index 01a32dfdde1d..5398c2f2866e 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_list_by_resource_group_maximum_set_gen.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_list_by_resource_group_maximum_set_gen.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: 2025-06-01/Organizations_ListByResourceGroup_MaximumSet_Gen.json +# x-ms-original-file: 2026-03-01-preview/Organizations_ListByResourceGroup_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_list_by_resource_group_minimum_set_gen.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_list_by_resource_group_minimum_set_gen.py index d4df4c794928..f3edbb90464b 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_list_by_resource_group_minimum_set_gen.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_list_by_resource_group_minimum_set_gen.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: 2025-06-01/Organizations_ListByResourceGroup_MinimumSet_Gen.json +# x-ms-original-file: 2026-03-01-preview/Organizations_ListByResourceGroup_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_list_by_subscription_maximum_set_gen.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_list_by_subscription_maximum_set_gen.py index e4b03823b127..536b80b9208d 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_list_by_subscription_maximum_set_gen.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_list_by_subscription_maximum_set_gen.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: 2025-06-01/Organizations_ListBySubscription_MaximumSet_Gen.json +# x-ms-original-file: 2026-03-01-preview/Organizations_ListBySubscription_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_list_by_subscription_minimum_set_gen.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_list_by_subscription_minimum_set_gen.py index 0b20fa5eb640..fa83ea9df1c3 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_list_by_subscription_minimum_set_gen.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_list_by_subscription_minimum_set_gen.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: 2025-06-01/Organizations_ListBySubscription_MinimumSet_Gen.json +# x-ms-original-file: 2026-03-01-preview/Organizations_ListBySubscription_MinimumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_update_maximum_set_gen.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_update_maximum_set_gen.py index 82c503d761be..050c95797983 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_update_maximum_set_gen.py +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/organizations_update_maximum_set_gen.py @@ -56,6 +56,6 @@ def main(): print(response) -# x-ms-original-file: 2025-06-01/Organizations_Update_MaximumSet_Gen.json +# x-ms-original-file: 2026-03-01-preview/Organizations_Update_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_create_or_update_maximum_set_gen.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_create_or_update_maximum_set_gen.py new file mode 100644 index 000000000000..122f5a882130 --- /dev/null +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_create_or_update_maximum_set_gen.py @@ -0,0 +1,44 @@ +# 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.mongodbatlas import MongoDBAtlasMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mongodbatlas +# USAGE + python projects_create_or_update_maximum_set_gen.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 = MongoDBAtlasMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.projects.begin_create_or_update( + resource_group_name="rgopenapi", + organization_name="myOrganization", + project_name="myProject", + resource={"properties": {}}, + ).result() + print(response) + + +# x-ms-original-file: 2026-03-01-preview/Projects_CreateOrUpdate_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_delete_maximum_set_gen.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_delete_maximum_set_gen.py new file mode 100644 index 000000000000..958f48cc2304 --- /dev/null +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_delete_maximum_set_gen.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.mongodbatlas import MongoDBAtlasMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mongodbatlas +# USAGE + python projects_delete_maximum_set_gen.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 = MongoDBAtlasMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.projects.begin_delete( + resource_group_name="rgopenapi", + organization_name="myOrganization", + project_name="myProject", + ).result() + + +# x-ms-original-file: 2026-03-01-preview/Projects_Delete_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_get_maximum_set_gen.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_get_maximum_set_gen.py new file mode 100644 index 000000000000..9b65dee0b1f3 --- /dev/null +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_get_maximum_set_gen.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.mongodbatlas import MongoDBAtlasMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mongodbatlas +# USAGE + python projects_get_maximum_set_gen.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 = MongoDBAtlasMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.projects.get( + resource_group_name="rgopenapi", + organization_name="myOrganization", + project_name="myProject", + ) + print(response) + + +# x-ms-original-file: 2026-03-01-preview/Projects_Get_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_list_cluster_tier_regions_maximum_set_gen.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_list_cluster_tier_regions_maximum_set_gen.py new file mode 100644 index 000000000000..903ebcfe0875 --- /dev/null +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_list_cluster_tier_regions_maximum_set_gen.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.mongodbatlas import MongoDBAtlasMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mongodbatlas +# USAGE + python projects_list_cluster_tier_regions_maximum_set_gen.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 = MongoDBAtlasMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.projects.list_cluster_tier_regions( + resource_group_name="rgopenapi", + organization_name="myOrganization", + project_name="myProject", + ) + print(response) + + +# x-ms-original-file: 2026-03-01-preview/Projects_ListClusterTierRegions_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_list_maximum_set_gen.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_list_maximum_set_gen.py new file mode 100644 index 000000000000..240396ee1430 --- /dev/null +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_list_maximum_set_gen.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.mongodbatlas import MongoDBAtlasMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mongodbatlas +# USAGE + python projects_list_maximum_set_gen.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 = MongoDBAtlasMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.projects.list( + resource_group_name="rgopenapi", + organization_name="myOrganization", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2026-03-01-preview/Projects_List_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_tier_limit_reached_maximum_set_gen.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_tier_limit_reached_maximum_set_gen.py new file mode 100644 index 000000000000..10e9f05fca8f --- /dev/null +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_samples/projects_tier_limit_reached_maximum_set_gen.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.mongodbatlas import MongoDBAtlasMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-mongodbatlas +# USAGE + python projects_tier_limit_reached_maximum_set_gen.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 = MongoDBAtlasMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.projects.tier_limit_reached( + resource_group_name="rgopenapi", + organization_name="myOrganization", + project_name="myProject", + ) + print(response) + + +# x-ms-original-file: 2026-03-01-preview/Projects_TierLimitReached_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_tests/test_mongo_db_atlas_mgmt_clusters_operations.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_tests/test_mongo_db_atlas_mgmt_clusters_operations.py new file mode 100644 index 000000000000..12da579053e2 --- /dev/null +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_tests/test_mongo_db_atlas_mgmt_clusters_operations.py @@ -0,0 +1,92 @@ +# 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.mongodbatlas import MongoDBAtlasMgmtClient + +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 TestMongoDBAtlasMgmtClustersOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MongoDBAtlasMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_clusters_begin_create_or_update(self, resource_group): + response = self.client.clusters.begin_create_or_update( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + cluster_name="str", + resource={ + "id": "str", + "name": "str", + "properties": { + "clusterTier": "str", + "regionName": "str", + "backups": bool, + "clusterName": "str", + "mongoDbVersion": "str", + "provisioningState": "str", + "state": "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_clusters_begin_delete(self, resource_group): + response = self.client.clusters.begin_delete( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + cluster_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_clusters_list(self, resource_group): + response = self.client.clusters.list( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_clusters_get(self, resource_group): + response = self.client.clusters.get( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + cluster_name="str", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_tests/test_mongo_db_atlas_mgmt_clusters_operations_async.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_tests/test_mongo_db_atlas_mgmt_clusters_operations_async.py new file mode 100644 index 000000000000..2d5429d4a8cc --- /dev/null +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_tests/test_mongo_db_atlas_mgmt_clusters_operations_async.py @@ -0,0 +1,97 @@ +# 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.mongodbatlas.aio import MongoDBAtlasMgmtClient + +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 TestMongoDBAtlasMgmtClustersOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MongoDBAtlasMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_clusters_begin_create_or_update(self, resource_group): + response = await ( + await self.client.clusters.begin_create_or_update( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + cluster_name="str", + resource={ + "id": "str", + "name": "str", + "properties": { + "clusterTier": "str", + "regionName": "str", + "backups": bool, + "clusterName": "str", + "mongoDbVersion": "str", + "provisioningState": "str", + "state": "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_clusters_begin_delete(self, resource_group): + response = await ( + await self.client.clusters.begin_delete( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + cluster_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_clusters_list(self, resource_group): + response = self.client.clusters.list( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_clusters_get(self, resource_group): + response = await self.client.clusters.get( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + cluster_name="str", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_tests/test_mongo_db_atlas_mgmt_projects_operations.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_tests/test_mongo_db_atlas_mgmt_projects_operations.py new file mode 100644 index 000000000000..e3743ac62630 --- /dev/null +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_tests/test_mongo_db_atlas_mgmt_projects_operations.py @@ -0,0 +1,110 @@ +# 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.mongodbatlas import MongoDBAtlasMgmtClient + +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 TestMongoDBAtlasMgmtProjectsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MongoDBAtlasMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_projects_get(self, resource_group): + response = self.client.projects.get( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_projects_begin_create_or_update(self, resource_group): + response = self.client.projects.begin_create_or_update( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + resource={ + "id": "str", + "name": "str", + "properties": { + "clusterCount": 0, + "organizationId": "str", + "projectId": "str", + "projectName": "str", + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).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_projects_begin_delete(self, resource_group): + response = self.client.projects.begin_delete( + resource_group_name=resource_group.name, + organization_name="str", + project_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_projects_list(self, resource_group): + response = self.client.projects.list( + resource_group_name=resource_group.name, + organization_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_projects_tier_limit_reached(self, resource_group): + response = self.client.projects.tier_limit_reached( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_projects_list_cluster_tier_regions(self, resource_group): + response = self.client.projects.list_cluster_tier_regions( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_tests/test_mongo_db_atlas_mgmt_projects_operations_async.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_tests/test_mongo_db_atlas_mgmt_projects_operations_async.py new file mode 100644 index 000000000000..13300d667336 --- /dev/null +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/generated_tests/test_mongo_db_atlas_mgmt_projects_operations_async.py @@ -0,0 +1,115 @@ +# 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.mongodbatlas.aio import MongoDBAtlasMgmtClient + +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 TestMongoDBAtlasMgmtProjectsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(MongoDBAtlasMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_projects_get(self, resource_group): + response = await self.client.projects.get( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_projects_begin_create_or_update(self, resource_group): + response = await ( + await self.client.projects.begin_create_or_update( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + resource={ + "id": "str", + "name": "str", + "properties": { + "clusterCount": 0, + "organizationId": "str", + "projectId": "str", + "projectName": "str", + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + ).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_projects_begin_delete(self, resource_group): + response = await ( + await self.client.projects.begin_delete( + resource_group_name=resource_group.name, + organization_name="str", + project_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_projects_list(self, resource_group): + response = self.client.projects.list( + resource_group_name=resource_group.name, + organization_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_projects_tier_limit_reached(self, resource_group): + response = await self.client.projects.tier_limit_reached( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_projects_list_cluster_tier_regions(self, resource_group): + response = await self.client.projects.list_cluster_tier_regions( + resource_group_name=resource_group.name, + organization_name="str", + project_name="str", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/pyproject.toml b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/pyproject.toml index ce5cf69b33f0..5aa689f7a6b8 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/pyproject.toml +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/pyproject.toml @@ -1,4 +1,86 @@ +[build-system] +requires = [ + "setuptools>=77.0.3", + "wheel", +] +build-backend = "setuptools.build_meta" + +[project] +name = "azure-mgmt-mongodbatlas" +authors = [ + { name = "Microsoft Corporation", email = "azpysdkhelp@microsoft.com" }, +] +description = "Microsoft Azure Mongodbatlas Management Client Library for Python" +license = "MIT" +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", +] +requires-python = ">=3.10" +keywords = [ + "azure", + "azure sdk", +] +dependencies = [ + "isodate>=0.6.1", + "azure-mgmt-core>=1.6.0", + "typing-extensions>=4.6.0", +] +dynamic = [ + "version", + "readme", +] + +[project.urls] +repository = "https://github.com/Azure/azure-sdk-for-python" + +[tool.setuptools.dynamic.version] +attr = "azure.mgmt.mongodbatlas._version.VERSION" + +[tool.setuptools.dynamic.readme] +file = [ + "README.md", + "CHANGELOG.md", +] +content-type = "text/markdown" + +[tool.setuptools.packages.find] +exclude = [ + "tests*", + "generated_tests*", + "samples*", + "generated_samples*", + "doc*", + "azure", + "azure.mgmt", +] + +[tool.setuptools.package-data] +pytyped = [ + "py.typed", +] + [tool.azure-sdk-build] breaking = false pyright = false mypy = false + +[packaging] +package_name = "azure-mgmt-mongodbatlas" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "Mongodbatlas Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true +sample_link = "" +exclude_folders = "" +title = "MongoDBAtlasMgmtClient" diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/sdk_packaging.toml b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/sdk_packaging.toml deleted file mode 100644 index cf6825f0de86..000000000000 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/sdk_packaging.toml +++ /dev/null @@ -1,12 +0,0 @@ -[packaging] -package_name = "azure-mgmt-mongodbatlas" -package_nspkg = "azure-mgmt-nspkg" -package_pprint_name = "Mongodbatlas Management" -package_doc_id = "" -is_stable = true -is_arm = true -need_msrestazure = false -need_azuremgmtcore = true -sample_link = "" -exclude_folders = "" -title = "MongoDBAtlasMgmtClient" diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/setup.py b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/setup.py deleted file mode 100644 index 9797161b4a50..000000000000 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/setup.py +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env python - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - -import re -import os.path -from io import open -from setuptools import find_packages, setup - -# Change the PACKAGE_NAME only to change folder and different name -PACKAGE_NAME = "azure-mgmt-mongodbatlas" -PACKAGE_PPRINT_NAME = "Mongodbatlas Management" - -# a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace("-", "/") -# a-b-c => a.b.c -namespace_name = PACKAGE_NAME.replace("-", ".") - -# Version extraction inspired from 'requests' -with open( - os.path.join(package_folder_path, "version.py") - if os.path.exists(os.path.join(package_folder_path, "version.py")) - else os.path.join(package_folder_path, "_version.py"), - "r", -) as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) - -if not version: - raise RuntimeError("Cannot find version information") - -with open("README.md", encoding="utf-8") as f: - readme = f.read() -with open("CHANGELOG.md", encoding="utf-8") as f: - changelog = f.read() - -setup( - name=PACKAGE_NAME, - version=version, - description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME), - long_description=readme + "\n\n" + changelog, - long_description_content_type="text/markdown", - license="MIT License", - author="Microsoft Corporation", - author_email="azpysdkhelp@microsoft.com", - 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", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "License :: OSI Approved :: MIT License", - ], - zip_safe=False, - packages=find_packages( - exclude=[ - "tests", - # Exclude packages that will be covered by PEP420 or nspkg - "azure", - "azure.mgmt", - ] - ), - include_package_data=True, - package_data={ - "pytyped": ["py.typed"], - }, - install_requires=[ - "isodate>=0.6.1", - "typing-extensions>=4.6.0", - "azure-common>=1.1", - "azure-mgmt-core>=1.5.0", - ], - python_requires=">=3.9", -) diff --git a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/tsp-location.yaml b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/tsp-location.yaml index 44919a76a29c..a2053971da9a 100644 --- a/sdk/mongodbatlas/azure-mgmt-mongodbatlas/tsp-location.yaml +++ b/sdk/mongodbatlas/azure-mgmt-mongodbatlas/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/liftrmongodb/MongoDB.Atlas.Management -commit: fa6fa40e4b84fded374f3aff1e591fa217a82fe8 +commit: 18ebae7ea8f6aefd83268aacdb1f480b24842726 repo: Azure/azure-rest-api-specs additionalDirectories: