diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/CHANGELOG.md b/sdk/managementgroups/azure-mgmt-managementgroups/CHANGELOG.md index c99df6bfcf70..fd991c98800c 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/CHANGELOG.md +++ b/sdk/managementgroups/azure-mgmt-managementgroups/CHANGELOG.md @@ -1,5 +1,15 @@ # Release History +## 1.1.0 (2026-02-12) + +### Bugs Fixed + + - Fixed import error when upgrading to latest azure-core + +### Other Changes + + - Refreshed SDK code with latest code generator + ## 1.1.0b2 (2024-11-05) ### Other Changes diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/MANIFEST.in b/sdk/managementgroups/azure-mgmt-managementgroups/MANIFEST.in index 8e2ca06b53eb..82cea40ee8cb 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/MANIFEST.in +++ b/sdk/managementgroups/azure-mgmt-managementgroups/MANIFEST.in @@ -1,8 +1,7 @@ -include _meta.json -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/managementgroups/py.typed +recursive-include tests *.py +recursive-include samples *.py *.md +include azure/__init__.py +include azure/mgmt/__init__.py diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/README.md b/sdk/managementgroups/azure-mgmt-managementgroups/README.md index fe5e08a6d803..f344dbf8af9f 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/README.md +++ b/sdk/managementgroups/azure-mgmt-managementgroups/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Management Groups Client Library. -This package has been tested with Python 3.8+. +This package has been tested with Python 3.9+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.8+ is required to use this package. +- Python 3.9+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -24,23 +24,19 @@ pip install azure-identity ### Authentication -By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables. +By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configuration of the following environment variables. - `AZURE_CLIENT_ID` for Azure client ID. - `AZURE_TENANT_ID` for Azure tenant ID. - `AZURE_CLIENT_SECRET` for Azure client secret. -In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`. - With above configuration, client can be authenticated by following code: ```python from azure.identity import DefaultAzureCredential from azure.mgmt.managementgroups import ManagementGroupsAPI -import os -sub_id = os.getenv("AZURE_SUBSCRIPTION_ID") -client = ManagementGroupsAPI(credential=DefaultAzureCredential(), subscription_id=sub_id) +client = ManagementGroupsAPI(credential=DefaultAzureCredential()) ``` ## Examples diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/_meta.json b/sdk/managementgroups/azure-mgmt-managementgroups/_meta.json deleted file mode 100644 index 08ce36824dda..000000000000 --- a/sdk/managementgroups/azure-mgmt-managementgroups/_meta.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "commit": "690a7656d65a03b134fa44fc7bb8013dc18a15b5", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.10.2", - "use": [ - "@autorest/python@6.19.0", - "@autorest/modelerfour@4.27.0" - ], - "autorest_command": "autorest specification/managementgroups/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --tag=package-2021-04 --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", - "readme": "specification/managementgroups/resource-manager/readme.md" -} \ No newline at end of file diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/_metadata.json b/sdk/managementgroups/azure-mgmt-managementgroups/_metadata.json new file mode 100644 index 000000000000..665e9e1337de --- /dev/null +++ b/sdk/managementgroups/azure-mgmt-managementgroups/_metadata.json @@ -0,0 +1,11 @@ +{ + "commit": "91b5db1facc51f4bf2b44afec16d79d8d92440f5", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest": "3.10.2", + "use": [ + "@autorest/python@6.48.0", + "@autorest/modelerfour@4.27.0" + ], + "autorest_command": "autorest specification/management/resource-manager/Microsoft.Management/ManagementGroups/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --package-mode=azure-mgmt --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --tag=package-2021-04 --use=@autorest/python@6.48.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", + "readme": "specification/management/resource-manager/Microsoft.Management/ManagementGroups/readme.md" +} \ No newline at end of file diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/apiview-properties.json b/sdk/managementgroups/azure-mgmt-managementgroups/apiview-properties.json new file mode 100644 index 000000000000..cdc51619555d --- /dev/null +++ b/sdk/managementgroups/azure-mgmt-managementgroups/apiview-properties.json @@ -0,0 +1,87 @@ +{ + "CrossLanguagePackageId": null, + "CrossLanguageDefinitionId": { + "azure.mgmt.managementgroups.models.AzureAsyncOperationResults": null, + "azure.mgmt.managementgroups.models.CheckNameAvailabilityRequest": null, + "azure.mgmt.managementgroups.models.CheckNameAvailabilityResult": null, + "azure.mgmt.managementgroups.models.CreateManagementGroupChildInfo": null, + "azure.mgmt.managementgroups.models.CreateManagementGroupDetails": null, + "azure.mgmt.managementgroups.models.CreateManagementGroupRequest": null, + "azure.mgmt.managementgroups.models.CreateOrUpdateSettingsRequest": null, + "azure.mgmt.managementgroups.models.CreateParentGroupInfo": null, + "azure.mgmt.managementgroups.models.DescendantInfo": null, + "azure.mgmt.managementgroups.models.DescendantListResult": null, + "azure.mgmt.managementgroups.models.DescendantParentGroupInfo": null, + "azure.mgmt.managementgroups.models.EntityHierarchyItem": null, + "azure.mgmt.managementgroups.models.EntityInfo": null, + "azure.mgmt.managementgroups.models.EntityListResult": null, + "azure.mgmt.managementgroups.models.EntityParentGroupInfo": null, + "azure.mgmt.managementgroups.models.ErrorDetails": null, + "azure.mgmt.managementgroups.models.ErrorResponse": null, + "azure.mgmt.managementgroups.models.HierarchySettings": null, + "azure.mgmt.managementgroups.models.HierarchySettingsInfo": null, + "azure.mgmt.managementgroups.models.HierarchySettingsList": null, + "azure.mgmt.managementgroups.models.ListSubscriptionUnderManagementGroup": null, + "azure.mgmt.managementgroups.models.ManagementGroup": null, + "azure.mgmt.managementgroups.models.ManagementGroupChildInfo": null, + "azure.mgmt.managementgroups.models.ManagementGroupDetails": null, + "azure.mgmt.managementgroups.models.ManagementGroupInfo": null, + "azure.mgmt.managementgroups.models.ManagementGroupListResult": null, + "azure.mgmt.managementgroups.models.ManagementGroupPathElement": null, + "azure.mgmt.managementgroups.models.Operation": null, + "azure.mgmt.managementgroups.models.OperationDisplayProperties": null, + "azure.mgmt.managementgroups.models.OperationListResult": null, + "azure.mgmt.managementgroups.models.OperationResults": null, + "azure.mgmt.managementgroups.models.ParentGroupInfo": null, + "azure.mgmt.managementgroups.models.PatchManagementGroupRequest": null, + "azure.mgmt.managementgroups.models.SubscriptionUnderManagementGroup": null, + "azure.mgmt.managementgroups.models.TenantBackfillStatusResult": null, + "azure.mgmt.managementgroups.models.ManagementGroupChildType": null, + "azure.mgmt.managementgroups.models.Permissions": null, + "azure.mgmt.managementgroups.models.ManagementGroupExpandType": null, + "azure.mgmt.managementgroups.models.EntitySearchType": null, + "azure.mgmt.managementgroups.models.EntityViewParameterType": null, + "azure.mgmt.managementgroups.models.Reason": null, + "azure.mgmt.managementgroups.models.Status": null, + "azure.mgmt.managementgroups.operations.ManagementGroupsOperations.list": null, + "azure.mgmt.managementgroups.aio.operations.ManagementGroupsOperations.list": null, + "azure.mgmt.managementgroups.operations.ManagementGroupsOperations.get": null, + "azure.mgmt.managementgroups.aio.operations.ManagementGroupsOperations.get": null, + "azure.mgmt.managementgroups.operations.ManagementGroupsOperations.begin_create_or_update": null, + "azure.mgmt.managementgroups.aio.operations.ManagementGroupsOperations.begin_create_or_update": null, + "azure.mgmt.managementgroups.operations.ManagementGroupsOperations.update": null, + "azure.mgmt.managementgroups.aio.operations.ManagementGroupsOperations.update": null, + "azure.mgmt.managementgroups.operations.ManagementGroupsOperations.begin_delete": null, + "azure.mgmt.managementgroups.aio.operations.ManagementGroupsOperations.begin_delete": null, + "azure.mgmt.managementgroups.operations.ManagementGroupsOperations.get_descendants": null, + "azure.mgmt.managementgroups.aio.operations.ManagementGroupsOperations.get_descendants": null, + "azure.mgmt.managementgroups.operations.ManagementGroupSubscriptionsOperations.create": null, + "azure.mgmt.managementgroups.aio.operations.ManagementGroupSubscriptionsOperations.create": null, + "azure.mgmt.managementgroups.operations.ManagementGroupSubscriptionsOperations.delete": null, + "azure.mgmt.managementgroups.aio.operations.ManagementGroupSubscriptionsOperations.delete": null, + "azure.mgmt.managementgroups.operations.ManagementGroupSubscriptionsOperations.get_subscription": null, + "azure.mgmt.managementgroups.aio.operations.ManagementGroupSubscriptionsOperations.get_subscription": null, + "azure.mgmt.managementgroups.operations.ManagementGroupSubscriptionsOperations.get_subscriptions_under_management_group": null, + "azure.mgmt.managementgroups.aio.operations.ManagementGroupSubscriptionsOperations.get_subscriptions_under_management_group": null, + "azure.mgmt.managementgroups.operations.HierarchySettingsOperations.list": null, + "azure.mgmt.managementgroups.aio.operations.HierarchySettingsOperations.list": null, + "azure.mgmt.managementgroups.operations.HierarchySettingsOperations.get": null, + "azure.mgmt.managementgroups.aio.operations.HierarchySettingsOperations.get": null, + "azure.mgmt.managementgroups.operations.HierarchySettingsOperations.create_or_update": null, + "azure.mgmt.managementgroups.aio.operations.HierarchySettingsOperations.create_or_update": null, + "azure.mgmt.managementgroups.operations.HierarchySettingsOperations.update": null, + "azure.mgmt.managementgroups.aio.operations.HierarchySettingsOperations.update": null, + "azure.mgmt.managementgroups.operations.HierarchySettingsOperations.delete": null, + "azure.mgmt.managementgroups.aio.operations.HierarchySettingsOperations.delete": null, + "azure.mgmt.managementgroups.operations.Operations.list": null, + "azure.mgmt.managementgroups.aio.operations.Operations.list": null, + "azure.mgmt.managementgroups.ManagementGroupsAPI.check_name_availability": null, + "azure.mgmt.managementgroups.aio.ManagementGroupsAPI.check_name_availability": null, + "azure.mgmt.managementgroups.ManagementGroupsAPI.start_tenant_backfill": null, + "azure.mgmt.managementgroups.aio.ManagementGroupsAPI.start_tenant_backfill": null, + "azure.mgmt.managementgroups.ManagementGroupsAPI.tenant_backfill_status": null, + "azure.mgmt.managementgroups.aio.ManagementGroupsAPI.tenant_backfill_status": null, + "azure.mgmt.managementgroups.operations.EntitiesOperations.list": null, + "azure.mgmt.managementgroups.aio.operations.EntitiesOperations.list": null + } +} \ No newline at end of file diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/__init__.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/__init__.py index 8db66d3d0f0f..d55ccad1f573 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/__init__.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/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/managementgroups/azure-mgmt-managementgroups/azure/mgmt/__init__.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/__init__.py index 8db66d3d0f0f..d55ccad1f573 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/__init__.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/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/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/__init__.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/__init__.py index 8e9886cca32f..333f77308020 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/__init__.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._management_groups_api import ManagementGroupsAPI +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._management_groups_api import ManagementGroupsAPI # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "ManagementGroupsAPI", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_configuration.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_configuration.py index 1238dac2312c..925b952e78a4 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_configuration.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_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,11 +14,11 @@ from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports + from azure.core import AzureClouds from azure.core.credentials import TokenCredential -class ManagementGroupsAPIConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class ManagementGroupsAPIConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for ManagementGroupsAPI. Note that all parameters used to create this instance are saved as instance @@ -26,18 +26,24 @@ class ManagementGroupsAPIConfiguration: # pylint: disable=too-many-instance-att :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential + :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: Api Version. Default value is "2021-04-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: + def __init__( + self, credential: "TokenCredential", cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any + ) -> None: api_version: str = kwargs.pop("api_version", "2021-04-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential + 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-managementgroups/{}".format(VERSION)) diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_management_groups_api.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_management_groups_api.py index 1f218f35a823..114dc408f93c 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_management_groups_api.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_management_groups_api.py @@ -7,32 +7,34 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING, cast from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse +from azure.core.settings import settings from azure.mgmt.core import ARMPipelineClient from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints from . import models as _models from ._configuration import ManagementGroupsAPIConfiguration -from ._serialization import Deserializer, Serializer +from ._utils.serialization import Deserializer, Serializer from .operations import ( EntitiesOperations, HierarchySettingsOperations, ManagementGroupSubscriptionsOperations, - ManagementGroupsAPIOperationsMixin, ManagementGroupsOperations, Operations, + _ManagementGroupsAPIOperationsMixin, ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports + from azure.core import AzureClouds from azure.core.credentials import TokenCredential -class ManagementGroupsAPI(ManagementGroupsAPIOperationsMixin): # pylint: disable=client-accepts-api-version-keyword +class ManagementGroupsAPI(_ManagementGroupsAPIOperationsMixin): """The Azure Management Groups API enables consolidation of multiple subscriptions/resources into an organizational hierarchy and centrally manage access control, policies, alerting and reporting for those resources. @@ -50,8 +52,11 @@ class ManagementGroupsAPI(ManagementGroupsAPIOperationsMixin): # pylint: disabl :vartype entities: azure.mgmt.managementgroups.operations.EntitiesOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". + :param base_url: Service URL. Default value is None. :type base_url: str + :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: Api Version. Default value is "2021-04-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str @@ -60,9 +65,22 @@ class ManagementGroupsAPI(ManagementGroupsAPIOperationsMixin): # pylint: disabl """ def __init__( - self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any + self, + credential: "TokenCredential", + base_url: Optional[str] = None, + *, + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any ) -> None: - self._config = ManagementGroupsAPIConfiguration(credential=credential, **kwargs) + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) + self._config = ManagementGroupsAPIConfiguration( + credential=credential, cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs + ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -81,7 +99,7 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_utils/__init__.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_utils/__init__.py new file mode 100644 index 000000000000..0af9b28f6607 --- /dev/null +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_utils/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_serialization.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_utils/serialization.py similarity index 81% rename from sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_serialization.py rename to sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_utils/serialization.py index 8139854b97bb..6da830e0cf4a 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_serialization.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_utils/serialization.py @@ -1,30 +1,12 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -# pylint: skip-file # pyright: reportUnnecessaryTypeIgnoreComment=false from base64 import b64decode, b64encode @@ -39,7 +21,6 @@ import sys import codecs from typing import ( - Dict, Any, cast, Optional, @@ -48,11 +29,7 @@ IO, Mapping, Callable, - TypeVar, MutableMapping, - Type, - List, - Mapping, ) try: @@ -62,13 +39,13 @@ import xml.etree.ElementTree as ET import isodate # type: ignore +from typing_extensions import Self from azure.core.exceptions import DeserializationError, SerializationError from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -ModelType = TypeVar("ModelType", bound="Model") JSON = MutableMapping[str, Any] @@ -91,6 +68,8 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: :param data: Input, could be bytes or stream (will be decoded with UTF8) or text :type data: str or bytes or IO :param str content_type: The content type. + :return: The deserialized data. + :rtype: object """ if hasattr(data, "read"): # Assume a stream @@ -112,7 +91,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: try: return json.loads(data_as_str) except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) + raise DeserializationError("JSON is invalid: {}".format(err), err) from err elif "xml" in (content_type or []): try: @@ -155,6 +134,11 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], Use bytes and headers to NOT use any requests/aiohttp or whatever specific implementation. Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object """ # Try to use content-type from headers if available content_type = None @@ -179,80 +163,31 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], except NameError: _long_type = int - -class UTC(datetime.tzinfo): - """Time Zone info for handling UTC""" - - def utcoffset(self, dt): - """UTF offset for UTC is 0.""" - return datetime.timedelta(0) - - def tzname(self, dt): - """Timestamp representation.""" - return "Z" - - def dst(self, dt): - """No daylight saving for UTC.""" - return datetime.timedelta(hours=1) - - -try: - from datetime import timezone as _FixedOffset # type: ignore -except ImportError: # Python 2.7 - - class _FixedOffset(datetime.tzinfo): # type: ignore - """Fixed offset in minutes east from UTC. - Copy/pasted from Python doc - :param datetime.timedelta offset: offset in timedelta format - """ - - def __init__(self, offset): - self.__offset = offset - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return str(self.__offset.total_seconds() / 3600) - - def __repr__(self): - return "".format(self.tzname(None)) - - def dst(self, dt): - return datetime.timedelta(0) - - def __getinitargs__(self): - return (self.__offset,) - - -try: - from datetime import timezone - - TZ_UTC = timezone.utc -except ImportError: - TZ_UTC = UTC() # type: ignore +TZ_UTC = datetime.timezone.utc _FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: + 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__) elif k in self._validation and self._validation[k].get("readonly", False): @@ -300,13 +242,23 @@ def __init__(self, **kwargs: Any) -> None: setattr(self, k, kwargs[k]) def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ return not self.__eq__(other) def __str__(self) -> str: @@ -326,7 +278,11 @@ def is_xml_model(cls) -> bool: @classmethod def _create_xml_node(cls): - """Create XML node.""" + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ try: xml_map = cls._xml_map # type: ignore except AttributeError: @@ -346,12 +302,14 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) 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,12 +338,15 @@ def my_key_transformer(key, attr_desc, value): If you want XML serialization, you can pass the kwargs is_xml=True. + :param bool keep_readonly: If you want to serialize the readonly attributes :param function key_transformer: A key transformer function. :returns: A dict JSON compatible object :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) @classmethod def _infer_class_models(cls): @@ -395,30 +356,31 @@ def _infer_class_models(cls): client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} if cls.__name__ not in client_models: raise ValueError("Not Autorest generated code") - except Exception: + except Exception: # pylint: disable=broad-exception-caught # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. client_models = {cls.__name__: cls} return client_models @classmethod - def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( - cls: Type[ModelType], + cls, data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + key_extractors: Optional[Callable[[str, dict[str, Any], Any], Any]] = None, content_type: Optional[str] = None, - ) -> ModelType: + ) -> Self: """Parse a dict using given key extractor return a model. By default consider key @@ -426,9 +388,11 @@ def from_dict( and last_rest_key_case_insensitive_extractor) :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -448,21 +412,25 @@ 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)) + result |= objects[valuetype]._flatten_subtype(key, objects) # pylint: disable=protected-access return result @classmethod def _classify(cls, response, objects): """Check the class _subtype_map for any child classes. We want to ignore any inherited _subtype_maps. - Remove the polymorphic key from the initial data. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class """ for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): subtype_value = None if not isinstance(response, ET.Element): rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) else: subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) if subtype_value: @@ -501,11 +469,13 @@ def _decode_attribute_map_key(key): inside the received data. :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str """ return key.replace("\\.", ".") -class Serializer(object): +class Serializer: # pylint: disable=too-many-public-methods """Request object model serializer.""" basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -540,7 +510,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, type]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -556,17 +526,20 @@ def __init__(self, classes: Optional[Mapping[str, type]] = 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 - def _serialize(self, target_obj, data_type=None, **kwargs): + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): """Serialize data into a string according to type. - :param target_obj: The data to be serialized. + :param object target_obj: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, dict - :raises: SerializationError if serialization fails. + :raises SerializationError: if serialization fails. + :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) keep_readonly = kwargs.get("keep_readonly", False) @@ -592,17 +565,19 @@ def _serialize(self, target_obj, data_type=None, **kwargs): serialized = {} if is_xml_model_serialization: - serialized = target_obj._create_xml_node() + serialized = target_obj._create_xml_node() # pylint: disable=protected-access try: - attributes = target_obj._attribute_map + attributes = target_obj._attribute_map # pylint: disable=protected-access for attr, attr_desc in attributes.items(): attr_name = attr - if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): continue if attr_name == "additional_properties" and attr_desc["key"] == "": if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) + serialized |= target_obj.additional_properties continue try: @@ -633,7 +608,8 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if isinstance(new_attr, list): serialized.extend(new_attr) # type: ignore elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. if "name" not in getattr(orig_attr, "_xml_map", {}): splitted_tag = new_attr.tag.split("}") if len(splitted_tag) == 2: # Namespace @@ -664,17 +640,17 @@ def _serialize(self, target_obj, data_type=None, **kwargs): except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) raise SerializationError(msg) from err - else: - return serialized + return serialized def body(self, data, data_type, **kwargs): """Serialize data intended for a request body. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: dict - :raises: SerializationError if serialization fails. - :raises: ValueError if data is None + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized request body """ # Just in case this is a dict @@ -703,7 +679,7 @@ def body(self, data, data_type, **kwargs): attribute_key_case_insensitive_extractor, last_rest_key_case_insensitive_extractor, ] - data = deserializer._deserialize(data_type, data) + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access except DeserializationError as err: raise SerializationError("Unable to build a model: " + str(err)) from err @@ -712,11 +688,13 @@ def body(self, data, data_type, **kwargs): def url(self, name, data, data_type, **kwargs): """Serialize data intended for a URL path. - :param data: The data to be serialized. + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :returns: The serialized URL path + :raises TypeError: if serialization fails. + :raises ValueError: if data is None """ try: output = self.serialize_data(data, data_type, **kwargs) @@ -728,21 +706,20 @@ def url(self, name, data, data_type, **kwargs): output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return output + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output def query(self, name, data, data_type, **kwargs): """Serialize data intended for a URL query. - :param data: The data to be serialized. + :param str name: The name of the query parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :keyword bool skip_quote: Whether to skip quote the serialized result. - Defaults to False. :rtype: str, list - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized query parameter """ try: # Treat the list aside, since we don't want to encode the div separator @@ -759,19 +736,20 @@ def query(self, name, data, data_type, **kwargs): output = str(output) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def header(self, name, data, data_type, **kwargs): """Serialize data intended for a request header. - :param data: The data to be serialized. + :param str name: The name of the header. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized header """ try: if data_type in ["[str]"]: @@ -780,21 +758,20 @@ def header(self, name, data, data_type, **kwargs): output = self.serialize_data(data, data_type, **kwargs) if data_type == "bool": output = json.dumps(output) - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def serialize_data(self, data, data_type, **kwargs): """Serialize generic data according to supplied data type. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :param bool required: Whether it's essential that the data not be - empty or None - :raises: AttributeError if required data is None. - :raises: ValueError if data is None - :raises: SerializationError if serialization fails. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list """ if data is None: raise ValueError("No value for given attribute") @@ -805,12 +782,12 @@ def serialize_data(self, data, data_type, **kwargs): if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) - elif data_type in self.serialize_type: + if data_type in self.serialize_type: return self.serialize_type[data_type](data, **kwargs) # If dependencies is empty, try with current data class # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) + 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) @@ -821,11 +798,10 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." raise SerializationError(msg.format(data, data_type)) from err - else: - return self._serialize(data, **kwargs) + return self._serialize(data, **kwargs) @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) if custom_serializer: return custom_serializer @@ -841,23 +817,33 @@ def serialize_basic(cls, data, data_type, **kwargs): - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - is_xml bool : If set, use xml_basic_types_serializers - :param data: Object to be serialized. + :param obj data: Object to be serialized. :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 + 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): """Special handling for serializing unicode strings in Py2. Encode to UTF-8 if unicode, otherwise handle as a str. - :param data: Object to be serialized. + :param str data: Object to be serialized. :rtype: str + :return: serialized object """ try: # If I received an enum, return its value return data.value @@ -871,8 +857,7 @@ def serialize_unicode(cls, data): return data except NameError: return str(data) - else: - return str(data) + return str(data) def serialize_iter(self, data, iter_type, div=None, **kwargs): """Serialize iterable. @@ -882,15 +867,13 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): serialization_ctxt['type'] should be same as data_type. - is_xml bool : If set, serialize as XML - :param list attr: Object to be serialized. + :param list data: Object to be serialized. :param str iter_type: Type of object in the iterable. - :param bool required: Whether the objects in the iterable must - not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. - :keyword bool do_quote: Whether to quote the serialized result of each iterable element. Defaults to False. :rtype: list, str + :return: serialized iterable """ if isinstance(data, str): raise SerializationError("Refuse str type as a valid iter type.") @@ -945,9 +928,8 @@ def serialize_dict(self, attr, dict_type, **kwargs): :param dict attr: Object to be serialized. :param str dict_type: Type of object in the dictionary. - :param bool required: Whether the objects in the dictionary must - not be None or empty. :rtype: dict + :return: serialized dictionary """ serialization_ctxt = kwargs.get("serialization_ctxt", {}) serialized = {} @@ -971,7 +953,7 @@ def serialize_dict(self, attr, dict_type, **kwargs): return serialized - def serialize_object(self, attr, **kwargs): + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Serialize a generic object. This will be handled as a dictionary. If object passed in is not a basic type (str, int, float, dict, list) it will simply be @@ -979,6 +961,7 @@ def serialize_object(self, attr, **kwargs): :param dict attr: Object to be serialized. :rtype: dict or str + :return: serialized object """ if attr is None: return None @@ -1003,7 +986,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_decimal(attr) # If it's a model or I know this dependency, serialize as a Model - elif obj_type in self.dependencies.values() or isinstance(attr, Model): + if obj_type in self.dependencies.values() or isinstance(attr, Model): return self._serialize(attr) if obj_type == dict: @@ -1034,56 +1017,61 @@ def serialize_enum(attr, enum_obj=None): try: enum_obj(result) # type: ignore return result - except ValueError: + except ValueError as exc: for enum_value in enum_obj: # type: ignore if enum_value.value.lower() == str(attr).lower(): return enum_value.value error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) + raise SerializationError(error.format(attr, enum_obj)) from exc @staticmethod - def serialize_bytearray(attr, **kwargs): + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument """Serialize bytearray into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ return b64encode(attr).decode() @staticmethod - def serialize_base64(attr, **kwargs): + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument """Serialize str into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ encoded = b64encode(attr).decode("ascii") return encoded.strip("=").replace("+", "-").replace("/", "_") @staticmethod - def serialize_decimal(attr, **kwargs): + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument """Serialize Decimal object to float. - :param attr: Object to be serialized. + :param decimal attr: Object to be serialized. :rtype: float + :return: serialized decimal """ return float(attr) @staticmethod - def serialize_long(attr, **kwargs): + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument """Serialize long (Py2) or int (Py3). - :param attr: Object to be serialized. + :param int attr: Object to be serialized. :rtype: int/long + :return: serialized long """ return _long_type(attr) @staticmethod - def serialize_date(attr, **kwargs): + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument """Serialize Date object into ISO-8601 formatted string. :param Date attr: Object to be serialized. :rtype: str + :return: serialized date """ if isinstance(attr, str): attr = isodate.parse_date(attr) @@ -1091,11 +1079,12 @@ def serialize_date(attr, **kwargs): return t @staticmethod - def serialize_time(attr, **kwargs): + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument """Serialize Time object into ISO-8601 formatted string. :param datetime.time attr: Object to be serialized. :rtype: str + :return: serialized time """ if isinstance(attr, str): attr = isodate.parse_time(attr) @@ -1105,30 +1094,32 @@ def serialize_time(attr, **kwargs): return t @staticmethod - def serialize_duration(attr, **kwargs): + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument """Serialize TimeDelta object into ISO-8601 formatted string. :param TimeDelta attr: Object to be serialized. :rtype: str + :return: serialized duration """ if isinstance(attr, str): attr = isodate.parse_duration(attr) return isodate.duration_isoformat(attr) @staticmethod - def serialize_rfc(attr, **kwargs): + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into RFC-1123 formatted string. :param Datetime attr: Object to be serialized. :rtype: str - :raises: TypeError if format invalid. + :raises TypeError: if format invalid. + :return: serialized rfc """ try: if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") utc = attr.utctimetuple() - except AttributeError: - raise TypeError("RFC1123 object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( Serializer.days[utc.tm_wday], @@ -1141,12 +1132,13 @@ def serialize_rfc(attr, **kwargs): ) @staticmethod - def serialize_iso(attr, **kwargs): + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into ISO-8601 formatted string. :param Datetime attr: Object to be serialized. :rtype: str - :raises: SerializationError if format invalid. + :raises SerializationError: if format invalid. + :return: serialized iso """ if isinstance(attr, str): attr = isodate.parse_datetime(attr) @@ -1172,13 +1164,14 @@ def serialize_iso(attr, **kwargs): raise TypeError(msg) from err @staticmethod - def serialize_unix(attr, **kwargs): + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into IntTime format. This is represented as seconds. :param Datetime attr: Object to be serialized. :rtype: int - :raises: SerializationError if format invalid + :raises SerializationError: if format invalid + :return: serialied unix """ if isinstance(attr, int): return attr @@ -1186,17 +1179,17 @@ def serialize_unix(attr, **kwargs): if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") return int(calendar.timegm(attr.utctimetuple())) - except AttributeError: - raise TypeError("Unix time object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc -def rest_key_extractor(attr, attr_desc, data): +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument key = attr_desc["key"] working_data = data 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 @@ -1211,7 +1204,9 @@ def rest_key_extractor(attr, attr_desc, data): return working_data.get(key) -def rest_key_case_insensitive_extractor(attr, attr_desc, data): +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): key = attr_desc["key"] working_data = data @@ -1232,17 +1227,29 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): return attribute_key_case_insensitive_extractor(key, None, working_data) -def last_rest_key_extractor(attr, attr_desc, data): - """Extract the attribute in "data" based on the last part of the JSON path key.""" +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) return attribute_key_extractor(dict_keys[-1], None, data) -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument """Extract the attribute in "data" based on the last part of the JSON path key. This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) @@ -1279,7 +1286,7 @@ def _extract_name_from_internal_type(internal_type): return xml_name -def xml_key_extractor(attr, attr_desc, data): +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements if isinstance(data, dict): return None @@ -1331,22 +1338,21 @@ def xml_key_extractor(attr, attr_desc, data): if is_iter_type: if is_wrapped: return None # is_wrapped no node, we want None - else: - return [] # not wrapped, assume empty list + return [] # not wrapped, assume empty list return None # Assume it's not there, maybe an optional node. # If is_iter_type and not wrapped, return all found children if is_iter_type: if not is_wrapped: return children - else: # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name ) - return list(children[0]) # Might be empty list and that's ok. + ) + return list(children[0]) # Might be empty list and that's ok. # Here it's not a itertype, we should have found one element only or empty if len(children) > 1: @@ -1354,7 +1360,7 @@ def xml_key_extractor(attr, attr_desc, data): return children[0] -class Deserializer(object): +class Deserializer: """Response object model deserializer. :param dict classes: Class type dictionary for deserializing complex types. @@ -1363,9 +1369,9 @@ class Deserializer(object): basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, type]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1385,7 +1391,7 @@ def __init__(self, classes: Optional[Mapping[str, type]] = 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 @@ -1401,27 +1407,29 @@ def __call__(self, target_obj, response_data, content_type=None): :param str target_obj: Target data type to deserialize to. :param requests.Response response_data: REST response object. :param str content_type: Swagger "produces" if available. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. + :rtype: object """ data = self._unpack_content(response_data, content_type) return self._deserialize(target_obj, data) - def _deserialize(self, target_obj, data): + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements """Call the deserializer on a model. Data needs to be already deserialized as JSON or XML ElementTree :param str target_obj: Target data type to deserialize to. :param object data: Object to deserialize. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. + :rtype: object """ # This is already a model, go recursive just in case if hasattr(data, "_attribute_map"): constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] try: - for attr, mapconfig in data._attribute_map.items(): + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access if attr in constants: continue value = getattr(data, attr) @@ -1440,13 +1448,13 @@ def _deserialize(self, target_obj, data): if isinstance(response, str): return self.deserialize_data(data, response) - elif isinstance(response, type) and issubclass(response, Enum): + if isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) if data is None or data is CoreNull: return data try: - attributes = response._attribute_map # type: ignore + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access d_attrs = {} for attr, attr_desc in attributes.items(): # Check empty string. If it's not empty, someone has a real "additionalProperties"... @@ -1476,9 +1484,8 @@ def _deserialize(self, target_obj, data): except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore raise DeserializationError(msg) from err - else: - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) def _build_additional_properties(self, attribute_map, data): if not self.additional_properties_detection: @@ -1505,6 +1512,8 @@ def _classify_target(self, target, data): :param str target: The target object type to deserialize to. :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple """ if target is None: return None, None @@ -1516,7 +1525,7 @@ def _classify_target(self, target, data): return target, target try: - target = target._classify(data, self.dependencies) # type: ignore + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1531,10 +1540,12 @@ def failsafe_deserialize(self, target_obj, data, content_type=None): :param str target_obj: The target object type to deserialize to. :param str/dict data: The response data to deserialize. :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object """ try: return self(target_obj, data, content_type=content_type) - except: + except: # pylint: disable=bare-except _LOGGER.debug( "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True ) @@ -1552,10 +1563,12 @@ def _unpack_content(raw_data, content_type=None): If raw_data is something else, bypass all logic and return it directly. - :param raw_data: Data to be processed. - :param content_type: How to parse if raw_data is a string/bytes. + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. :raises JSONDecodeError: If JSON is requested and parsing is impossible. :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. """ # Assume this is enough to detect a Pipeline Response without importing it context = getattr(raw_data, "context", {}) @@ -1579,24 +1592,35 @@ def _unpack_content(raw_data, content_type=None): def _instantiate_model(self, response, attrs, additional_properties=None): """Instantiate a response model passing in deserialized args. - :param response: The response model class. - :param d_attrs: The deserialized response attributes. + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. """ if callable(response): subtype = getattr(response, "_subtype_map", {}) try: - readonly = [k for k, v in response._validation.items() if v.get("readonly")] - const = [k for k, v in response._validation.items() if v.get("constant")] + readonly = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} response_obj = response(**kwargs) for attr in readonly: setattr(response_obj, attr, attrs.get(attr)) if additional_properties: - response_obj.additional_properties = additional_properties + response_obj.additional_properties = additional_properties # type: ignore return response_obj except TypeError as err: msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) + raise DeserializationError(msg + str(err)) from err else: try: for attr, value in attrs.items(): @@ -1605,15 +1629,16 @@ def _instantiate_model(self, response, attrs, additional_properties=None): except Exception as exp: msg = "Unable to populate response model. " msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) + raise DeserializationError(msg) from exp - def deserialize_data(self, data, data_type): + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements """Process data for deserialization according to data type. :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. + :rtype: object """ if data is None: return data @@ -1627,7 +1652,11 @@ def deserialize_data(self, data, data_type): if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): return data - is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: return None data_val = self.deserialize_type[data_type](data) @@ -1647,14 +1676,14 @@ def deserialize_data(self, data, data_type): msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) raise DeserializationError(msg) from err - else: - return self._deserialize(obj_type, data) + return self._deserialize(obj_type, data) def deserialize_iter(self, attr, iter_type): """Deserialize an iterable. :param list attr: Iterable to be deserialized. :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. :rtype: list """ if attr is None: @@ -1671,6 +1700,7 @@ def deserialize_dict(self, attr, dict_type): :param dict/list attr: Dictionary to be deserialized. Also accepts a list of key, value pairs. :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. :rtype: dict """ if isinstance(attr, list): @@ -1681,13 +1711,14 @@ def deserialize_dict(self, attr, dict_type): attr = {el.tag: el.text for el in attr} return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - def deserialize_object(self, attr, **kwargs): + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Deserialize a generic object. This will be handled as a dictionary. :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. :rtype: dict - :raises: TypeError if non-builtin datatype encountered. + :raises TypeError: if non-builtin datatype encountered. """ if attr is None: return None @@ -1720,11 +1751,10 @@ def deserialize_object(self, attr, **kwargs): pass return deserialized - else: - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) - def deserialize_basic(self, attr, data_type): + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements """Deserialize basic builtin data type from string. Will attempt to convert to str, int, float and bool. This function will also accept '1', '0', 'true' and 'false' as @@ -1732,8 +1762,9 @@ def deserialize_basic(self, attr, data_type): :param str attr: response string to be deserialized. :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 @@ -1743,24 +1774,27 @@ def deserialize_basic(self, attr, data_type): if data_type == "str": # None or '', node is empty string. return "" - else: - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, str): + if isinstance(attr, str): if attr.lower() in ["true", "1"]: return True - elif attr.lower() in ["false", "0"]: + if attr.lower() in ["false", "0"]: return False raise TypeError("Invalid boolean value: {}".format(attr)) if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec + 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): @@ -1768,6 +1802,7 @@ def deserialize_unicode(data): as a string. :param str data: response string to be deserialized. + :return: Deserialized string. :rtype: str or unicode """ # We might be here because we have an enum modeled as string, @@ -1781,8 +1816,7 @@ def deserialize_unicode(data): return data except NameError: return str(data) - else: - return str(data) + return str(data) @staticmethod def deserialize_enum(data, enum_obj): @@ -1794,6 +1828,7 @@ def deserialize_enum(data, enum_obj): :param str data: Response string to be deserialized. If this value is None or invalid it will be returned as-is. :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. :rtype: Enum """ if isinstance(data, enum_obj) or data is None: @@ -1804,9 +1839,9 @@ def deserialize_enum(data, enum_obj): # Workaround. We might consider remove it in the future. try: return list(enum_obj.__members__.values())[data] - except IndexError: + except IndexError as exc: error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) + raise DeserializationError(error.format(data, enum_obj)) from exc try: return enum_obj(str(data)) except ValueError: @@ -1822,8 +1857,9 @@ def deserialize_bytearray(attr): """Deserialize string into bytearray. :param str attr: response string to be deserialized. + :return: Deserialized bytearray :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1834,8 +1870,9 @@ def deserialize_base64(attr): """Deserialize base64 encoded string into string. :param str attr: response string to be deserialized. + :return: Deserialized base64 string :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1849,8 +1886,9 @@ def deserialize_decimal(attr): """Deserialize string into Decimal object. :param str attr: response string to be deserialized. - :rtype: Decimal - :raises: DeserializationError if string format invalid. + :return: Deserialized decimal + :raises DeserializationError: if string format invalid. + :rtype: decimal """ if isinstance(attr, ET.Element): attr = attr.text @@ -1865,8 +1903,9 @@ def deserialize_long(attr): """Deserialize string into long (Py2) or int (Py3). :param str attr: response string to be deserialized. + :return: Deserialized int :rtype: long or int - :raises: ValueError if string format invalid. + :raises ValueError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1877,8 +1916,9 @@ def deserialize_duration(attr): """Deserialize ISO-8601 formatted string into TimeDelta object. :param str attr: response string to be deserialized. + :return: Deserialized duration :rtype: TimeDelta - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1887,16 +1927,16 @@ def deserialize_duration(attr): except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." raise DeserializationError(msg) from err - else: - return duration + return duration @staticmethod def deserialize_date(attr): """Deserialize ISO-8601 formatted string into Date object. :param str attr: response string to be deserialized. + :return: Deserialized date :rtype: Date - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1910,8 +1950,9 @@ def deserialize_time(attr): """Deserialize ISO-8601 formatted string into time object. :param str attr: response string to be deserialized. + :return: Deserialized time :rtype: datetime.time - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1924,31 +1965,32 @@ def deserialize_rfc(attr): """Deserialize RFC-1123 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text try: parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) if not date_obj.tzinfo: date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." raise DeserializationError(msg) from err - else: - return date_obj + return date_obj @staticmethod def deserialize_iso(attr): """Deserialize ISO-8601 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1976,8 +2018,7 @@ def deserialize_iso(attr): except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." raise DeserializationError(msg) from err - else: - return date_obj + return date_obj @staticmethod def deserialize_unix(attr): @@ -1985,8 +2026,9 @@ def deserialize_unix(attr): This is represented as seconds. :param int attr: Object to be serialized. + :return: Deserialized datetime :rtype: Datetime - :raises: DeserializationError if format invalid + :raises DeserializationError: if format invalid """ if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore @@ -1996,5 +2038,4 @@ def deserialize_unix(attr): except ValueError as err: msg = "Cannot deserialize to unix datetime object." raise DeserializationError(msg) from err - else: - return date_obj + return date_obj diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_vendor.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_utils/utils.py similarity index 63% rename from sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_vendor.py rename to sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_utils/utils.py index 59d3f80715a2..39b612f39a9b 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_vendor.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_utils/utils.py @@ -6,21 +6,20 @@ # -------------------------------------------------------------------------- from abc import ABC -from typing import TYPE_CHECKING - -from ._configuration import ManagementGroupsAPIConfiguration +from typing import Generic, TYPE_CHECKING, TypeVar if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core import PipelineClient + from .serialization import Deserializer, Serializer + - from ._serialization import Deserializer, Serializer +TClient = TypeVar("TClient") +TConfig = TypeVar("TConfig") -class ManagementGroupsAPIMixinABC(ABC): +class ClientMixinABC(ABC, Generic[TClient, TConfig]): """DO NOT use this class. It is for internal typing use only.""" - _client: "PipelineClient" - _config: ManagementGroupsAPIConfiguration + _client: TClient + _config: TConfig _serialize: "Serializer" _deserialize: "Deserializer" diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_version.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_version.py index f1fb63697cf5..59deb8c7263b 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_version.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.1.0b2" +VERSION = "1.1.0" diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/__init__.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/__init__.py index 311e06c2a36d..a46f4fe420fe 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/__init__.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._management_groups_api import ManagementGroupsAPI +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._management_groups_api import ManagementGroupsAPI # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "ManagementGroupsAPI", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/_configuration.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/_configuration.py index 95eea1ddf7e8..94d7c2698aab 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/_configuration.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/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,11 +14,11 @@ from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports + from azure.core import AzureClouds from azure.core.credentials_async import AsyncTokenCredential -class ManagementGroupsAPIConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class ManagementGroupsAPIConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for ManagementGroupsAPI. Note that all parameters used to create this instance are saved as instance @@ -26,18 +26,24 @@ class ManagementGroupsAPIConfiguration: # pylint: disable=too-many-instance-att :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :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: Api Version. Default value is "2021-04-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: + def __init__( + self, credential: "AsyncTokenCredential", cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any + ) -> None: api_version: str = kwargs.pop("api_version", "2021-04-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") self.credential = credential + 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-managementgroups/{}".format(VERSION)) diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/_management_groups_api.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/_management_groups_api.py index e00daa120c5b..4af224abe68e 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/_management_groups_api.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/_management_groups_api.py @@ -7,32 +7,34 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING +from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.settings import settings from azure.mgmt.core import AsyncARMPipelineClient from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints from .. import models as _models -from .._serialization import Deserializer, Serializer +from .._utils.serialization import Deserializer, Serializer from ._configuration import ManagementGroupsAPIConfiguration from .operations import ( EntitiesOperations, HierarchySettingsOperations, ManagementGroupSubscriptionsOperations, - ManagementGroupsAPIOperationsMixin, ManagementGroupsOperations, Operations, + _ManagementGroupsAPIOperationsMixin, ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports + from azure.core import AzureClouds from azure.core.credentials_async import AsyncTokenCredential -class ManagementGroupsAPI(ManagementGroupsAPIOperationsMixin): # pylint: disable=client-accepts-api-version-keyword +class ManagementGroupsAPI(_ManagementGroupsAPIOperationsMixin): """The Azure Management Groups API enables consolidation of multiple subscriptions/resources into an organizational hierarchy and centrally manage access control, policies, alerting and reporting for those resources. @@ -52,8 +54,11 @@ class ManagementGroupsAPI(ManagementGroupsAPIOperationsMixin): # pylint: disabl :vartype entities: azure.mgmt.managementgroups.aio.operations.EntitiesOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param base_url: Service URL. Default value is "https://management.azure.com". + :param base_url: Service URL. Default value is None. :type base_url: str + :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: Api Version. Default value is "2021-04-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str @@ -62,9 +67,22 @@ class ManagementGroupsAPI(ManagementGroupsAPIOperationsMixin): # pylint: disabl """ def __init__( - self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any + self, + credential: "AsyncTokenCredential", + base_url: Optional[str] = None, + *, + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any ) -> None: - self._config = ManagementGroupsAPIConfiguration(credential=credential, **kwargs) + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) + self._config = ManagementGroupsAPIConfiguration( + credential=credential, cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs + ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -83,7 +101,9 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( + base_url=cast(str, base_url), policies=_policies, **kwargs + ) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/_vendor.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/_vendor.py deleted file mode 100644 index d4f2a8633b08..000000000000 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/_vendor.py +++ /dev/null @@ -1,26 +0,0 @@ -# -------------------------------------------------------------------------- -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from abc import ABC -from typing import TYPE_CHECKING - -from ._configuration import ManagementGroupsAPIConfiguration - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core import AsyncPipelineClient - - from .._serialization import Deserializer, Serializer - - -class ManagementGroupsAPIMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - - _client: "AsyncPipelineClient" - _config: ManagementGroupsAPIConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/__init__.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/__init__.py index 17da0c8d00e0..777e215f1a9f 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/__init__.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/__init__.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._management_groups_operations import ManagementGroupsOperations -from ._management_group_subscriptions_operations import ManagementGroupSubscriptionsOperations -from ._hierarchy_settings_operations import HierarchySettingsOperations -from ._operations import Operations -from ._management_groups_api_operations import ManagementGroupsAPIOperationsMixin -from ._entities_operations import EntitiesOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._management_groups_operations import ManagementGroupsOperations # type: ignore +from ._management_group_subscriptions_operations import ManagementGroupSubscriptionsOperations # type: ignore +from ._hierarchy_settings_operations import HierarchySettingsOperations # type: ignore +from ._operations import Operations # type: ignore +from ._management_groups_api_operations import _ManagementGroupsAPIOperationsMixin # type: ignore # pylint: disable=unused-import +from ._entities_operations import EntitiesOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -22,8 +29,7 @@ "ManagementGroupSubscriptionsOperations", "HierarchySettingsOperations", "Operations", - "ManagementGroupsAPIOperationsMixin", "EntitiesOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_entities_operations.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_entities_operations.py index cbf581dd3f19..59eac6281359 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_entities_operations.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_entities_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar, Union +from collections.abc import MutableMapping +from typing import Any, Callable, Optional, TypeVar, Union import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -26,14 +26,13 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer from ...operations._entities_operations import build_list_request +from .._configuration import ManagementGroupsAPIConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list class EntitiesOperations: @@ -50,10 +49,10 @@ class EntitiesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ManagementGroupsAPIConfiguration = 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 def list( @@ -68,7 +67,7 @@ def list( group_name: Optional[str] = None, cache_control: str = "no-cache", **kwargs: Any - ) -> AsyncIterable["_models.EntityInfo"]: + ) -> AsyncItemPaged["_models.EntityInfo"]: """List all entities (Management Groups, Subscriptions, etc.) for the authenticated user. :param skiptoken: Page continuation token is only used if a previous operation returned a @@ -132,7 +131,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EntityListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -194,7 +193,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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_hierarchy_settings_operations.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_hierarchy_settings_operations.py index 996a93ab1010..d204aa74bc14 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_hierarchy_settings_operations.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_hierarchy_settings_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -25,6 +25,7 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer from ...operations._hierarchy_settings_operations import ( build_create_or_update_request, build_delete_request, @@ -32,13 +33,11 @@ build_list_request, build_update_request, ) +from .._configuration import ManagementGroupsAPIConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list class HierarchySettingsOperations: @@ -55,10 +54,10 @@ class HierarchySettingsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ManagementGroupsAPIConfiguration = 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 async def list(self, group_id: str, **kwargs: Any) -> _models.HierarchySettingsList: @@ -71,7 +70,7 @@ async def list(self, group_id: str, **kwargs: Any) -> _models.HierarchySettingsL :rtype: ~azure.mgmt.managementgroups.models.HierarchySettingsList :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -102,7 +101,10 @@ async def list(self, group_id: str, **kwargs: Any) -> _models.HierarchySettingsL if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("HierarchySettingsList", pipeline_response.http_response) @@ -123,7 +125,7 @@ async def get(self, group_id: str, **kwargs: Any) -> _models.HierarchySettings: :rtype: ~azure.mgmt.managementgroups.models.HierarchySettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -154,7 +156,10 @@ async def get(self, group_id: str, **kwargs: Any) -> _models.HierarchySettings: if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("HierarchySettings", pipeline_response.http_response) @@ -230,7 +235,7 @@ async def create_or_update( :rtype: ~azure.mgmt.managementgroups.models.HierarchySettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -273,7 +278,10 @@ async def create_or_update( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("HierarchySettings", pipeline_response.http_response) @@ -349,7 +357,7 @@ async def update( :rtype: ~azure.mgmt.managementgroups.models.HierarchySettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -392,7 +400,10 @@ async def update( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("HierarchySettings", pipeline_response.http_response) @@ -403,7 +414,7 @@ async def update( return deserialized # type: ignore @distributed_trace_async - async def delete(self, group_id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + async def delete(self, group_id: str, **kwargs: Any) -> None: """Deletes the hierarchy settings defined at the Management Group level. :param group_id: Management Group ID. Required. @@ -412,7 +423,7 @@ async def delete(self, group_id: str, **kwargs: Any) -> None: # pylint: disable :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -443,7 +454,10 @@ async def delete(self, group_id: str, **kwargs: Any) -> None: # pylint: disable if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_management_group_subscriptions_operations.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_management_group_subscriptions_operations.py index 2b8418c0ee75..4fb5c1bae852 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_management_group_subscriptions_operations.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_management_group_subscriptions_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from collections.abc import MutableMapping +from typing import Any, Callable, Optional, TypeVar import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -27,19 +27,18 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer from ...operations._management_group_subscriptions_operations import ( build_create_request, build_delete_request, build_get_subscription_request, build_get_subscriptions_under_management_group_request, ) +from .._configuration import ManagementGroupsAPIConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list class ManagementGroupSubscriptionsOperations: @@ -56,10 +55,10 @@ class ManagementGroupSubscriptionsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ManagementGroupsAPIConfiguration = 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 async def create( @@ -78,7 +77,7 @@ async def create( :rtype: ~azure.mgmt.managementgroups.models.SubscriptionUnderManagementGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -111,7 +110,10 @@ async def create( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("SubscriptionUnderManagementGroup", pipeline_response.http_response) @@ -122,9 +124,7 @@ async def create( return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, group_id: str, subscription_id: str, cache_control: str = "no-cache", **kwargs: Any - ) -> None: + async def delete(self, group_id: str, subscription_id: str, cache_control: str = "no-cache", **kwargs: Any) -> None: """De-associates subscription from the management group. :param group_id: Management Group ID. Required. @@ -138,7 +138,7 @@ async def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -171,7 +171,10 @@ async def delete( # pylint: disable=inconsistent-return-statements if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -194,7 +197,7 @@ async def get_subscription( :rtype: ~azure.mgmt.managementgroups.models.SubscriptionUnderManagementGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -227,7 +230,10 @@ async def get_subscription( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("SubscriptionUnderManagementGroup", pipeline_response.http_response) @@ -240,7 +246,7 @@ async def get_subscription( @distributed_trace def get_subscriptions_under_management_group( self, group_id: str, skiptoken: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.SubscriptionUnderManagementGroup"]: + ) -> AsyncItemPaged["_models.SubscriptionUnderManagementGroup"]: """Retrieves details about all subscriptions which are associated with the management group. :param group_id: Management Group ID. Required. @@ -263,7 +269,7 @@ def get_subscriptions_under_management_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ListSubscriptionUnderManagementGroup] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -318,7 +324,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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_management_groups_api_operations.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_management_groups_api_operations.py index 8aa8c6eefadb..373521b1c9a6 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_management_groups_api_operations.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_management_groups_api_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines,too-many-statements +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, IO, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -25,22 +26,22 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._utils.utils import ClientMixinABC from ...operations._management_groups_api_operations import ( build_check_name_availability_request, build_start_tenant_backfill_request, build_tenant_backfill_status_request, ) -from .._vendor import ManagementGroupsAPIMixinABC +from .._configuration import ManagementGroupsAPIConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list -class ManagementGroupsAPIOperationsMixin(ManagementGroupsAPIMixinABC): +class _ManagementGroupsAPIOperationsMixin( + ClientMixinABC[AsyncPipelineClient[HttpRequest, AsyncHttpResponse], ManagementGroupsAPIConfiguration] +): @overload async def check_name_availability( @@ -95,7 +96,7 @@ async def check_name_availability( :rtype: ~azure.mgmt.managementgroups.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -137,7 +138,10 @@ async def check_name_availability( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response.http_response) @@ -155,7 +159,7 @@ async def start_tenant_backfill(self, **kwargs: Any) -> _models.TenantBackfillSt :rtype: ~azure.mgmt.managementgroups.models.TenantBackfillStatusResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -185,7 +189,10 @@ async def start_tenant_backfill(self, **kwargs: Any) -> _models.TenantBackfillSt if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("TenantBackfillStatusResult", pipeline_response.http_response) @@ -203,7 +210,7 @@ async def tenant_backfill_status(self, **kwargs: Any) -> _models.TenantBackfillS :rtype: ~azure.mgmt.managementgroups.models.TenantBackfillStatusResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -233,7 +240,10 @@ async def tenant_backfill_status(self, **kwargs: Any) -> _models.TenantBackfillS if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("TenantBackfillStatusResult", pipeline_response.http_response) diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_management_groups_operations.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_management_groups_operations.py index df7ca2a82348..cd63c9a82728 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_management_groups_operations.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_management_groups_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,11 +5,12 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -32,6 +32,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer from ...operations._management_groups_operations import ( build_create_or_update_request, build_delete_request, @@ -40,13 +41,11 @@ build_list_request, build_update_request, ) +from .._configuration import ManagementGroupsAPIConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list class ManagementGroupsOperations: @@ -63,15 +62,15 @@ class ManagementGroupsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ManagementGroupsAPIConfiguration = 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 def list( self, cache_control: str = "no-cache", skiptoken: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ManagementGroupInfo"]: + ) -> AsyncItemPaged["_models.ManagementGroupInfo"]: """List management groups for the authenticated user. :param cache_control: Indicates whether the request should utilize any caches. Populate the @@ -94,7 +93,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagementGroupListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -149,7 +148,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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -189,7 +191,7 @@ async def get( :rtype: ~azure.mgmt.managementgroups.models.ManagementGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -224,7 +226,10 @@ async def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ManagementGroup", pipeline_response.http_response) @@ -241,7 +246,7 @@ async def _create_or_update_initial( cache_control: str = "no-cache", **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -290,7 +295,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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -527,7 +535,7 @@ async def update( :rtype: ~azure.mgmt.managementgroups.models.ManagementGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -571,7 +579,10 @@ async def update( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ManagementGroup", pipeline_response.http_response) @@ -584,7 +595,7 @@ async def update( async def _delete_initial( self, group_id: str, cache_control: str = "no-cache", **kwargs: Any ) -> AsyncIterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -621,7 +632,10 @@ async def _delete_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -713,7 +727,7 @@ def get_long_running_output(pipeline_response): @distributed_trace def get_descendants( self, group_id: str, skiptoken: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.DescendantInfo"]: + ) -> AsyncItemPaged["_models.DescendantInfo"]: """List all entities that descend from a management group. :param group_id: Management Group ID. Required. @@ -738,7 +752,7 @@ def get_descendants( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DescendantListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -794,7 +808,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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_operations.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_operations.py index 9e46fe69fbaa..b232f9f5d7fa 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_operations.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +from collections.abc import MutableMapping +from typing import Any, Callable, Optional, TypeVar import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -26,14 +26,13 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models +from ..._utils.serialization import Deserializer, Serializer from ...operations._operations import build_list_request +from .._configuration import ManagementGroupsAPIConfiguration -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list class Operations: @@ -50,13 +49,13 @@ class Operations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ManagementGroupsAPIConfiguration = 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 - def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: """Lists all of the available Management REST API operations. :return: An iterator like instance of either Operation or the result of cls(response) @@ -69,7 +68,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -122,7 +121,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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/models/__init__.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/models/__init__.py index 118960055d79..f7d7a91724ff 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/models/__init__.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/models/__init__.py @@ -5,52 +5,63 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import AzureAsyncOperationResults -from ._models_py3 import CheckNameAvailabilityRequest -from ._models_py3 import CheckNameAvailabilityResult -from ._models_py3 import CreateManagementGroupChildInfo -from ._models_py3 import CreateManagementGroupDetails -from ._models_py3 import CreateManagementGroupRequest -from ._models_py3 import CreateOrUpdateSettingsRequest -from ._models_py3 import CreateParentGroupInfo -from ._models_py3 import DescendantInfo -from ._models_py3 import DescendantListResult -from ._models_py3 import DescendantParentGroupInfo -from ._models_py3 import EntityHierarchyItem -from ._models_py3 import EntityInfo -from ._models_py3 import EntityListResult -from ._models_py3 import EntityParentGroupInfo -from ._models_py3 import ErrorDetails -from ._models_py3 import ErrorResponse -from ._models_py3 import HierarchySettings -from ._models_py3 import HierarchySettingsInfo -from ._models_py3 import HierarchySettingsList -from ._models_py3 import ListSubscriptionUnderManagementGroup -from ._models_py3 import ManagementGroup -from ._models_py3 import ManagementGroupChildInfo -from ._models_py3 import ManagementGroupDetails -from ._models_py3 import ManagementGroupInfo -from ._models_py3 import ManagementGroupListResult -from ._models_py3 import ManagementGroupPathElement -from ._models_py3 import Operation -from ._models_py3 import OperationDisplayProperties -from ._models_py3 import OperationListResult -from ._models_py3 import OperationResults -from ._models_py3 import ParentGroupInfo -from ._models_py3 import PatchManagementGroupRequest -from ._models_py3 import SubscriptionUnderManagementGroup -from ._models_py3 import TenantBackfillStatusResult +from typing import TYPE_CHECKING -from ._management_groups_api_enums import EntitySearchType -from ._management_groups_api_enums import EntityViewParameterType -from ._management_groups_api_enums import ManagementGroupChildType -from ._management_groups_api_enums import ManagementGroupExpandType -from ._management_groups_api_enums import Permissions -from ._management_groups_api_enums import Reason -from ._management_groups_api_enums import Status +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + AzureAsyncOperationResults, + CheckNameAvailabilityRequest, + CheckNameAvailabilityResult, + CreateManagementGroupChildInfo, + CreateManagementGroupDetails, + CreateManagementGroupRequest, + CreateOrUpdateSettingsRequest, + CreateParentGroupInfo, + DescendantInfo, + DescendantListResult, + DescendantParentGroupInfo, + EntityHierarchyItem, + EntityInfo, + EntityListResult, + EntityParentGroupInfo, + ErrorDetails, + ErrorResponse, + HierarchySettings, + HierarchySettingsInfo, + HierarchySettingsList, + ListSubscriptionUnderManagementGroup, + ManagementGroup, + ManagementGroupChildInfo, + ManagementGroupDetails, + ManagementGroupInfo, + ManagementGroupListResult, + ManagementGroupPathElement, + Operation, + OperationDisplayProperties, + OperationListResult, + OperationResults, + ParentGroupInfo, + PatchManagementGroupRequest, + SubscriptionUnderManagementGroup, + TenantBackfillStatusResult, +) + +from ._management_groups_api_enums import ( # type: ignore + EntitySearchType, + EntityViewParameterType, + ManagementGroupChildType, + ManagementGroupExpandType, + Permissions, + Reason, + Status, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -97,5 +108,5 @@ "Reason", "Status", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/models/_models_py3.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/models/_models_py3.py index 85432e7f5f8e..484f0fc0a2bf 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/models/_models_py3.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/models/_models_py3.py @@ -1,5 +1,5 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 -# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -8,12 +8,11 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, List, Literal, Optional, TYPE_CHECKING, Union +from typing import Any, Literal, Optional, TYPE_CHECKING, Union -from .. import _serialization +from .._utils import serialization as _serialization if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models @@ -65,10 +64,10 @@ def __init__(self, *, tenant_id: Optional[str] = None, display_name: Optional[st :paramtype display_name: str """ super().__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.status = None + self.id: Optional[str] = None + self.type: Optional[str] = None + self.name: Optional[str] = None + self.status: Optional[str] = None self.tenant_id = tenant_id self.display_name = display_name @@ -142,9 +141,9 @@ class CheckNameAvailabilityResult(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.name_available = None - self.reason = None - self.message = None + self.name_available: Optional[bool] = None + self.reason: Optional[Union[str, "_models.Reason"]] = None + self.message: Optional[str] = None class CreateManagementGroupChildInfo(_serialization.Model): @@ -187,11 +186,11 @@ class CreateManagementGroupChildInfo(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.type = None - self.id = None - self.name = None - self.display_name = None - self.children = None + self.type: Optional[Union[str, "_models.ManagementGroupChildType"]] = None + self.id: Optional[str] = None + self.name: Optional[str] = None + self.display_name: Optional[str] = None + self.children: Optional[list["_models.CreateManagementGroupChildInfo"]] = None class CreateManagementGroupDetails(_serialization.Model): @@ -228,9 +227,9 @@ def __init__(self, *, parent: Optional["_models.CreateParentGroupInfo"] = None, :paramtype parent: ~azure.mgmt.managementgroups.models.CreateParentGroupInfo """ super().__init__(**kwargs) - self.version = None - self.updated_time = None - self.updated_by = None + self.version: Optional[int] = None + self.updated_time: Optional[datetime.datetime] = None + self.updated_by: Optional[str] = None self.parent = parent @@ -295,13 +294,13 @@ def __init__( :paramtype details: ~azure.mgmt.managementgroups.models.CreateManagementGroupDetails """ super().__init__(**kwargs) - self.id = None - self.type = None + self.id: Optional[str] = None + self.type: Optional[str] = None self.name = name - self.tenant_id = None + self.tenant_id: Optional[str] = None self.display_name = display_name self.details = details - self.children = None + self.children: Optional[list["_models.CreateManagementGroupChildInfo"]] = None class CreateOrUpdateSettingsRequest(_serialization.Model): @@ -384,8 +383,8 @@ def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylin """ super().__init__(**kwargs) self.id = id - self.name = None - self.display_name = None + self.name: Optional[str] = None + self.display_name: Optional[str] = None class DescendantInfo(_serialization.Model): @@ -436,9 +435,9 @@ def __init__( :paramtype parent: ~azure.mgmt.managementgroups.models.DescendantParentGroupInfo """ super().__init__(**kwargs) - self.id = None - self.type = None - self.name = None + self.id: Optional[str] = None + self.type: Optional[str] = None + self.name: Optional[str] = None self.display_name = display_name self.parent = parent @@ -463,14 +462,14 @@ class DescendantListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.DescendantInfo"]] = None, **kwargs: Any) -> None: + def __init__(self, *, value: Optional[list["_models.DescendantInfo"]] = None, **kwargs: Any) -> None: """ :keyword value: The list of descendants. :paramtype value: list[~azure.mgmt.managementgroups.models.DescendantInfo] """ super().__init__(**kwargs) self.value = value - self.next_link = None + self.next_link: Optional[str] = None class DescendantParentGroupInfo(_serialization.Model): @@ -537,7 +536,7 @@ def __init__( *, display_name: Optional[str] = None, permissions: Optional[Union[str, "_models.Permissions"]] = None, - children: Optional[List["_models.EntityHierarchyItem"]] = None, + children: Optional[list["_models.EntityHierarchyItem"]] = None, **kwargs: Any ) -> None: """ @@ -550,15 +549,15 @@ def __init__( :paramtype children: list[~azure.mgmt.managementgroups.models.EntityHierarchyItem] """ super().__init__(**kwargs) - self.id = None - self.type = None - self.name = None + self.id: Optional[str] = None + self.type: Optional[str] = None + self.name: Optional[str] = None self.display_name = display_name self.permissions = permissions self.children = children -class EntityInfo(_serialization.Model): # pylint: disable=too-many-instance-attributes +class EntityInfo(_serialization.Model): """The entity. Variables are only populated by the server, and will be ignored when sending a request. @@ -631,8 +630,8 @@ def __init__( number_of_descendants: Optional[int] = None, number_of_children: Optional[int] = None, number_of_child_groups: Optional[int] = None, - parent_display_name_chain: Optional[List[str]] = None, - parent_name_chain: Optional[List[str]] = None, + parent_display_name_chain: Optional[list[str]] = None, + parent_name_chain: Optional[list[str]] = None, **kwargs: Any ) -> None: """ @@ -664,9 +663,9 @@ def __init__( :paramtype parent_name_chain: list[str] """ super().__init__(**kwargs) - self.id = None - self.type = None - self.name = None + self.id: Optional[str] = None + self.type: Optional[str] = None + self.name: Optional[str] = None self.tenant_id = tenant_id self.display_name = display_name self.parent = parent @@ -703,15 +702,15 @@ class EntityListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.EntityInfo"]] = None, **kwargs: Any) -> None: + def __init__(self, *, value: Optional[list["_models.EntityInfo"]] = None, **kwargs: Any) -> None: """ :keyword value: The list of entities. :paramtype value: list[~azure.mgmt.managementgroups.models.EntityInfo] """ super().__init__(**kwargs) self.value = value - self.count = None - self.next_link = None + self.count: Optional[int] = None + self.next_link: Optional[str] = None class EntityParentGroupInfo(_serialization.Model): @@ -860,9 +859,9 @@ def __init__( :paramtype default_management_group: str """ super().__init__(**kwargs) - self.id = None - self.type = None - self.name = None + self.id: Optional[str] = None + self.type: Optional[str] = None + self.name: Optional[str] = None self.tenant_id = tenant_id self.require_authorization_for_group_creation = require_authorization_for_group_creation self.default_management_group = default_management_group @@ -938,9 +937,9 @@ def __init__( :paramtype default_management_group: str """ super().__init__(**kwargs) - self.id = None - self.type = None - self.name = None + self.id: Optional[str] = None + self.type: Optional[str] = None + self.name: Optional[str] = None self.tenant_id = tenant_id self.require_authorization_for_group_creation = require_authorization_for_group_creation self.default_management_group = default_management_group @@ -966,14 +965,14 @@ class HierarchySettingsList(_serialization.Model): "next_link": {"key": "@nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.HierarchySettingsInfo"]] = None, **kwargs: Any) -> None: + def __init__(self, *, value: Optional[list["_models.HierarchySettingsInfo"]] = None, **kwargs: Any) -> None: """ :keyword value: The list of hierarchy settings. :paramtype value: list[~azure.mgmt.managementgroups.models.HierarchySettingsInfo] """ super().__init__(**kwargs) self.value = value - self.next_link = None + self.next_link: Optional[str] = None class ListSubscriptionUnderManagementGroup(_serialization.Model): @@ -997,7 +996,7 @@ class ListSubscriptionUnderManagementGroup(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.SubscriptionUnderManagementGroup"]] = None, **kwargs: Any + self, *, value: Optional[list["_models.SubscriptionUnderManagementGroup"]] = None, **kwargs: Any ) -> None: """ :keyword value: The list of subscriptions. @@ -1005,7 +1004,7 @@ def __init__( """ super().__init__(**kwargs) self.value = value - self.next_link = None + self.next_link: Optional[str] = None class ManagementGroup(_serialization.Model): @@ -1054,7 +1053,7 @@ def __init__( tenant_id: Optional[str] = None, display_name: Optional[str] = None, details: Optional["_models.ManagementGroupDetails"] = None, - children: Optional[List["_models.ManagementGroupChildInfo"]] = None, + children: Optional[list["_models.ManagementGroupChildInfo"]] = None, **kwargs: Any ) -> None: """ @@ -1069,9 +1068,9 @@ def __init__( :paramtype children: list[~azure.mgmt.managementgroups.models.ManagementGroupChildInfo] """ super().__init__(**kwargs) - self.id = None - self.type = None - self.name = None + self.id: Optional[str] = None + self.type: Optional[str] = None + self.name: Optional[str] = None self.tenant_id = tenant_id self.display_name = display_name self.details = details @@ -1112,7 +1111,7 @@ def __init__( id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, display_name: Optional[str] = None, - children: Optional[List["_models.ManagementGroupChildInfo"]] = None, + children: Optional[list["_models.ManagementGroupChildInfo"]] = None, **kwargs: Any ) -> None: """ @@ -1180,9 +1179,9 @@ def __init__( updated_time: Optional[datetime.datetime] = None, updated_by: Optional[str] = None, parent: Optional["_models.ParentGroupInfo"] = None, - path: Optional[List["_models.ManagementGroupPathElement"]] = None, - management_group_ancestors: Optional[List[str]] = None, - management_group_ancestors_chain: Optional[List["_models.ManagementGroupPathElement"]] = None, + path: Optional[list["_models.ManagementGroupPathElement"]] = None, + management_group_ancestors: Optional[list[str]] = None, + management_group_ancestors_chain: Optional[list["_models.ManagementGroupPathElement"]] = None, **kwargs: Any ) -> None: """ @@ -1256,9 +1255,9 @@ def __init__(self, *, tenant_id: Optional[str] = None, display_name: Optional[st :paramtype display_name: str """ super().__init__(**kwargs) - self.id = None - self.type = None - self.name = None + self.id: Optional[str] = None + self.type: Optional[str] = None + self.name: Optional[str] = None self.tenant_id = tenant_id self.display_name = display_name @@ -1283,14 +1282,14 @@ class ManagementGroupListResult(_serialization.Model): "next_link": {"key": "@nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.ManagementGroupInfo"]] = None, **kwargs: Any) -> None: + def __init__(self, *, value: Optional[list["_models.ManagementGroupInfo"]] = None, **kwargs: Any) -> None: """ :keyword value: The list of management groups. :paramtype value: list[~azure.mgmt.managementgroups.models.ManagementGroupInfo] """ super().__init__(**kwargs) self.value = value - self.next_link = None + self.next_link: Optional[str] = None class ManagementGroupPathElement(_serialization.Model): @@ -1345,7 +1344,7 @@ def __init__(self, *, display: Optional["_models.OperationDisplayProperties"] = :paramtype display: ~azure.mgmt.managementgroups.models.OperationDisplayProperties """ super().__init__(**kwargs) - self.name = None + self.name: Optional[str] = None self.display = display @@ -1381,10 +1380,10 @@ class OperationDisplayProperties(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None + self.provider: Optional[str] = None + self.resource: Optional[str] = None + self.operation: Optional[str] = None + self.description: Optional[str] = None class OperationListResult(_serialization.Model): @@ -1411,8 +1410,8 @@ class OperationListResult(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.value = None - self.next_link = None + self.value: Optional[list["_models.Operation"]] = None + self.next_link: Optional[str] = None class OperationResults(_serialization.Model): @@ -1458,9 +1457,9 @@ def __init__(self, *, tenant_id: Optional[str] = None, display_name: Optional[st :paramtype display_name: str """ super().__init__(**kwargs) - self.id = None - self.type = None - self.name = None + self.id: Optional[str] = None + self.type: Optional[str] = None + self.name: Optional[str] = None self.tenant_id = tenant_id self.display_name = display_name @@ -1543,7 +1542,7 @@ class SubscriptionUnderManagementGroup(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The fully qualified ID for the subscription. For example, - /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/subscriptions/0000000-0000-0000-0000-000000000001. # pylint: disable=line-too-long + /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/subscriptions/0000000-0000-0000-0000-000000000001. :vartype id: str :ivar type: The type of the resource. For example, Microsoft.Management/managementGroups/subscriptions. @@ -1599,9 +1598,9 @@ def __init__( :paramtype state: str """ super().__init__(**kwargs) - self.id = None - self.type = None - self.name = None + self.id: Optional[str] = None + self.type: Optional[str] = None + self.name: Optional[str] = None self.tenant = tenant self.display_name = display_name self.parent = parent @@ -1634,5 +1633,5 @@ class TenantBackfillStatusResult(_serialization.Model): def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.tenant_id = None - self.status = None + self.tenant_id: Optional[str] = None + self.status: Optional[Union[str, "_models.Status"]] = None diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/__init__.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/__init__.py index 17da0c8d00e0..777e215f1a9f 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/__init__.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/__init__.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._management_groups_operations import ManagementGroupsOperations -from ._management_group_subscriptions_operations import ManagementGroupSubscriptionsOperations -from ._hierarchy_settings_operations import HierarchySettingsOperations -from ._operations import Operations -from ._management_groups_api_operations import ManagementGroupsAPIOperationsMixin -from ._entities_operations import EntitiesOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._management_groups_operations import ManagementGroupsOperations # type: ignore +from ._management_group_subscriptions_operations import ManagementGroupSubscriptionsOperations # type: ignore +from ._hierarchy_settings_operations import HierarchySettingsOperations # type: ignore +from ._operations import Operations # type: ignore +from ._management_groups_api_operations import _ManagementGroupsAPIOperationsMixin # type: ignore # pylint: disable=unused-import +from ._entities_operations import EntitiesOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -22,8 +29,7 @@ "ManagementGroupSubscriptionsOperations", "HierarchySettingsOperations", "Operations", - "ManagementGroupsAPIOperationsMixin", "EntitiesOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_entities_operations.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_entities_operations.py index 848a0c91605d..13e2f733dff8 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_entities_operations.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_entities_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar, Union +from collections.abc import MutableMapping +from typing import Any, Callable, Optional, TypeVar, Union import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -26,14 +26,12 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._serialization import Serializer +from .._configuration import ManagementGroupsAPIConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +List = list _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False @@ -100,12 +98,12 @@ class EntitiesOperations: models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ManagementGroupsAPIConfiguration = 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 def list( @@ -120,7 +118,7 @@ def list( group_name: Optional[str] = None, cache_control: str = "no-cache", **kwargs: Any - ) -> Iterable["_models.EntityInfo"]: + ) -> ItemPaged["_models.EntityInfo"]: """List all entities (Management Groups, Subscriptions, etc.) for the authenticated user. :param skiptoken: Page continuation token is only used if a previous operation returned a @@ -184,7 +182,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.EntityListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -246,7 +244,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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_hierarchy_settings_operations.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_hierarchy_settings_operations.py index d7cb37ab15bf..8a1926d21001 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_hierarchy_settings_operations.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_hierarchy_settings_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -25,14 +25,12 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._serialization import Serializer +from .._configuration import ManagementGroupsAPIConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +List = list _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False @@ -176,12 +174,12 @@ class HierarchySettingsOperations: models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ManagementGroupsAPIConfiguration = 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 def list(self, group_id: str, **kwargs: Any) -> _models.HierarchySettingsList: @@ -194,7 +192,7 @@ def list(self, group_id: str, **kwargs: Any) -> _models.HierarchySettingsList: :rtype: ~azure.mgmt.managementgroups.models.HierarchySettingsList :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -225,7 +223,10 @@ def list(self, group_id: str, **kwargs: Any) -> _models.HierarchySettingsList: if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("HierarchySettingsList", pipeline_response.http_response) @@ -246,7 +247,7 @@ def get(self, group_id: str, **kwargs: Any) -> _models.HierarchySettings: :rtype: ~azure.mgmt.managementgroups.models.HierarchySettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -277,7 +278,10 @@ def get(self, group_id: str, **kwargs: Any) -> _models.HierarchySettings: if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("HierarchySettings", pipeline_response.http_response) @@ -353,7 +357,7 @@ def create_or_update( :rtype: ~azure.mgmt.managementgroups.models.HierarchySettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -396,7 +400,10 @@ def create_or_update( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("HierarchySettings", pipeline_response.http_response) @@ -472,7 +479,7 @@ def update( :rtype: ~azure.mgmt.managementgroups.models.HierarchySettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -515,7 +522,10 @@ def update( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("HierarchySettings", pipeline_response.http_response) @@ -535,7 +545,7 @@ def delete(self, group_id: str, **kwargs: Any) -> None: # pylint: disable=incon :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,7 +576,10 @@ def delete(self, group_id: str, **kwargs: Any) -> None: # pylint: disable=incon if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_management_group_subscriptions_operations.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_management_group_subscriptions_operations.py index a1ba0e701465..728e6fb2e7c4 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_management_group_subscriptions_operations.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_management_group_subscriptions_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from collections.abc import MutableMapping +from typing import Any, Callable, Optional, TypeVar import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -26,14 +26,12 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._serialization import Serializer +from .._configuration import ManagementGroupsAPIConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +List = list _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False @@ -51,7 +49,7 @@ def build_create_request( # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "groupId": _SERIALIZER.url("group_id", group_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -82,7 +80,7 @@ def build_delete_request( # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "groupId": _SERIALIZER.url("group_id", group_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -113,7 +111,7 @@ def build_get_subscription_request( # Construct URL _url = kwargs.pop( "template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "groupId": _SERIALIZER.url("group_id", group_id, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -172,12 +170,12 @@ class ManagementGroupSubscriptionsOperations: models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ManagementGroupsAPIConfiguration = 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 def create( @@ -196,7 +194,7 @@ def create( :rtype: ~azure.mgmt.managementgroups.models.SubscriptionUnderManagementGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -229,7 +227,10 @@ def create( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("SubscriptionUnderManagementGroup", pipeline_response.http_response) @@ -256,7 +257,7 @@ def delete( # pylint: disable=inconsistent-return-statements :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -289,7 +290,10 @@ def delete( # pylint: disable=inconsistent-return-statements if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -312,7 +316,7 @@ def get_subscription( :rtype: ~azure.mgmt.managementgroups.models.SubscriptionUnderManagementGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -345,7 +349,10 @@ def get_subscription( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("SubscriptionUnderManagementGroup", pipeline_response.http_response) @@ -358,7 +365,7 @@ def get_subscription( @distributed_trace def get_subscriptions_under_management_group( self, group_id: str, skiptoken: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.SubscriptionUnderManagementGroup"]: + ) -> ItemPaged["_models.SubscriptionUnderManagementGroup"]: """Retrieves details about all subscriptions which are associated with the management group. :param group_id: Management Group ID. Required. @@ -381,7 +388,7 @@ def get_subscriptions_under_management_group( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ListSubscriptionUnderManagementGroup] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -436,7 +443,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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_management_groups_api_operations.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_management_groups_api_operations.py index 665856ed4c5a..970833c2fca0 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_management_groups_api_operations.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_management_groups_api_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload +from typing import Any, Callable, IO, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -25,15 +25,13 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._serialization import Serializer -from .._vendor import ManagementGroupsAPIMixinABC +from .._configuration import ManagementGroupsAPIConfiguration +from .._utils.serialization import Serializer +from .._utils.utils import ClientMixinABC -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +List = list _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False @@ -99,7 +97,9 @@ def build_tenant_backfill_status_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class ManagementGroupsAPIOperationsMixin(ManagementGroupsAPIMixinABC): +class _ManagementGroupsAPIOperationsMixin( + ClientMixinABC[PipelineClient[HttpRequest, HttpResponse], ManagementGroupsAPIConfiguration] +): @overload def check_name_availability( @@ -154,7 +154,7 @@ def check_name_availability( :rtype: ~azure.mgmt.managementgroups.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -196,7 +196,10 @@ def check_name_availability( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response.http_response) @@ -214,7 +217,7 @@ def start_tenant_backfill(self, **kwargs: Any) -> _models.TenantBackfillStatusRe :rtype: ~azure.mgmt.managementgroups.models.TenantBackfillStatusResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -244,7 +247,10 @@ def start_tenant_backfill(self, **kwargs: Any) -> _models.TenantBackfillStatusRe if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("TenantBackfillStatusResult", pipeline_response.http_response) @@ -262,7 +268,7 @@ def tenant_backfill_status(self, **kwargs: Any) -> _models.TenantBackfillStatusR :rtype: ~azure.mgmt.managementgroups.models.TenantBackfillStatusResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -292,7 +298,10 @@ def tenant_backfill_status(self, **kwargs: Any) -> _models.TenantBackfillStatusR if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("TenantBackfillStatusResult", pipeline_response.http_response) diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_management_groups_operations.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_management_groups_operations.py index 62631da53036..67b1abf477d7 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_management_groups_operations.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_management_groups_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,11 +5,12 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -31,14 +31,12 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._serialization import Serializer +from .._configuration import ManagementGroupsAPIConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +List = list _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False @@ -235,17 +233,17 @@ class ManagementGroupsOperations: models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ManagementGroupsAPIConfiguration = 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 def list( self, cache_control: str = "no-cache", skiptoken: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ManagementGroupInfo"]: + ) -> ItemPaged["_models.ManagementGroupInfo"]: """List management groups for the authenticated user. :param cache_control: Indicates whether the request should utilize any caches. Populate the @@ -267,7 +265,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagementGroupListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -322,7 +320,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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -362,7 +363,7 @@ def get( :rtype: ~azure.mgmt.managementgroups.models.ManagementGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -397,7 +398,10 @@ def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ManagementGroup", pipeline_response.http_response) @@ -414,7 +418,7 @@ def _create_or_update_initial( cache_control: str = "no-cache", **kwargs: Any ) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -463,7 +467,10 @@ def _create_or_update_initial( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -696,7 +703,7 @@ def update( :rtype: ~azure.mgmt.managementgroups.models.ManagementGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -740,7 +747,10 @@ def update( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ManagementGroup", pipeline_response.http_response) @@ -751,7 +761,7 @@ def update( return deserialized # type: ignore def _delete_initial(self, group_id: str, cache_control: str = "no-cache", **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -788,7 +798,10 @@ def _delete_initial(self, group_id: str, cache_control: str = "no-cache", **kwar except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -879,7 +892,7 @@ def get_long_running_output(pipeline_response): @distributed_trace def get_descendants( self, group_id: str, skiptoken: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.DescendantInfo"]: + ) -> ItemPaged["_models.DescendantInfo"]: """List all entities that descend from a management group. :param group_id: Management Group ID. Required. @@ -903,7 +916,7 @@ def get_descendants( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DescendantListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -959,7 +972,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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_operations.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_operations.py index a4e8257524b2..300c1cbc156f 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_operations.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +from collections.abc import MutableMapping +from typing import Any, Callable, Optional, TypeVar import urllib.parse +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -26,14 +26,12 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._serialization import Serializer +from .._configuration import ManagementGroupsAPIConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +List = list _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False @@ -70,15 +68,15 @@ class Operations: models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ManagementGroupsAPIConfiguration = 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 - def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: + def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: """Lists all of the available Management REST API operations. :return: An iterator like instance of either Operation or the result of cls(response) @@ -91,7 +89,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -144,7 +142,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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize( + _models.ErrorResponse, + pipeline_response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/add_management_group_subscription.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/add_management_group_subscription.py index d819ea2f2dd6..5c2ee1ff82b8 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/add_management_group_subscription.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/add_management_group_subscription.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/AddManagementGroupSubscription.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/AddManagementGroupSubscription.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/check_management_group_name_availability.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/check_management_group_name_availability.py index ea68c2126682..ef6cd460683b 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/check_management_group_name_availability.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/check_management_group_name_availability.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/CheckManagementGroupNameAvailability.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/CheckManagementGroupNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/delete_hierarchy_settings.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/delete_hierarchy_settings.py index a63f8f1208cc..03c66f4b2b9b 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/delete_hierarchy_settings.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/delete_hierarchy_settings.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -34,6 +35,6 @@ def main(): ) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/DeleteHierarchySettings.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/DeleteHierarchySettings.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/delete_management_group.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/delete_management_group.py index 3beb74f6f45a..9d7fc910aea7 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/delete_management_group.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/delete_management_group.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/DeleteManagementGroup.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/DeleteManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_all_subscriptions_from_management_group.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_all_subscriptions_from_management_group.py index e48422e5a918..554d2ffe4b1e 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_all_subscriptions_from_management_group.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_all_subscriptions_from_management_group.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetAllSubscriptionsFromManagementGroup.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/GetAllSubscriptionsFromManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_descendants.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_descendants.py index 7d31d56e71d9..31ebaf9a7bf6 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_descendants.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_descendants.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetDescendants.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/GetDescendants.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_entities.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_entities.py index 95b671c9aa7c..dc61fbddda8e 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_entities.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_entities.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetEntities.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/GetEntities.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_hierarchy_settings.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_hierarchy_settings.py index 277b028cccc0..a63b36838e18 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_hierarchy_settings.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_hierarchy_settings.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetHierarchySettings.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/GetHierarchySettings.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_management_group.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_management_group.py index 899379ca04c9..198bfda6e658 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_management_group.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_management_group.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroup.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/GetManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_management_group_with_ancestors.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_management_group_with_ancestors.py index 54945f11d5f5..4cf45d79eb18 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_management_group_with_ancestors.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_management_group_with_ancestors.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithAncestors.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/GetManagementGroupWithAncestors.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_management_group_with_expand.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_management_group_with_expand.py index 1d15fb613e52..d7c57bf7d9bb 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_management_group_with_expand.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_management_group_with_expand.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpand.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/GetManagementGroupWithExpand.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_management_group_with_expand_and_recurse.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_management_group_with_expand_and_recurse.py index 20e26124f02d..d4c9e4157229 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_management_group_with_expand_and_recurse.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_management_group_with_expand_and_recurse.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpandAndRecurse.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/GetManagementGroupWithExpandAndRecurse.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_management_group_with_path.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_management_group_with_path.py index d354b4db4192..a4f7abfc58b2 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_management_group_with_path.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_management_group_with_path.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithPath.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/GetManagementGroupWithPath.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_subscription_from_management_group.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_subscription_from_management_group.py index a30e1cd3218a..517cffab76cc 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_subscription_from_management_group.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/get_subscription_from_management_group.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetSubscriptionFromManagementGroup.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/GetSubscriptionFromManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/list_hierarchy_settings.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/list_hierarchy_settings.py index 79d043988180..390ef937d29c 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/list_hierarchy_settings.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/list_hierarchy_settings.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/ListHierarchySettings.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/ListHierarchySettings.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/list_management_groups.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/list_management_groups.py index c224cd60e988..33e35853255c 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/list_management_groups.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/list_management_groups.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/ListManagementGroups.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/ListManagementGroups.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/list_operations.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/list_operations.py index 425f40edf405..759ce2a8cebd 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/list_operations.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/list_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/ListOperations.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/ListOperations.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/patch_management_group.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/patch_management_group.py index 37f9808f29d7..ab06b202746d 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/patch_management_group.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/patch_management_group.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/PatchManagementGroup.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/PatchManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/put_management_group.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/put_management_group.py index a679c165f0fe..5c8a11e0c2fa 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/put_management_group.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/put_management_group.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -41,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/PutManagementGroup.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/PutManagementGroup.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/remove_management_group_subscription.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/remove_management_group_subscription.py index 31e730d7a20f..895f2b0d2ee2 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/remove_management_group_subscription.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/remove_management_group_subscription.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/RemoveManagementGroupSubscription.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/RemoveManagementGroupSubscription.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/start_tenant_backfill_request.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/start_tenant_backfill_request.py index 3e6e8af4eae3..ac438e9fc1ae 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/start_tenant_backfill_request.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/start_tenant_backfill_request.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -33,6 +34,6 @@ def main(): print(response) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/StartTenantBackfillRequest.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/StartTenantBackfillRequest.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/tenant_backfill_status_request.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/tenant_backfill_status_request.py index 1845f73eede2..62df7ef650df 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/tenant_backfill_status_request.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_samples/tenant_backfill_status_request.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -33,6 +34,6 @@ def main(): print(response) -# x-ms-original-file: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/TenantBackfillStatusRequest.json +# x-ms-original-file: specification/management/resource-manager/Microsoft.Management/ManagementGroups/stable/2021-04-01/examples/TenantBackfillStatusRequest.json if __name__ == "__main__": main() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/conftest.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/conftest.py index c25467ab34b1..d59e8af55682 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/conftest.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/conftest.py @@ -18,7 +18,7 @@ load_dotenv() -# aovid record sensitive identity information in recordings +# For security, please avoid record sensitive identity information in recordings @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): managementgroupsapi_subscription_id = os.environ.get( diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_entities_operations.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_entities_operations.py index fa10581070c1..ca05a5e7311c 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_entities_operations.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_entities_operations.py @@ -20,7 +20,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): + def test_entities_list(self, resource_group): response = self.client.entities.list( api_version="2021-04-01", ) diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_entities_operations_async.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_entities_operations_async.py index bdf74dcbf38b..610a93b96b19 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_entities_operations_async.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_entities_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): + async def test_entities_list(self, resource_group): response = self.client.entities.list( api_version="2021-04-01", ) diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_hierarchy_settings_operations.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_hierarchy_settings_operations.py index a80e2be3c554..01fc3b52c2db 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_hierarchy_settings_operations.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_hierarchy_settings_operations.py @@ -20,7 +20,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): + def test_hierarchy_settings_list(self, resource_group): response = self.client.hierarchy_settings.list( group_id="str", api_version="2021-04-01", @@ -31,7 +31,7 @@ def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_hierarchy_settings_get(self, resource_group): response = self.client.hierarchy_settings.get( group_id="str", api_version="2021-04-01", @@ -42,7 +42,7 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_create_or_update(self, resource_group): + def test_hierarchy_settings_create_or_update(self, resource_group): response = self.client.hierarchy_settings.create_or_update( group_id="str", create_tenant_settings_request={ @@ -57,7 +57,7 @@ def test_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_update(self, resource_group): + def test_hierarchy_settings_update(self, resource_group): response = self.client.hierarchy_settings.update( group_id="str", create_tenant_settings_request={ @@ -72,7 +72,7 @@ def test_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_delete(self, resource_group): + def test_hierarchy_settings_delete(self, resource_group): response = self.client.hierarchy_settings.delete( group_id="str", api_version="2021-04-01", diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_hierarchy_settings_operations_async.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_hierarchy_settings_operations_async.py index d54f6f497f81..48db33b39ecd 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_hierarchy_settings_operations_async.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_hierarchy_settings_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): + async def test_hierarchy_settings_list(self, resource_group): response = await self.client.hierarchy_settings.list( group_id="str", api_version="2021-04-01", @@ -32,7 +32,7 @@ async def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_hierarchy_settings_get(self, resource_group): response = await self.client.hierarchy_settings.get( group_id="str", api_version="2021-04-01", @@ -43,7 +43,7 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_create_or_update(self, resource_group): + async def test_hierarchy_settings_create_or_update(self, resource_group): response = await self.client.hierarchy_settings.create_or_update( group_id="str", create_tenant_settings_request={ @@ -58,7 +58,7 @@ async def test_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_update(self, resource_group): + async def test_hierarchy_settings_update(self, resource_group): response = await self.client.hierarchy_settings.update( group_id="str", create_tenant_settings_request={ @@ -73,7 +73,7 @@ async def test_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_delete(self, resource_group): + async def test_hierarchy_settings_delete(self, resource_group): response = await self.client.hierarchy_settings.delete( group_id="str", api_version="2021-04-01", diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_management_group_subscriptions_operations.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_management_group_subscriptions_operations.py index 27a846c4dc15..b125baab4813 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_management_group_subscriptions_operations.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_management_group_subscriptions_operations.py @@ -20,7 +20,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_create(self, resource_group): + def test_management_group_subscriptions_create(self, resource_group): response = self.client.management_group_subscriptions.create( group_id="str", subscription_id="str", @@ -32,7 +32,7 @@ def test_create(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_delete(self, resource_group): + def test_management_group_subscriptions_delete(self, resource_group): response = self.client.management_group_subscriptions.delete( group_id="str", subscription_id="str", @@ -44,7 +44,7 @@ def test_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get_subscription(self, resource_group): + def test_management_group_subscriptions_get_subscription(self, resource_group): response = self.client.management_group_subscriptions.get_subscription( group_id="str", subscription_id="str", @@ -56,7 +56,7 @@ def test_get_subscription(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get_subscriptions_under_management_group(self, resource_group): + def test_management_group_subscriptions_get_subscriptions_under_management_group(self, resource_group): response = self.client.management_group_subscriptions.get_subscriptions_under_management_group( group_id="str", api_version="2021-04-01", diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_management_group_subscriptions_operations_async.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_management_group_subscriptions_operations_async.py index 68fee623a5d4..40ef5332e7ba 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_management_group_subscriptions_operations_async.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_management_group_subscriptions_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_create(self, resource_group): + async def test_management_group_subscriptions_create(self, resource_group): response = await self.client.management_group_subscriptions.create( group_id="str", subscription_id="str", @@ -33,7 +33,7 @@ async def test_create(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_delete(self, resource_group): + async def test_management_group_subscriptions_delete(self, resource_group): response = await self.client.management_group_subscriptions.delete( group_id="str", subscription_id="str", @@ -45,7 +45,7 @@ async def test_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get_subscription(self, resource_group): + async def test_management_group_subscriptions_get_subscription(self, resource_group): response = await self.client.management_group_subscriptions.get_subscription( group_id="str", subscription_id="str", @@ -57,7 +57,7 @@ async def test_get_subscription(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get_subscriptions_under_management_group(self, resource_group): + async def test_management_group_subscriptions_get_subscriptions_under_management_group(self, resource_group): response = self.client.management_group_subscriptions.get_subscriptions_under_management_group( group_id="str", api_version="2021-04-01", diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_management_groups_operations.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_management_groups_operations.py index f2aea8b3e992..70848ee7009a 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_management_groups_operations.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_management_groups_operations.py @@ -20,7 +20,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): + def test_management_groups_list(self, resource_group): response = self.client.management_groups.list( api_version="2021-04-01", ) @@ -30,7 +30,7 @@ def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get(self, resource_group): + def test_management_groups_get(self, resource_group): response = self.client.management_groups.get( group_id="str", api_version="2021-04-01", @@ -41,7 +41,7 @@ def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_create_or_update(self, resource_group): + def test_management_groups_begin_create_or_update(self, resource_group): response = self.client.management_groups.begin_create_or_update( group_id="str", create_management_group_request={ @@ -66,7 +66,7 @@ def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_update(self, resource_group): + def test_management_groups_update(self, resource_group): response = self.client.management_groups.update( group_id="str", patch_group_request={"displayName": "str", "parentGroupId": "str"}, @@ -78,7 +78,7 @@ def test_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_begin_delete(self, resource_group): + def test_management_groups_begin_delete(self, resource_group): response = self.client.management_groups.begin_delete( group_id="str", api_version="2021-04-01", @@ -89,7 +89,7 @@ def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_get_descendants(self, resource_group): + def test_management_groups_get_descendants(self, resource_group): response = self.client.management_groups.get_descendants( group_id="str", api_version="2021-04-01", diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_management_groups_operations_async.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_management_groups_operations_async.py index b66119c1b13d..ef25f1ed96e2 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_management_groups_operations_async.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_management_groups_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): + async def test_management_groups_list(self, resource_group): response = self.client.management_groups.list( api_version="2021-04-01", ) @@ -31,7 +31,7 @@ async def test_list(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get(self, resource_group): + async def test_management_groups_get(self, resource_group): response = await self.client.management_groups.get( group_id="str", api_version="2021-04-01", @@ -42,7 +42,7 @@ async def test_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_create_or_update(self, resource_group): + async def test_management_groups_begin_create_or_update(self, resource_group): response = await ( await self.client.management_groups.begin_create_or_update( group_id="str", @@ -69,7 +69,7 @@ async def test_begin_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_update(self, resource_group): + async def test_management_groups_update(self, resource_group): response = await self.client.management_groups.update( group_id="str", patch_group_request={"displayName": "str", "parentGroupId": "str"}, @@ -81,7 +81,7 @@ async def test_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_begin_delete(self, resource_group): + async def test_management_groups_begin_delete(self, resource_group): response = await ( await self.client.management_groups.begin_delete( group_id="str", @@ -94,7 +94,7 @@ async def test_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_get_descendants(self, resource_group): + async def test_management_groups_get_descendants(self, resource_group): response = self.client.management_groups.get_descendants( group_id="str", api_version="2021-04-01", diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_operations.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_operations.py index c578d36eabd5..9832dd7b36e0 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_operations.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_operations.py @@ -20,7 +20,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_list(self, resource_group): + def test_operations_list(self, resource_group): response = self.client.operations.list( api_version="2021-04-01", ) diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_operations_async.py b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_operations_async.py index bf116af2ca85..1ec63ca84a37 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_operations_async.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/generated_tests/test_management_groups_api_operations_async.py @@ -21,7 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_list(self, resource_group): + async def test_operations_list(self, resource_group): response = self.client.operations.list( api_version="2021-04-01", ) diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/pyproject.toml b/sdk/managementgroups/azure-mgmt-managementgroups/pyproject.toml index 540da07d41af..57bd1097db1f 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/pyproject.toml +++ b/sdk/managementgroups/azure-mgmt-managementgroups/pyproject.toml @@ -1,6 +1,89 @@ +[build-system] +requires = [ + "setuptools>=77.0.3", + "wheel", +] +build-backend = "setuptools.build_meta" + +[project] +name = "azure-mgmt-managementgroups" +authors = [ + { name = "Microsoft Corporation", email = "azpysdkhelp@microsoft.com" }, +] +description = "Microsoft Azure Managementgroups Management Client Library for Python" +license = "MIT" +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", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.9" +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.managementgroups._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 mypy = false pyright = false type_check_samples = false verifytypes = false + +[packaging] +package_name = "azure-mgmt-managementgroups" +package_pprint_name = "Management Groups" +package_doc_id = "" +is_stable = true +title = "ManagementGroupsAPI" +package_nspkg = "azure-mgmt-nspkg" +is_arm = true +no_sub = true +need_msrestazure = false +need_azuremgmtcore = true +sample_link = "" +exclude_folders = "" diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/sdk_packaging.toml b/sdk/managementgroups/azure-mgmt-managementgroups/sdk_packaging.toml deleted file mode 100644 index 18d7edcf0d36..000000000000 --- a/sdk/managementgroups/azure-mgmt-managementgroups/sdk_packaging.toml +++ /dev/null @@ -1,6 +0,0 @@ -[packaging] -package_name = "azure-mgmt-managementgroups" -package_pprint_name = "Management Groups" -package_doc_id = "" -is_stable = true -title = "ManagementGroupsAPI" diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/setup.py b/sdk/managementgroups/azure-mgmt-managementgroups/setup.py deleted file mode 100644 index a29615a0d4e6..000000000000 --- a/sdk/managementgroups/azure-mgmt-managementgroups/setup.py +++ /dev/null @@ -1,85 +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-managementgroups" -PACKAGE_PPRINT_NAME = "Management Groups" - -# 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 :: 4 - Beta", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "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.3.2", - ], - python_requires=">=3.8", -)