diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/_meta.json b/sdk/managementgroups/azure-mgmt-managementgroups/_meta.json index dd31d1077c15..bc42d1237e51 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/_meta.json +++ b/sdk/managementgroups/azure-mgmt-managementgroups/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.2", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.0", - "@autorest/modelerfour@4.19.1" + "@autorest/python@5.16.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "e5bdbb00cf31e34dfaffe74432b80a110f86e06a", + "commit": "3d829159d05d8740cd09988ed1e11420fe54af5b", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/managementgroups/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.0 --use=@autorest/modelerfour@4.19.1 --version=3.4.2", + "autorest_command": "autorest specification/managementgroups/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/managementgroups/resource-manager/readme.md" } \ No newline at end of file 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 4341ee714d79..f423b5f689f4 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/__init__.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/__init__.py @@ -10,10 +10,14 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ManagementGroupsAPI'] try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['ManagementGroupsAPI'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_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 87587d19dd3f..8507305c65b8 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_configuration.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class ManagementGroupsAPIConfiguration(Configuration): +class ManagementGroupsAPIConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for ManagementGroupsAPI. Note that all parameters used to create this instance are saved as instance @@ -29,20 +27,24 @@ class ManagementGroupsAPIConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential + :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, # type: "TokenCredential" - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + **kwargs: Any + ) -> None: + super(ManagementGroupsAPIConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-04-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(ManagementGroupsAPIConfiguration, self).__init__(**kwargs) self.credential = credential - self.api_version = "2021-04-01" + 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)) self._configure(**kwargs) @@ -62,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) 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 5130850fc138..b8f2c28865c7 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 @@ -6,37 +6,32 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import ManagementGroupsAPIConfiguration -from .operations import ManagementGroupsOperations -from .operations import ManagementGroupSubscriptionsOperations -from .operations import HierarchySettingsOperations -from .operations import Operations -from .operations import ManagementGroupsAPIOperationsMixin -from .operations import EntitiesOperations from . import models +from ._configuration import ManagementGroupsAPIConfiguration +from .operations import EntitiesOperations, HierarchySettingsOperations, ManagementGroupSubscriptionsOperations, ManagementGroupsAPIOperationsMixin, ManagementGroupsOperations, Operations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential 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. + """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. :ivar management_groups: ManagementGroupsOperations operations :vartype management_groups: azure.mgmt.managementgroups.operations.ManagementGroupsOperations :ivar management_group_subscriptions: ManagementGroupSubscriptionsOperations operations - :vartype management_group_subscriptions: azure.mgmt.managementgroups.operations.ManagementGroupSubscriptionsOperations + :vartype management_group_subscriptions: + azure.mgmt.managementgroups.operations.ManagementGroupSubscriptionsOperations :ivar hierarchy_settings: HierarchySettingsOperations operations :vartype hierarchy_settings: azure.mgmt.managementgroups.operations.HierarchySettingsOperations :ivar operations: Operations operations @@ -45,52 +40,70 @@ class ManagementGroupsAPI(ManagementGroupsAPIOperationsMixin): :vartype entities: azure.mgmt.managementgroups.operations.EntitiesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :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 + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ManagementGroupsAPIConfiguration(credential, **kwargs) + credential: "TokenCredential", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ManagementGroupsAPIConfiguration(credential=credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.management_groups = ManagementGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.management_group_subscriptions = ManagementGroupSubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.hierarchy_settings = HierarchySettingsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.entities = EntitiesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_metadata.json b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_metadata.json deleted file mode 100644 index 33210bd110be..000000000000 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_metadata.json +++ /dev/null @@ -1,137 +0,0 @@ -{ - "chosen_version": "2021-04-01", - "total_api_version_list": ["2021-04-01"], - "client": { - "name": "ManagementGroupsAPI", - "filename": "_management_groups_api", - "description": "The Azure Management Groups API enables consolidation of multiple \nsubscriptions/resources into an organizational hierarchy and centrally \nmanage access control, policies, alerting and reporting for those resources.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagementGroupsAPIConfiguration\"], \"._operations_mixin\": [\"ManagementGroupsAPIOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ManagementGroupsAPIConfiguration\"], \"._operations_mixin\": [\"ManagementGroupsAPIOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=None, # type: Optional[str]", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "management_groups": "ManagementGroupsOperations", - "management_group_subscriptions": "ManagementGroupSubscriptionsOperations", - "hierarchy_settings": "HierarchySettingsOperations", - "operations": "Operations", - "entities": "EntitiesOperations" - }, - "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\"]}}}", - "operations": { - "check_name_availability" : { - "sync": { - "signature": "def check_name_availability(\n self,\n check_name_availability_request, # type: \"_models.CheckNameAvailabilityRequest\"\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Checks if the specified management group name is valid and unique.\n\n:param check_name_availability_request: Management group name availability check parameters.\n:type check_name_availability_request: ~azure.mgmt.managementgroups.models.CheckNameAvailabilityRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckNameAvailabilityResult, or the result of cls(response)\n:rtype: ~azure.mgmt.managementgroups.models.CheckNameAvailabilityResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def check_name_availability(\n self,\n check_name_availability_request: \"_models.CheckNameAvailabilityRequest\",\n **kwargs: Any\n) -\u003e \"_models.CheckNameAvailabilityResult\":\n", - "doc": "\"\"\"Checks if the specified management group name is valid and unique.\n\n:param check_name_availability_request: Management group name availability check parameters.\n:type check_name_availability_request: ~azure.mgmt.managementgroups.models.CheckNameAvailabilityRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckNameAvailabilityResult, or the result of cls(response)\n:rtype: ~azure.mgmt.managementgroups.models.CheckNameAvailabilityResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "check_name_availability_request" - }, - "start_tenant_backfill" : { - "sync": { - "signature": "def start_tenant_backfill(\n self,\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Starts backfilling subscriptions for the Tenant.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: TenantBackfillStatusResult, or the result of cls(response)\n:rtype: ~azure.mgmt.managementgroups.models.TenantBackfillStatusResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def start_tenant_backfill(\n self,\n **kwargs: Any\n) -\u003e \"_models.TenantBackfillStatusResult\":\n", - "doc": "\"\"\"Starts backfilling subscriptions for the Tenant.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: TenantBackfillStatusResult, or the result of cls(response)\n:rtype: ~azure.mgmt.managementgroups.models.TenantBackfillStatusResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "" - }, - "tenant_backfill_status" : { - "sync": { - "signature": "def tenant_backfill_status(\n self,\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Gets tenant backfill status.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: TenantBackfillStatusResult, or the result of cls(response)\n:rtype: ~azure.mgmt.managementgroups.models.TenantBackfillStatusResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def tenant_backfill_status(\n self,\n **kwargs: Any\n) -\u003e \"_models.TenantBackfillStatusResult\":\n", - "doc": "\"\"\"Gets tenant backfill status.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: TenantBackfillStatusResult, or the result of cls(response)\n:rtype: ~azure.mgmt.managementgroups.models.TenantBackfillStatusResult\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "" - } - } - } -} \ No newline at end of file diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_patch.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_vendor.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_vendor.py new file mode 100644 index 000000000000..5ec395288f13 --- /dev/null +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_vendor.py @@ -0,0 +1,45 @@ +# -------------------------------------------------------------------------- +# 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 azure.core.pipeline.transport import HttpRequest + +from ._configuration import ManagementGroupsAPIConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import PipelineClient + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "PipelineClient" + _config: ManagementGroupsAPIConfiguration + _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 c47f66669f1b..e5754a47ce68 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.0.0" +VERSION = "1.0.0b1" 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 02de8eb547be..25d6fe2261f1 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 @@ -7,4 +7,14 @@ # -------------------------------------------------------------------------- from ._management_groups_api import ManagementGroupsAPI + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['ManagementGroupsAPI'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_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 17c536d1d994..bd4f1d1bb473 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 @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class ManagementGroupsAPIConfiguration(Configuration): +class ManagementGroupsAPIConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for ManagementGroupsAPI. Note that all parameters used to create this instance are saved as instance @@ -27,6 +27,9 @@ class ManagementGroupsAPIConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :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__( @@ -34,12 +37,14 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(ManagementGroupsAPIConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-04-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(ManagementGroupsAPIConfiguration, self).__init__(**kwargs) self.credential = credential - self.api_version = "2021-04-01" + 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)) self._configure(**kwargs) @@ -58,4 +63,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) 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 2bc19337ac90..78767dd1e0b3 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 @@ -6,87 +6,106 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import ManagementGroupsAPIConfiguration -from .operations import ManagementGroupsOperations -from .operations import ManagementGroupSubscriptionsOperations -from .operations import HierarchySettingsOperations -from .operations import Operations -from .operations import ManagementGroupsAPIOperationsMixin -from .operations import EntitiesOperations from .. import models +from ._configuration import ManagementGroupsAPIConfiguration +from .operations import EntitiesOperations, HierarchySettingsOperations, ManagementGroupSubscriptionsOperations, ManagementGroupsAPIOperationsMixin, ManagementGroupsOperations, Operations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential 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. + """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. :ivar management_groups: ManagementGroupsOperations operations - :vartype management_groups: azure.mgmt.managementgroups.aio.operations.ManagementGroupsOperations + :vartype management_groups: + azure.mgmt.managementgroups.aio.operations.ManagementGroupsOperations :ivar management_group_subscriptions: ManagementGroupSubscriptionsOperations operations - :vartype management_group_subscriptions: azure.mgmt.managementgroups.aio.operations.ManagementGroupSubscriptionsOperations + :vartype management_group_subscriptions: + azure.mgmt.managementgroups.aio.operations.ManagementGroupSubscriptionsOperations :ivar hierarchy_settings: HierarchySettingsOperations operations - :vartype hierarchy_settings: azure.mgmt.managementgroups.aio.operations.HierarchySettingsOperations + :vartype hierarchy_settings: + azure.mgmt.managementgroups.aio.operations.HierarchySettingsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.managementgroups.aio.operations.Operations :ivar entities: EntitiesOperations operations :vartype entities: azure.mgmt.managementgroups.aio.operations.EntitiesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :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 + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ManagementGroupsAPIConfiguration(credential, **kwargs) + self._config = ManagementGroupsAPIConfiguration(credential=credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - + self._serialize.client_side_validation = False self.management_groups = ManagementGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.management_group_subscriptions = ManagementGroupSubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.hierarchy_settings = HierarchySettingsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.entities = EntitiesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/_patch.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ 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 new file mode 100644 index 000000000000..77ba52132b6c --- /dev/null +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# 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 azure.core.pipeline.transport import HttpRequest + +from ._configuration import ManagementGroupsAPIConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import AsyncPipelineClient + + +class MixinABC(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 d3c6bc42bbef..2daa6ac3837c 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 @@ -13,6 +13,9 @@ from ._management_groups_api_operations import ManagementGroupsAPIOperationsMixin from ._entities_operations import EntitiesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ManagementGroupsOperations', 'ManagementGroupSubscriptionsOperations', @@ -21,3 +24,5 @@ 'ManagementGroupsAPIOperationsMixin', 'EntitiesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 007f59816832..c93a327033ca 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,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,72 +6,76 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._entities_operations import build_list_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class EntitiesOperations: - """EntitiesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.managementgroups.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.managementgroups.aio.ManagementGroupsAPI`'s + :attr:`entities` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, skiptoken: Optional[str] = None, skip: Optional[int] = None, top: Optional[int] = None, select: Optional[str] = None, - search: Optional[Union[str, "_models.Enum2"]] = None, + search: Optional[Union[str, "_models.EntitySearchType"]] = None, filter: Optional[str] = None, - view: Optional[Union[str, "_models.Enum3"]] = None, + view: Optional[Union[str, "_models.EntityViewParameterType"]] = None, group_name: Optional[str] = None, cache_control: Optional[str] = "no-cache", **kwargs: Any - ) -> AsyncIterable["_models.EntityListResult"]: + ) -> AsyncIterable[_models.EntityListResult]: """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 partial result. If a previous response contains a nextLink element, the value of the nextLink element will - include a token parameter that specifies a starting point to use for subsequent calls. + include a token parameter that specifies a starting point to use for subsequent calls. Default + value is None. :type skiptoken: str :param skip: Number of entities to skip over when retrieving results. Passing this in will - override $skipToken. + override $skipToken. Default value is None. :type skip: int :param top: Number of elements to return when retrieving results. Passing this in will override - $skipToken. + $skipToken. Default value is None. :type top: int :param select: This parameter specifies the fields to include in the response. Can include any combination of Name,DisplayName,Type,ParentDisplayNameChain,ParentChain, e.g. '$select=Name,DisplayName,Type,ParentDisplayNameChain,ParentNameChain'. When specified the - $select parameter can override select in $skipToken. + $select parameter can override select in $skipToken. Default value is None. :type select: str :param search: The $search parameter is used in conjunction with the $filter parameter to return three different outputs depending on the parameter passed in. @@ -85,75 +90,85 @@ def list( one of the descendants of the group. With $search=ChildrenOnly the API will return only the first level of children of the group entity info specified in $filter. The user must have direct access to the children entities or - one of it's descendants for it to show up in the results. - :type search: str or ~azure.mgmt.managementgroups.models.Enum2 + one of it's descendants for it to show up in the results. Default value is None. + :type search: str or ~azure.mgmt.managementgroups.models.EntitySearchType :param filter: The filter parameter allows you to filter on the the name or display name fields. You can check for equality on the name field (e.g. name eq '{entityName}') and you can check for substrings on either the name or display name fields(e.g. contains(name, '{substringToSearch}'), contains(displayName, '{substringToSearch')). Note that the - '{entityName}' and '{substringToSearch}' fields are checked case insensitively. + '{entityName}' and '{substringToSearch}' fields are checked case insensitively. Default value + is None. :type filter: str :param view: The view parameter allows clients to filter the type of data that is returned by - the getEntities call. - :type view: str or ~azure.mgmt.managementgroups.models.Enum3 + the getEntities call. Default value is None. + :type view: str or ~azure.mgmt.managementgroups.models.EntityViewParameterType :param group_name: A filter which allows the get entities call to focus on a particular group - (i.e. "$filter=name eq 'groupName'"). + (i.e. "$filter=name eq 'groupName'"). Default value is None. :type group_name: str :param cache_control: Indicates whether the request should utilize any caches. Populate the - header with 'no-cache' value to bypass existing caches. + header with 'no-cache' value to bypass existing caches. Default value is "no-cache". :type cache_control: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EntityListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managementgroups.models.EntityListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managementgroups.models.EntityListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EntityListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EntityListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if cache_control is not None: - header_parameters['Cache-Control'] = self._serialize.header("cache_control", cache_control, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if select is not None: - query_parameters['$select'] = self._serialize.query("select", select, 'str') - if search is not None: - query_parameters['$search'] = self._serialize.query("search", search, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if view is not None: - query_parameters['$view'] = self._serialize.query("view", view, 'str') - if group_name is not None: - query_parameters['groupName'] = self._serialize.query("group_name", group_name, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + skiptoken=skiptoken, + skip=skip, + top=top, + select=select, + search=search, + filter=filter, + view=view, + group_name=group_name, + cache_control=cache_control, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + skiptoken=skiptoken, + skip=skip, + top=top, + select=select, + search=search, + filter=filter, + view=view, + group_name=group_name, + cache_control=cache_control, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EntityListResult', pipeline_response) + deserialized = self._deserialize("EntityListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -162,17 +177,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Management/getEntities'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Management/getEntities"} # type: ignore 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 a40502909456..7cdf9b7c3a1d 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,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,46 +6,49 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._hierarchy_settings_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class HierarchySettingsOperations: - """HierarchySettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.managementgroups.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.managementgroups.aio.ManagementGroupsAPI`'s + :attr:`hierarchy_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def list( self, group_id: str, **kwargs: Any - ) -> "_models.HierarchySettingsList": + ) -> _models.HierarchySettingsList: """Gets all the hierarchy settings defined at the Management Group level. Settings can only be set on the root Management Group of the hierarchy. @@ -55,36 +59,38 @@ async def list( :rtype: ~azure.mgmt.managementgroups.models.HierarchySettingsList :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HierarchySettingsList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.HierarchySettingsList] + + + request = build_list_request( + group_id=group_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -93,13 +99,16 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/settings'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/settings"} # type: ignore + + + @distributed_trace_async async def get( self, group_id: str, **kwargs: Any - ) -> "_models.HierarchySettings": + ) -> _models.HierarchySettings: """Gets the hierarchy settings defined at the Management Group level. Settings can only be set on the root Management Group of the hierarchy. @@ -110,36 +119,38 @@ async def get( :rtype: ~azure.mgmt.managementgroups.models.HierarchySettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HierarchySettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.HierarchySettings] + + + request = build_get_request( + group_id=group_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -148,60 +159,65 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/settings/default'} # type: ignore + get.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/settings/default"} # type: ignore + + + @distributed_trace_async async def create_or_update( self, group_id: str, - create_tenant_settings_request: "_models.CreateOrUpdateSettingsRequest", + create_tenant_settings_request: _models.CreateOrUpdateSettingsRequest, **kwargs: Any - ) -> "_models.HierarchySettings": + ) -> _models.HierarchySettings: """Creates or updates the hierarchy settings defined at the Management Group level. :param group_id: Management Group ID. :type group_id: str :param create_tenant_settings_request: Tenant level settings request parameter. - :type create_tenant_settings_request: ~azure.mgmt.managementgroups.models.CreateOrUpdateSettingsRequest + :type create_tenant_settings_request: + ~azure.mgmt.managementgroups.models.CreateOrUpdateSettingsRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: HierarchySettings, or the result of cls(response) :rtype: ~azure.mgmt.managementgroups.models.HierarchySettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HierarchySettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_tenant_settings_request, 'CreateOrUpdateSettingsRequest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.HierarchySettings] + + _json = self._serialize.body(create_tenant_settings_request, 'CreateOrUpdateSettingsRequest') + + request = build_create_or_update_request( + group_id=group_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -210,60 +226,65 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/settings/default'} # type: ignore + create_or_update.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/settings/default"} # type: ignore + + + @distributed_trace_async async def update( self, group_id: str, - create_tenant_settings_request: "_models.CreateOrUpdateSettingsRequest", + create_tenant_settings_request: _models.CreateOrUpdateSettingsRequest, **kwargs: Any - ) -> "_models.HierarchySettings": + ) -> _models.HierarchySettings: """Updates the hierarchy settings defined at the Management Group level. :param group_id: Management Group ID. :type group_id: str :param create_tenant_settings_request: Tenant level settings request parameter. - :type create_tenant_settings_request: ~azure.mgmt.managementgroups.models.CreateOrUpdateSettingsRequest + :type create_tenant_settings_request: + ~azure.mgmt.managementgroups.models.CreateOrUpdateSettingsRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: HierarchySettings, or the result of cls(response) :rtype: ~azure.mgmt.managementgroups.models.HierarchySettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HierarchySettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_tenant_settings_request, 'CreateOrUpdateSettingsRequest') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.HierarchySettings] + + _json = self._serialize.body(create_tenant_settings_request, 'CreateOrUpdateSettingsRequest') + + request = build_update_request( + group_id=group_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -272,9 +293,12 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/settings/default'} # type: ignore - async def delete( + update.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/settings/default"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, group_id: str, **kwargs: Any @@ -288,39 +312,42 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + group_id=group_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/settings/default'} # type: ignore + delete.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/settings/default"} # type: ignore + 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 2d07b449685e..9ab1e8fd831b 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,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,49 +6,53 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +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 .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ManagementGroupSubscriptionsOperations: - """ManagementGroupSubscriptionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.managementgroups.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.managementgroups.aio.ManagementGroupsAPI`'s + :attr:`management_group_subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def create( self, group_id: str, subscription_id: str, cache_control: Optional[str] = "no-cache", **kwargs: Any - ) -> "_models.SubscriptionUnderManagementGroup": + ) -> _models.SubscriptionUnderManagementGroup: """Associates existing subscription with the management group. :param group_id: Management Group ID. @@ -55,46 +60,47 @@ async def create( :param subscription_id: Subscription ID. :type subscription_id: str :param cache_control: Indicates whether the request should utilize any caches. Populate the - header with 'no-cache' value to bypass existing caches. + header with 'no-cache' value to bypass existing caches. Default value is "no-cache". :type cache_control: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionUnderManagementGroup, or the result of cls(response) :rtype: ~azure.mgmt.managementgroups.models.SubscriptionUnderManagementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionUnderManagementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if cache_control is not None: - header_parameters['Cache-Control'] = self._serialize.header("cache_control", cache_control, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionUnderManagementGroup] + + + request = build_create_request( + group_id=group_id, + subscription_id=subscription_id, + api_version=api_version, + cache_control=cache_control, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -103,9 +109,12 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}'} # type: ignore - async def delete( + create.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, group_id: str, subscription_id: str, @@ -119,60 +128,63 @@ async def delete( :param subscription_id: Subscription ID. :type subscription_id: str :param cache_control: Indicates whether the request should utilize any caches. Populate the - header with 'no-cache' value to bypass existing caches. + header with 'no-cache' value to bypass existing caches. Default value is "no-cache". :type cache_control: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if cache_control is not None: - header_parameters['Cache-Control'] = self._serialize.header("cache_control", cache_control, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + group_id=group_id, + subscription_id=subscription_id, + api_version=api_version, + cache_control=cache_control, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}'} # type: ignore + delete.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}"} # type: ignore + + @distributed_trace_async async def get_subscription( self, group_id: str, subscription_id: str, cache_control: Optional[str] = "no-cache", **kwargs: Any - ) -> "_models.SubscriptionUnderManagementGroup": + ) -> _models.SubscriptionUnderManagementGroup: """Retrieves details about given subscription which is associated with the management group. :param group_id: Management Group ID. @@ -180,46 +192,47 @@ async def get_subscription( :param subscription_id: Subscription ID. :type subscription_id: str :param cache_control: Indicates whether the request should utilize any caches. Populate the - header with 'no-cache' value to bypass existing caches. + header with 'no-cache' value to bypass existing caches. Default value is "no-cache". :type cache_control: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionUnderManagementGroup, or the result of cls(response) :rtype: ~azure.mgmt.managementgroups.models.SubscriptionUnderManagementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionUnderManagementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if cache_control is not None: - header_parameters['Cache-Control'] = self._serialize.header("cache_control", cache_control, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionUnderManagementGroup] + + + request = build_get_subscription_request( + group_id=group_id, + subscription_id=subscription_id, + api_version=api_version, + cache_control=cache_control, + template_url=self.get_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -228,14 +241,17 @@ async def get_subscription( return cls(pipeline_response, deserialized, {}) return deserialized - get_subscription.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}'} # type: ignore + get_subscription.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}"} # type: ignore + + + @distributed_trace def get_subscriptions_under_management_group( self, group_id: str, skiptoken: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListSubscriptionUnderManagementGroup"]: + ) -> AsyncIterable[_models.ListSubscriptionUnderManagementGroup]: """Retrieves details about all subscriptions which are associated with the management group. :param group_id: Management Group ID. @@ -243,48 +259,57 @@ def get_subscriptions_under_management_group( :param skiptoken: Page continuation token is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will - include a token parameter that specifies a starting point to use for subsequent calls. + include a token parameter that specifies a starting point to use for subsequent calls. Default + value is None. :type skiptoken: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListSubscriptionUnderManagementGroup or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managementgroups.models.ListSubscriptionUnderManagementGroup] + :return: An iterator like instance of either ListSubscriptionUnderManagementGroup or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managementgroups.models.ListSubscriptionUnderManagementGroup] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListSubscriptionUnderManagementGroup"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListSubscriptionUnderManagementGroup] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_subscriptions_under_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_subscriptions_under_management_group_request( + group_id=group_id, + api_version=api_version, + skiptoken=skiptoken, + template_url=self.get_subscriptions_under_management_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_subscriptions_under_management_group_request( + group_id=group_id, + api_version=api_version, + skiptoken=skiptoken, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ListSubscriptionUnderManagementGroup', pipeline_response) + deserialized = self._deserialize("ListSubscriptionUnderManagementGroup", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -293,17 +318,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - get_subscriptions_under_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions'} # type: ignore + get_subscriptions_under_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions"} # type: ignore 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 369b62fd0642..6741601ffdf9 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,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,66 +6,76 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +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 MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ManagementGroupsAPIOperationsMixin: +class ManagementGroupsAPIOperationsMixin(MixinABC): + @distributed_trace_async async def check_name_availability( self, - check_name_availability_request: "_models.CheckNameAvailabilityRequest", + check_name_availability_request: _models.CheckNameAvailabilityRequest, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks if the specified management group name is valid and unique. :param check_name_availability_request: Management group name availability check parameters. - :type check_name_availability_request: ~azure.mgmt.managementgroups.models.CheckNameAvailabilityRequest + :type check_name_availability_request: + ~azure.mgmt.managementgroups.models.CheckNameAvailabilityRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckNameAvailabilityResult, or the result of cls(response) :rtype: ~azure.mgmt.managementgroups.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(check_name_availability_request, 'CheckNameAvailabilityRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + + _json = self._serialize.body(check_name_availability_request, 'CheckNameAvailabilityRequest') + + request = build_check_name_availability_request( + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -73,12 +84,15 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/providers/Microsoft.Management/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/providers/Microsoft.Management/checkNameAvailability"} # type: ignore + + + @distributed_trace_async async def start_tenant_backfill( self, **kwargs: Any - ) -> "_models.TenantBackfillStatusResult": + ) -> _models.TenantBackfillStatusResult: """Starts backfilling subscriptions for the Tenant. :keyword callable cls: A custom type or function that will be passed the direct response @@ -86,32 +100,37 @@ async def start_tenant_backfill( :rtype: ~azure.mgmt.managementgroups.models.TenantBackfillStatusResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantBackfillStatusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.start_tenant_backfill.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TenantBackfillStatusResult] + + + request = build_start_tenant_backfill_request( + api_version=api_version, + template_url=self.start_tenant_backfill.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -120,12 +139,15 @@ async def start_tenant_backfill( return cls(pipeline_response, deserialized, {}) return deserialized - start_tenant_backfill.metadata = {'url': '/providers/Microsoft.Management/startTenantBackfill'} # type: ignore + start_tenant_backfill.metadata = {'url': "/providers/Microsoft.Management/startTenantBackfill"} # type: ignore + + + @distributed_trace_async async def tenant_backfill_status( self, **kwargs: Any - ) -> "_models.TenantBackfillStatusResult": + ) -> _models.TenantBackfillStatusResult: """Gets tenant backfill status. :keyword callable cls: A custom type or function that will be passed the direct response @@ -133,32 +155,37 @@ async def tenant_backfill_status( :rtype: ~azure.mgmt.managementgroups.models.TenantBackfillStatusResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantBackfillStatusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.tenant_backfill_status.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TenantBackfillStatusResult] + + + request = build_tenant_backfill_status_request( + api_version=api_version, + template_url=self.tenant_backfill_status.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -167,4 +194,6 @@ async def tenant_backfill_status( return cls(pipeline_response, deserialized, {}) return deserialized - tenant_backfill_status.metadata = {'url': '/providers/Microsoft.Management/tenantBackfillStatus'} # type: ignore + + tenant_backfill_status.metadata = {'url': "/providers/Microsoft.Management/tenantBackfillStatus"} # type: ignore + 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 e7742eb35893..ae6b6d9ff3d5 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,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,98 +6,113 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._management_groups_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_descendants_request, build_get_request, build_list_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ManagementGroupsOperations: - """ManagementGroupsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.managementgroups.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.managementgroups.aio.ManagementGroupsAPI`'s + :attr:`management_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, cache_control: Optional[str] = "no-cache", skiptoken: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ManagementGroupListResult"]: + ) -> AsyncIterable[_models.ManagementGroupListResult]: """List management groups for the authenticated user. :param cache_control: Indicates whether the request should utilize any caches. Populate the - header with 'no-cache' value to bypass existing caches. + header with 'no-cache' value to bypass existing caches. Default value is "no-cache". :type cache_control: str :param skiptoken: Page continuation token is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will - include a token parameter that specifies a starting point to use for subsequent calls. + include a token parameter that specifies a starting point to use for subsequent calls. Default + value is None. :type skiptoken: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementGroupListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managementgroups.models.ManagementGroupListResult] + :return: An iterator like instance of either ManagementGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managementgroups.models.ManagementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroupListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if cache_control is not None: - header_parameters['Cache-Control'] = self._serialize.header("cache_control", cache_control, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + cache_control=cache_control, + skiptoken=skiptoken, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + cache_control=cache_control, + skiptoken=skiptoken, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ManagementGroupListResult', pipeline_response) + deserialized = self._deserialize("ManagementGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,91 +121,96 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Management/managementGroups'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Management/managementGroups"} # type: ignore + @distributed_trace_async async def get( self, group_id: str, - expand: Optional[Union[str, "_models.Enum0"]] = None, + expand: Optional[Union[str, "_models.ManagementGroupExpandType"]] = None, recurse: Optional[bool] = None, filter: Optional[str] = None, cache_control: Optional[str] = "no-cache", **kwargs: Any - ) -> "_models.ManagementGroup": + ) -> _models.ManagementGroup: """Get the details of the management group. :param group_id: Management Group ID. :type group_id: str :param expand: The $expand=children query string parameter allows clients to request inclusion of children in the response payload. $expand=path includes the path from the root group to the - current group. $expand=ancestors includes the ancestor Ids of the current group. - :type expand: str or ~azure.mgmt.managementgroups.models.Enum0 + current group. $expand=ancestors includes the ancestor Ids of the current group. Default value + is None. + :type expand: str or ~azure.mgmt.managementgroups.models.ManagementGroupExpandType :param recurse: The $recurse=true query string parameter allows clients to request inclusion of entire hierarchy in the response payload. Note that $expand=children must be passed up if - $recurse is set to true. + $recurse is set to true. Default value is None. :type recurse: bool :param filter: A filter which allows the exclusion of subscriptions from results (i.e. - '$filter=children.childType ne Subscription'). + '$filter=children.childType ne Subscription'). Default value is None. :type filter: str :param cache_control: Indicates whether the request should utilize any caches. Populate the - header with 'no-cache' value to bypass existing caches. + header with 'no-cache' value to bypass existing caches. Default value is "no-cache". :type cache_control: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementGroup, or the result of cls(response) :rtype: ~azure.mgmt.managementgroups.models.ManagementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if recurse is not None: - query_parameters['$recurse'] = self._serialize.query("recurse", recurse, 'bool') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if cache_control is not None: - header_parameters['Cache-Control'] = self._serialize.header("cache_control", cache_control, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroup] + + + request = build_get_request( + group_id=group_id, + api_version=api_version, + expand=expand, + recurse=recurse, + filter=filter, + cache_control=cache_control, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -198,53 +219,54 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}'} # type: ignore + + get.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}"} # type: ignore + async def _create_or_update_initial( self, group_id: str, - create_management_group_request: "_models.CreateManagementGroupRequest", + create_management_group_request: _models.CreateManagementGroupRequest, cache_control: Optional[str] = "no-cache", **kwargs: Any - ) -> Union["_models.ManagementGroup", "_models.AzureAsyncOperationResults"]: - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.ManagementGroup", "_models.AzureAsyncOperationResults"]] + ) -> Union[_models.ManagementGroup, _models.AzureAsyncOperationResults]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if cache_control is not None: - header_parameters['Cache-Control'] = self._serialize.header("cache_control", cache_control, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_management_group_request, 'CreateManagementGroupRequest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Union[_models.ManagementGroup, _models.AzureAsyncOperationResults]] + + _json = self._serialize.body(create_management_group_request, 'CreateManagementGroupRequest') + + request = build_create_or_update_request_initial( + group_id=group_id, + api_version=api_version, + content_type=content_type, + json=_json, + cache_control=cache_control, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: @@ -253,21 +275,25 @@ async def _create_or_update_initial( if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + deserialized = self._deserialize('AzureAsyncOperationResults', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}"} # type: ignore + + + @distributed_trace_async async def begin_create_or_update( self, group_id: str, - create_management_group_request: "_models.CreateManagementGroupRequest", + create_management_group_request: _models.CreateManagementGroupRequest, cache_control: Optional[str] = "no-cache", **kwargs: Any - ) -> AsyncLROPoller[Union["_models.ManagementGroup", "_models.AzureAsyncOperationResults"]]: + ) -> AsyncLROPoller[Union[_models.ManagementGroup, _models.AzureAsyncOperationResults]]: """Create or update a management group. If a management group is already created and a subsequent create request is issued with different properties, the management group properties will be updated. @@ -275,52 +301,66 @@ async def begin_create_or_update( :param group_id: Management Group ID. :type group_id: str :param create_management_group_request: Management group creation parameters. - :type create_management_group_request: ~azure.mgmt.managementgroups.models.CreateManagementGroupRequest + :type create_management_group_request: + ~azure.mgmt.managementgroups.models.CreateManagementGroupRequest :param cache_control: Indicates whether the request should utilize any caches. Populate the - header with 'no-cache' value to bypass existing caches. + header with 'no-cache' value to bypass existing caches. Default value is "no-cache". :type cache_control: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ManagementGroup or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managementgroups.models.ManagementGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ManagementGroup or + AzureAsyncOperationResults or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managementgroups.models.ManagementGroup + or ~azure.mgmt.managementgroups.models.AzureAsyncOperationResults] + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Union[_models.ManagementGroup, _models.AzureAsyncOperationResults]] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.ManagementGroup", "_models.AzureAsyncOperationResults"]] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore group_id=group_id, create_management_group_request=create_management_group_request, cache_control=cache_control, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('ManagementGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -329,17 +369,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}"} # type: ignore + @distributed_trace_async async def update( self, group_id: str, - patch_group_request: "_models.PatchManagementGroupRequest", + patch_group_request: _models.PatchManagementGroupRequest, cache_control: Optional[str] = "no-cache", **kwargs: Any - ) -> "_models.ManagementGroup": + ) -> _models.ManagementGroup: """Update a management group. :param group_id: Management Group ID. @@ -347,50 +388,50 @@ async def update( :param patch_group_request: Management group patch parameters. :type patch_group_request: ~azure.mgmt.managementgroups.models.PatchManagementGroupRequest :param cache_control: Indicates whether the request should utilize any caches. Populate the - header with 'no-cache' value to bypass existing caches. + header with 'no-cache' value to bypass existing caches. Default value is "no-cache". :type cache_control: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementGroup, or the result of cls(response) :rtype: ~azure.mgmt.managementgroups.models.ManagementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if cache_control is not None: - header_parameters['Cache-Control'] = self._serialize.header("cache_control", cache_control, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(patch_group_request, 'PatchManagementGroupRequest') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroup] + + _json = self._serialize.body(patch_group_request, 'PatchManagementGroupRequest') + + request = build_update_request( + group_id=group_id, + api_version=api_version, + content_type=content_type, + json=_json, + cache_control=cache_control, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -399,120 +440,138 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}'} # type: ignore + + update.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}"} # type: ignore + async def _delete_initial( self, group_id: str, cache_control: Optional[str] = "no-cache", **kwargs: Any - ) -> Optional["_models.AzureAsyncOperationResults"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AzureAsyncOperationResults"]] + ) -> Optional[_models.AzureAsyncOperationResults]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if cache_control is not None: - header_parameters['Cache-Control'] = self._serialize.header("cache_control", cache_control, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.AzureAsyncOperationResults]] + + + request = build_delete_request_initial( + group_id=group_id, + api_version=api_version, + cache_control=cache_control, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + deserialized = self._deserialize('AzureAsyncOperationResults', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _delete_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}'} # type: ignore + _delete_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}"} # type: ignore + + + @distributed_trace_async async def begin_delete( self, group_id: str, cache_control: Optional[str] = "no-cache", **kwargs: Any - ) -> AsyncLROPoller["_models.AzureAsyncOperationResults"]: + ) -> AsyncLROPoller[_models.AzureAsyncOperationResults]: """Delete management group. If a management group contains child resources, the request will fail. :param group_id: Management Group ID. :type group_id: str :param cache_control: Indicates whether the request should utilize any caches. Populate the - header with 'no-cache' value to bypass existing caches. + header with 'no-cache' value to bypass existing caches. Default value is "no-cache". :type cache_control: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either AzureAsyncOperationResults or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managementgroups.models.AzureAsyncOperationResults] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AzureAsyncOperationResults or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managementgroups.models.AzureAsyncOperationResults] + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureAsyncOperationResults] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureAsyncOperationResults"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore group_id=group_id, cache_control=cache_control, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + deserialized = self._deserialize('AzureAsyncOperationResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -521,17 +580,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}"} # type: ignore + + @distributed_trace def get_descendants( self, group_id: str, skiptoken: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.DescendantListResult"]: + ) -> AsyncIterable[_models.DescendantListResult]: """List all entities that descend from a management group. :param group_id: Management Group ID. @@ -539,53 +599,62 @@ def get_descendants( :param skiptoken: Page continuation token is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will - include a token parameter that specifies a starting point to use for subsequent calls. + include a token parameter that specifies a starting point to use for subsequent calls. Default + value is None. :type skiptoken: str :param top: Number of elements to return when retrieving results. Passing this in will override - $skipToken. + $skipToken. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DescendantListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managementgroups.models.DescendantListResult] + :return: An iterator like instance of either DescendantListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managementgroups.models.DescendantListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DescendantListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DescendantListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_descendants.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_descendants_request( + group_id=group_id, + api_version=api_version, + skiptoken=skiptoken, + top=top, + template_url=self.get_descendants.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_descendants_request( + group_id=group_id, + api_version=api_version, + skiptoken=skiptoken, + top=top, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DescendantListResult', pipeline_response) + deserialized = self._deserialize("DescendantListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -594,17 +663,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - get_descendants.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/descendants'} # type: ignore + get_descendants.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/descendants"} # type: ignore 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 638162002233..ce96d15d9995 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,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,94 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.managementgroups.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.managementgroups.aio.ManagementGroupsAPI`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """Lists all of the available Management REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managementgroups.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managementgroups.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,17 +102,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Management/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Management/operations"} # type: ignore diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_patch.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ 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 9fe767e89df2..7c8486dd309d 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 @@ -6,89 +6,55 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - 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 -except (SyntaxError, ImportError): - from ._models import AzureAsyncOperationResults # type: ignore - from ._models import CheckNameAvailabilityRequest # type: ignore - from ._models import CheckNameAvailabilityResult # type: ignore - from ._models import CreateManagementGroupChildInfo # type: ignore - from ._models import CreateManagementGroupDetails # type: ignore - from ._models import CreateManagementGroupRequest # type: ignore - from ._models import CreateOrUpdateSettingsRequest # type: ignore - from ._models import CreateParentGroupInfo # type: ignore - from ._models import DescendantInfo # type: ignore - from ._models import DescendantListResult # type: ignore - from ._models import DescendantParentGroupInfo # type: ignore - from ._models import EntityHierarchyItem # type: ignore - from ._models import EntityInfo # type: ignore - from ._models import EntityListResult # type: ignore - from ._models import EntityParentGroupInfo # type: ignore - from ._models import ErrorDetails # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import HierarchySettings # type: ignore - from ._models import HierarchySettingsInfo # type: ignore - from ._models import HierarchySettingsList # type: ignore - from ._models import ListSubscriptionUnderManagementGroup # type: ignore - from ._models import ManagementGroup # type: ignore - from ._models import ManagementGroupChildInfo # type: ignore - from ._models import ManagementGroupDetails # type: ignore - from ._models import ManagementGroupInfo # type: ignore - from ._models import ManagementGroupListResult # type: ignore - from ._models import ManagementGroupPathElement # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplayProperties # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import OperationResults # type: ignore - from ._models import ParentGroupInfo # type: ignore - from ._models import PatchManagementGroupRequest # type: ignore - from ._models import SubscriptionUnderManagementGroup # type: ignore - from ._models import TenantBackfillStatusResult # type: ignore +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 ._management_groups_api_enums import ( - Enum0, - Enum2, - Enum3, + EntitySearchType, + EntityViewParameterType, ManagementGroupChildType, + ManagementGroupExpandType, Permissions, Reason, Status, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'AzureAsyncOperationResults', 'CheckNameAvailabilityRequest', @@ -125,11 +91,13 @@ 'PatchManagementGroupRequest', 'SubscriptionUnderManagementGroup', 'TenantBackfillStatusResult', - 'Enum0', - 'Enum2', - 'Enum3', + 'EntitySearchType', + 'EntityViewParameterType', 'ManagementGroupChildType', + 'ManagementGroupExpandType', 'Permissions', 'Reason', 'Status', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/models/_management_groups_api_enums.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/models/_management_groups_api_enums.py index 540f4d216664..b1d9aff9a0f7 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/models/_management_groups_api_enums.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/models/_management_groups_api_enums.py @@ -6,33 +6,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class Enum0(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - - CHILDREN = "children" - PATH = "path" - ANCESTORS = "ancestors" - -class Enum2(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EntitySearchType(str, Enum, metaclass=CaseInsensitiveEnumMeta): ALLOWED_PARENTS = "AllowedParents" ALLOWED_CHILDREN = "AllowedChildren" @@ -40,21 +18,27 @@ class Enum2(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PARENT_ONLY = "ParentOnly" CHILDREN_ONLY = "ChildrenOnly" -class Enum3(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EntityViewParameterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): FULL_HIERARCHY = "FullHierarchy" GROUPS_ONLY = "GroupsOnly" SUBSCRIPTIONS_ONLY = "SubscriptionsOnly" AUDIT = "Audit" -class ManagementGroupChildType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagementGroupChildType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of child resource. """ MICROSOFT_MANAGEMENT_MANAGEMENT_GROUPS = "Microsoft.Management/managementGroups" _SUBSCRIPTIONS = "/subscriptions" -class Permissions(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagementGroupExpandType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + + CHILDREN = "children" + PATH = "path" + ANCESTORS = "ancestors" + +class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The users specific permissions to this item. """ @@ -63,7 +47,7 @@ class Permissions(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): EDIT = "edit" DELETE = "delete" -class Reason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Required if nameAvailable == false. Invalid indicates the name provided does not match the resource provider's naming requirements (incorrect length, unsupported characters, etc.) AlreadyExists indicates that the name is already in use and is therefore unavailable. @@ -72,7 +56,7 @@ class Reason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class Status(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the Tenant Backfill """ diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/models/_models.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/models/_models.py deleted file mode 100644 index 5baa1bc0c0cf..000000000000 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/models/_models.py +++ /dev/null @@ -1,1360 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class AzureAsyncOperationResults(msrest.serialization.Model): - """The results of Azure-AsyncOperation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The fully qualified ID for the management group. For example, - /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - :vartype id: str - :ivar type: The type of the resource. For example, Microsoft.Management/managementGroups. - :vartype type: str - :ivar name: The name of the management group. For example, - 00000000-0000-0000-0000-000000000000. - :vartype name: str - :ivar status: The current status of the asynchronous operation performed . For example, - Running, Succeeded, Failed. - :vartype status: str - :param tenant_id: The AAD Tenant ID associated with the management group. For example, - 00000000-0000-0000-0000-000000000000. - :type tenant_id: str - :param display_name: The friendly name of the management group. - :type display_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureAsyncOperationResults, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.status = None - self.tenant_id = kwargs.get('tenant_id', None) - self.display_name = kwargs.get('display_name', None) - - -class CheckNameAvailabilityRequest(msrest.serialization.Model): - """Management group name availability check parameters. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param name: the name to check for availability. - :type name: str - :ivar type: fully qualified resource type which includes provider namespace. Default value: - "Microsoft.Management/managementGroups". - :vartype type: str - """ - - _validation = { - 'type': {'constant': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - type = "Microsoft.Management/managementGroups" - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailabilityRequest, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - - -class CheckNameAvailabilityResult(msrest.serialization.Model): - """Describes the result of the request to check management group name availability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name_available: Required. True indicates name is valid and available. False indicates the - name is invalid, unavailable, or both. - :vartype name_available: bool - :ivar reason: Required if nameAvailable == false. Invalid indicates the name provided does not - match the resource provider's naming requirements (incorrect length, unsupported characters, - etc.) AlreadyExists indicates that the name is already in use and is therefore unavailable. - Possible values include: "Invalid", "AlreadyExists". - :vartype reason: str or ~azure.mgmt.managementgroups.models.Reason - :ivar message: Required if nameAvailable == false. Localized. If reason == invalid, provide the - user with the reason why the given name is invalid, and provide the resource naming - requirements so that the user can select a valid name. If reason == AlreadyExists, explain that - is already in use, and direct them to select a different name. - :vartype message: str - """ - - _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailabilityResult, self).__init__(**kwargs) - self.name_available = None - self.reason = None - self.message = None - - -class CreateManagementGroupChildInfo(msrest.serialization.Model): - """The child information of a management group used during creation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The fully qualified resource type which includes provider namespace (e.g. - Microsoft.Management/managementGroups). Possible values include: - "Microsoft.Management/managementGroups", "/subscriptions". - :vartype type: str or ~azure.mgmt.managementgroups.models.ManagementGroupChildType - :ivar id: The fully qualified ID for the child resource (management group or subscription). - For example, - /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - :vartype id: str - :ivar name: The name of the child entity. - :vartype name: str - :ivar display_name: The friendly name of the child resource. - :vartype display_name: str - :ivar children: The list of children. - :vartype children: list[~azure.mgmt.managementgroups.models.CreateManagementGroupChildInfo] - """ - - _validation = { - 'type': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'display_name': {'readonly': True}, - 'children': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'children': {'key': 'children', 'type': '[CreateManagementGroupChildInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(CreateManagementGroupChildInfo, self).__init__(**kwargs) - self.type = None - self.id = None - self.name = None - self.display_name = None - self.children = None - - -class CreateManagementGroupDetails(msrest.serialization.Model): - """The details of a management group used during creation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar version: The version number of the object. - :vartype version: int - :ivar updated_time: The date and time when this object was last updated. - :vartype updated_time: ~datetime.datetime - :ivar updated_by: The identity of the principal or process that updated the object. - :vartype updated_by: str - :param parent: (Optional) The ID of the parent management group used during creation. - :type parent: ~azure.mgmt.managementgroups.models.CreateParentGroupInfo - """ - - _validation = { - 'version': {'readonly': True}, - 'updated_time': {'readonly': True}, - 'updated_by': {'readonly': True}, - } - - _attribute_map = { - 'version': {'key': 'version', 'type': 'int'}, - 'updated_time': {'key': 'updatedTime', 'type': 'iso-8601'}, - 'updated_by': {'key': 'updatedBy', 'type': 'str'}, - 'parent': {'key': 'parent', 'type': 'CreateParentGroupInfo'}, - } - - def __init__( - self, - **kwargs - ): - super(CreateManagementGroupDetails, self).__init__(**kwargs) - self.version = None - self.updated_time = None - self.updated_by = None - self.parent = kwargs.get('parent', None) - - -class CreateManagementGroupRequest(msrest.serialization.Model): - """Management group creation parameters. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The fully qualified ID for the management group. For example, - /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - :vartype id: str - :ivar type: The type of the resource. For example, Microsoft.Management/managementGroups. - :vartype type: str - :param name: The name of the management group. For example, - 00000000-0000-0000-0000-000000000000. - :type name: str - :ivar tenant_id: The AAD Tenant ID associated with the management group. For example, - 00000000-0000-0000-0000-000000000000. - :vartype tenant_id: str - :param display_name: The friendly name of the management group. If no value is passed then this - field will be set to the groupId. - :type display_name: str - :param details: The details of a management group used during creation. - :type details: ~azure.mgmt.managementgroups.models.CreateManagementGroupDetails - :ivar children: The list of children. - :vartype children: list[~azure.mgmt.managementgroups.models.CreateManagementGroupChildInfo] - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'children': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'details': {'key': 'properties.details', 'type': 'CreateManagementGroupDetails'}, - 'children': {'key': 'properties.children', 'type': '[CreateManagementGroupChildInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(CreateManagementGroupRequest, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = kwargs.get('name', None) - self.tenant_id = None - self.display_name = kwargs.get('display_name', None) - self.details = kwargs.get('details', None) - self.children = None - - -class CreateOrUpdateSettingsRequest(msrest.serialization.Model): - """Parameters for creating or updating Management Group settings. - - :param require_authorization_for_group_creation: Indicates whether RBAC access is required upon - group creation under the root Management Group. If set to true, user will require - Microsoft.Management/managementGroups/write action on the root Management Group scope in order - to create new Groups directly under the root. This will prevent new users from creating new - Management Groups, unless they are given access. - :type require_authorization_for_group_creation: bool - :param default_management_group: Settings that sets the default Management Group under which - new subscriptions get added in this tenant. For example, - /providers/Microsoft.Management/managementGroups/defaultGroup. - :type default_management_group: str - """ - - _attribute_map = { - 'require_authorization_for_group_creation': {'key': 'properties.requireAuthorizationForGroupCreation', 'type': 'bool'}, - 'default_management_group': {'key': 'properties.defaultManagementGroup', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CreateOrUpdateSettingsRequest, self).__init__(**kwargs) - self.require_authorization_for_group_creation = kwargs.get('require_authorization_for_group_creation', None) - self.default_management_group = kwargs.get('default_management_group', None) - - -class CreateParentGroupInfo(msrest.serialization.Model): - """(Optional) The ID of the parent management group used during creation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param id: The fully qualified ID for the parent management group. For example, - /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - :type id: str - :ivar name: The name of the parent management group. - :vartype name: str - :ivar display_name: The friendly name of the parent management group. - :vartype display_name: str - """ - - _validation = { - 'name': {'readonly': True}, - 'display_name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CreateParentGroupInfo, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = None - self.display_name = None - - -class DescendantInfo(msrest.serialization.Model): - """The descendant. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The fully qualified ID for the descendant. For example, - /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 or - /subscriptions/0000000-0000-0000-0000-000000000000. - :vartype id: str - :ivar type: The type of the resource. For example, Microsoft.Management/managementGroups or - /subscriptions. - :vartype type: str - :ivar name: The name of the descendant. For example, 00000000-0000-0000-0000-000000000000. - :vartype name: str - :param display_name: The friendly name of the management group. - :type display_name: str - :param parent: The ID of the parent management group. - :type parent: ~azure.mgmt.managementgroups.models.DescendantParentGroupInfo - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'parent': {'key': 'properties.parent', 'type': 'DescendantParentGroupInfo'}, - } - - def __init__( - self, - **kwargs - ): - super(DescendantInfo, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.display_name = kwargs.get('display_name', None) - self.parent = kwargs.get('parent', None) - - -class DescendantListResult(msrest.serialization.Model): - """Describes the result of the request to view descendants. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of descendants. - :type value: list[~azure.mgmt.managementgroups.models.DescendantInfo] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DescendantInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DescendantListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class DescendantParentGroupInfo(msrest.serialization.Model): - """The ID of the parent management group. - - :param id: The fully qualified ID for the parent management group. For example, - /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DescendantParentGroupInfo, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - - -class EntityHierarchyItem(msrest.serialization.Model): - """The management group details for the hierarchy view. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The fully qualified ID for the management group. For example, - /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - :vartype id: str - :ivar type: The type of the resource. For example, Microsoft.Management/managementGroups. - :vartype type: str - :ivar name: The name of the management group. For example, - 00000000-0000-0000-0000-000000000000. - :vartype name: str - :param display_name: The friendly name of the management group. - :type display_name: str - :param permissions: The users specific permissions to this item. Possible values include: - "noaccess", "view", "edit", "delete". - :type permissions: str or ~azure.mgmt.managementgroups.models.Permissions - :param children: The list of children. - :type children: list[~azure.mgmt.managementgroups.models.EntityHierarchyItem] - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'permissions': {'key': 'properties.permissions', 'type': 'str'}, - 'children': {'key': 'properties.children', 'type': '[EntityHierarchyItem]'}, - } - - def __init__( - self, - **kwargs - ): - super(EntityHierarchyItem, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.display_name = kwargs.get('display_name', None) - self.permissions = kwargs.get('permissions', None) - self.children = kwargs.get('children', None) - - -class EntityInfo(msrest.serialization.Model): - """The entity. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The fully qualified ID for the entity. For example, - /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - :vartype id: str - :ivar type: The type of the resource. For example, Microsoft.Management/managementGroups. - :vartype type: str - :ivar name: The name of the entity. For example, 00000000-0000-0000-0000-000000000000. - :vartype name: str - :param tenant_id: The AAD Tenant ID associated with the entity. For example, - 00000000-0000-0000-0000-000000000000. - :type tenant_id: str - :param display_name: The friendly name of the management group. - :type display_name: str - :param parent: (Optional) The ID of the parent management group. - :type parent: ~azure.mgmt.managementgroups.models.EntityParentGroupInfo - :param permissions: The users specific permissions to this item. Possible values include: - "noaccess", "view", "edit", "delete". - :type permissions: str or ~azure.mgmt.managementgroups.models.Permissions - :param inherited_permissions: The users specific permissions to this item. Possible values - include: "noaccess", "view", "edit", "delete". - :type inherited_permissions: str or ~azure.mgmt.managementgroups.models.Permissions - :param number_of_descendants: Number of Descendants. - :type number_of_descendants: int - :param number_of_children: Number of children is the number of Groups and Subscriptions that - are exactly one level underneath the current Group. - :type number_of_children: int - :param number_of_child_groups: Number of children is the number of Groups that are exactly one - level underneath the current Group. - :type number_of_child_groups: int - :param parent_display_name_chain: The parent display name chain from the root group to the - immediate parent. - :type parent_display_name_chain: list[str] - :param parent_name_chain: The parent name chain from the root group to the immediate parent. - :type parent_name_chain: list[str] - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'parent': {'key': 'properties.parent', 'type': 'EntityParentGroupInfo'}, - 'permissions': {'key': 'properties.permissions', 'type': 'str'}, - 'inherited_permissions': {'key': 'properties.inheritedPermissions', 'type': 'str'}, - 'number_of_descendants': {'key': 'properties.numberOfDescendants', 'type': 'int'}, - 'number_of_children': {'key': 'properties.numberOfChildren', 'type': 'int'}, - 'number_of_child_groups': {'key': 'properties.numberOfChildGroups', 'type': 'int'}, - 'parent_display_name_chain': {'key': 'properties.parentDisplayNameChain', 'type': '[str]'}, - 'parent_name_chain': {'key': 'properties.parentNameChain', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(EntityInfo, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.tenant_id = kwargs.get('tenant_id', None) - self.display_name = kwargs.get('display_name', None) - self.parent = kwargs.get('parent', None) - self.permissions = kwargs.get('permissions', None) - self.inherited_permissions = kwargs.get('inherited_permissions', None) - self.number_of_descendants = kwargs.get('number_of_descendants', None) - self.number_of_children = kwargs.get('number_of_children', None) - self.number_of_child_groups = kwargs.get('number_of_child_groups', None) - self.parent_display_name_chain = kwargs.get('parent_display_name_chain', None) - self.parent_name_chain = kwargs.get('parent_name_chain', None) - - -class EntityListResult(msrest.serialization.Model): - """Describes the result of the request to view entities. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of entities. - :type value: list[~azure.mgmt.managementgroups.models.EntityInfo] - :ivar count: Total count of records that match the filter. - :vartype count: int - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - 'count': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[EntityInfo]'}, - 'count': {'key': 'count', 'type': 'int'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EntityListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.count = None - self.next_link = None - - -class EntityParentGroupInfo(msrest.serialization.Model): - """(Optional) The ID of the parent management group. - - :param id: The fully qualified ID for the parent management group. For example, - /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EntityParentGroupInfo, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - - -class ErrorDetails(msrest.serialization.Model): - """The details of the error. - - :param code: One of a server-defined set of error codes. - :type code: str - :param message: A human-readable representation of the error. - :type message: str - :param details: A human-readable representation of the error's details. - :type details: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetails, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.details = kwargs.get('details', None) - - -class ErrorResponse(msrest.serialization.Model): - """The error object. - - :param error: The details of the error. - :type error: ~azure.mgmt.managementgroups.models.ErrorDetails - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class HierarchySettings(msrest.serialization.Model): - """Settings defined at the Management Group scope. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The fully qualified ID for the settings object. For example, - /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/settings/default. - :vartype id: str - :ivar type: The type of the resource. For example, - Microsoft.Management/managementGroups/settings. - :vartype type: str - :ivar name: The name of the object. In this case, default. - :vartype name: str - :param tenant_id: The AAD Tenant ID associated with the hierarchy settings. For example, - 00000000-0000-0000-0000-000000000000. - :type tenant_id: str - :param require_authorization_for_group_creation: Indicates whether RBAC access is required upon - group creation under the root Management Group. If set to true, user will require - Microsoft.Management/managementGroups/write action on the root Management Group scope in order - to create new Groups directly under the root. This will prevent new users from creating new - Management Groups, unless they are given access. - :type require_authorization_for_group_creation: bool - :param default_management_group: Settings that sets the default Management Group under which - new subscriptions get added in this tenant. For example, - /providers/Microsoft.Management/managementGroups/defaultGroup. - :type default_management_group: str - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'require_authorization_for_group_creation': {'key': 'properties.requireAuthorizationForGroupCreation', 'type': 'bool'}, - 'default_management_group': {'key': 'properties.defaultManagementGroup', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(HierarchySettings, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.tenant_id = kwargs.get('tenant_id', None) - self.require_authorization_for_group_creation = kwargs.get('require_authorization_for_group_creation', None) - self.default_management_group = kwargs.get('default_management_group', None) - - -class HierarchySettingsInfo(msrest.serialization.Model): - """The hierarchy settings resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The fully qualified ID for the settings object. For example, - /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/settings/default. - :vartype id: str - :ivar type: The type of the resource. For example, - Microsoft.Management/managementGroups/settings. - :vartype type: str - :ivar name: The name of the object. In this case, default. - :vartype name: str - :param tenant_id: The AAD Tenant ID associated with the hierarchy settings. For example, - 00000000-0000-0000-0000-000000000000. - :type tenant_id: str - :param require_authorization_for_group_creation: Indicates whether RBAC access is required upon - group creation under the root Management Group. If set to true, user will require - Microsoft.Management/managementGroups/write action on the root Management Group scope in order - to create new Groups directly under the root. This will prevent new users from creating new - Management Groups, unless they are given access. - :type require_authorization_for_group_creation: bool - :param default_management_group: Settings that sets the default Management Group under which - new subscriptions get added in this tenant. For example, - /providers/Microsoft.Management/managementGroups/defaultGroup. - :type default_management_group: str - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'require_authorization_for_group_creation': {'key': 'properties.requireAuthorizationForGroupCreation', 'type': 'bool'}, - 'default_management_group': {'key': 'properties.defaultManagementGroup', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(HierarchySettingsInfo, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.tenant_id = kwargs.get('tenant_id', None) - self.require_authorization_for_group_creation = kwargs.get('require_authorization_for_group_creation', None) - self.default_management_group = kwargs.get('default_management_group', None) - - -class HierarchySettingsList(msrest.serialization.Model): - """Lists all hierarchy settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of hierarchy settings. - :type value: list[~azure.mgmt.managementgroups.models.HierarchySettingsInfo] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[HierarchySettingsInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(HierarchySettingsList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class ListSubscriptionUnderManagementGroup(msrest.serialization.Model): - """The details of all subscriptions under management group. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of subscriptions. - :type value: list[~azure.mgmt.managementgroups.models.SubscriptionUnderManagementGroup] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SubscriptionUnderManagementGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ListSubscriptionUnderManagementGroup, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class ManagementGroup(msrest.serialization.Model): - """The management group details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The fully qualified ID for the management group. For example, - /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - :vartype id: str - :ivar type: The type of the resource. For example, Microsoft.Management/managementGroups. - :vartype type: str - :ivar name: The name of the management group. For example, - 00000000-0000-0000-0000-000000000000. - :vartype name: str - :param tenant_id: The AAD Tenant ID associated with the management group. For example, - 00000000-0000-0000-0000-000000000000. - :type tenant_id: str - :param display_name: The friendly name of the management group. - :type display_name: str - :param details: The details of a management group. - :type details: ~azure.mgmt.managementgroups.models.ManagementGroupDetails - :param children: The list of children. - :type children: list[~azure.mgmt.managementgroups.models.ManagementGroupChildInfo] - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'details': {'key': 'properties.details', 'type': 'ManagementGroupDetails'}, - 'children': {'key': 'properties.children', 'type': '[ManagementGroupChildInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementGroup, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.tenant_id = kwargs.get('tenant_id', None) - self.display_name = kwargs.get('display_name', None) - self.details = kwargs.get('details', None) - self.children = kwargs.get('children', None) - - -class ManagementGroupChildInfo(msrest.serialization.Model): - """The child information of a management group. - - :param type: The fully qualified resource type which includes provider namespace (e.g. - Microsoft.Management/managementGroups). Possible values include: - "Microsoft.Management/managementGroups", "/subscriptions". - :type type: str or ~azure.mgmt.managementgroups.models.ManagementGroupChildType - :param id: The fully qualified ID for the child resource (management group or subscription). - For example, - /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - :type id: str - :param name: The name of the child entity. - :type name: str - :param display_name: The friendly name of the child resource. - :type display_name: str - :param children: The list of children. - :type children: list[~azure.mgmt.managementgroups.models.ManagementGroupChildInfo] - """ - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'children': {'key': 'children', 'type': '[ManagementGroupChildInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementGroupChildInfo, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.children = kwargs.get('children', None) - - -class ManagementGroupDetails(msrest.serialization.Model): - """The details of a management group. - - :param version: The version number of the object. - :type version: int - :param updated_time: The date and time when this object was last updated. - :type updated_time: ~datetime.datetime - :param updated_by: The identity of the principal or process that updated the object. - :type updated_by: str - :param parent: (Optional) The ID of the parent management group. - :type parent: ~azure.mgmt.managementgroups.models.ParentGroupInfo - :param path: The path from the root to the current group. - :type path: list[~azure.mgmt.managementgroups.models.ManagementGroupPathElement] - :param management_group_ancestors: The ancestors of the management group. - :type management_group_ancestors: list[str] - :param management_group_ancestors_chain: The ancestors of the management group displayed in - reversed order, from immediate parent to the root. - :type management_group_ancestors_chain: - list[~azure.mgmt.managementgroups.models.ManagementGroupPathElement] - """ - - _attribute_map = { - 'version': {'key': 'version', 'type': 'int'}, - 'updated_time': {'key': 'updatedTime', 'type': 'iso-8601'}, - 'updated_by': {'key': 'updatedBy', 'type': 'str'}, - 'parent': {'key': 'parent', 'type': 'ParentGroupInfo'}, - 'path': {'key': 'path', 'type': '[ManagementGroupPathElement]'}, - 'management_group_ancestors': {'key': 'managementGroupAncestors', 'type': '[str]'}, - 'management_group_ancestors_chain': {'key': 'managementGroupAncestorsChain', 'type': '[ManagementGroupPathElement]'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementGroupDetails, self).__init__(**kwargs) - self.version = kwargs.get('version', None) - self.updated_time = kwargs.get('updated_time', None) - self.updated_by = kwargs.get('updated_by', None) - self.parent = kwargs.get('parent', None) - self.path = kwargs.get('path', None) - self.management_group_ancestors = kwargs.get('management_group_ancestors', None) - self.management_group_ancestors_chain = kwargs.get('management_group_ancestors_chain', None) - - -class ManagementGroupInfo(msrest.serialization.Model): - """The management group resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The fully qualified ID for the management group. For example, - /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - :vartype id: str - :ivar type: The type of the resource. For example, Microsoft.Management/managementGroups. - :vartype type: str - :ivar name: The name of the management group. For example, - 00000000-0000-0000-0000-000000000000. - :vartype name: str - :param tenant_id: The AAD Tenant ID associated with the management group. For example, - 00000000-0000-0000-0000-000000000000. - :type tenant_id: str - :param display_name: The friendly name of the management group. - :type display_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementGroupInfo, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.tenant_id = kwargs.get('tenant_id', None) - self.display_name = kwargs.get('display_name', None) - - -class ManagementGroupListResult(msrest.serialization.Model): - """Describes the result of the request to list management groups. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of management groups. - :type value: list[~azure.mgmt.managementgroups.models.ManagementGroupInfo] - :ivar next_link: The URL to use for getting the next set of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ManagementGroupInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementGroupListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class ManagementGroupPathElement(msrest.serialization.Model): - """A path element of a management group ancestors. - - :param name: The name of the group. - :type name: str - :param display_name: The friendly name of the group. - :type display_name: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementGroupPathElement, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - - -class Operation(msrest.serialization.Model): - """Operation supported by the Microsoft.Management resource provider. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.managementgroups.models.OperationDisplayProperties - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplayProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = kwargs.get('display', None) - - -class OperationDisplayProperties(msrest.serialization.Model): - """The object that represents the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The name of the provider. - :vartype provider: str - :ivar resource: The resource on which the operation is performed. - :vartype resource: str - :ivar operation: The operation that can be performed. - :vartype operation: str - :ivar description: Operation description. - :vartype description: str - """ - - _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplayProperties, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(msrest.serialization.Model): - """Describes the result of the request to list Microsoft.Management operations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of operations supported by the Microsoft.Management resource provider. - :vartype value: list[~azure.mgmt.managementgroups.models.Operation] - :ivar next_link: URL to get the next set of operation list results if there are any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class OperationResults(msrest.serialization.Model): - """The results of an asynchronous operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The fully qualified ID for the management group. For example, - /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - :vartype id: str - :ivar type: The type of the resource. For example, Microsoft.Management/managementGroups. - :vartype type: str - :ivar name: The name of the management group. For example, - 00000000-0000-0000-0000-000000000000. - :vartype name: str - :param tenant_id: The AAD Tenant ID associated with the management group. For example, - 00000000-0000-0000-0000-000000000000. - :type tenant_id: str - :param display_name: The friendly name of the management group. - :type display_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationResults, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.tenant_id = kwargs.get('tenant_id', None) - self.display_name = kwargs.get('display_name', None) - - -class ParentGroupInfo(msrest.serialization.Model): - """(Optional) The ID of the parent management group. - - :param id: The fully qualified ID for the parent management group. For example, - /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - :type id: str - :param name: The name of the parent management group. - :type name: str - :param display_name: The friendly name of the parent management group. - :type display_name: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ParentGroupInfo, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - - -class PatchManagementGroupRequest(msrest.serialization.Model): - """Management group patch parameters. - - :param display_name: The friendly name of the management group. - :type display_name: str - :param parent_group_id: (Optional) The fully qualified ID for the parent management group. For - example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - :type parent_group_id: str - """ - - _attribute_map = { - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'parent_group_id': {'key': 'parentGroupId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PatchManagementGroupRequest, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.parent_group_id = kwargs.get('parent_group_id', None) - - -class SubscriptionUnderManagementGroup(msrest.serialization.Model): - """The details of subscription under management group. - - 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. - :vartype id: str - :ivar type: The type of the resource. For example, - Microsoft.Management/managementGroups/subscriptions. - :vartype type: str - :ivar name: The stringified id of the subscription. For example, - 00000000-0000-0000-0000-000000000000. - :vartype name: str - :param tenant: The AAD Tenant ID associated with the subscription. For example, - 00000000-0000-0000-0000-000000000000. - :type tenant: str - :param display_name: The friendly name of the subscription. - :type display_name: str - :param parent: The ID of the parent management group. - :type parent: ~azure.mgmt.managementgroups.models.DescendantParentGroupInfo - :param state: The state of the subscription. - :type state: str - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tenant': {'key': 'properties.tenant', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'parent': {'key': 'properties.parent', 'type': 'DescendantParentGroupInfo'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionUnderManagementGroup, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.tenant = kwargs.get('tenant', None) - self.display_name = kwargs.get('display_name', None) - self.parent = kwargs.get('parent', None) - self.state = kwargs.get('state', None) - - -class TenantBackfillStatusResult(msrest.serialization.Model): - """The tenant backfill status. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tenant_id: The AAD Tenant ID associated with the management group. For example, - 00000000-0000-0000-0000-000000000000. - :vartype tenant_id: str - :ivar status: The status of the Tenant Backfill. Possible values include: "NotStarted", - "NotStartedButGroupsExist", "Started", "Failed", "Cancelled", "Completed". - :vartype status: str or ~azure.mgmt.managementgroups.models.Status - """ - - _validation = { - 'tenant_id': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TenantBackfillStatusResult, self).__init__(**kwargs) - self.tenant_id = None - self.status = None 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 d516780d606c..79a25ca77eb7 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 @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import List, Optional, Union +from typing import List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._management_groups_api_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AzureAsyncOperationResults(msrest.serialization.Model): @@ -31,11 +33,11 @@ class AzureAsyncOperationResults(msrest.serialization.Model): :ivar status: The current status of the asynchronous operation performed . For example, Running, Succeeded, Failed. :vartype status: str - :param tenant_id: The AAD Tenant ID associated with the management group. For example, + :ivar tenant_id: The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000. - :type tenant_id: str - :param display_name: The friendly name of the management group. - :type display_name: str + :vartype tenant_id: str + :ivar display_name: The friendly name of the management group. + :vartype display_name: str """ _validation = { @@ -61,6 +63,13 @@ def __init__( display_name: Optional[str] = None, **kwargs ): + """ + :keyword tenant_id: The AAD Tenant ID associated with the management group. For example, + 00000000-0000-0000-0000-000000000000. + :paramtype tenant_id: str + :keyword display_name: The friendly name of the management group. + :paramtype display_name: str + """ super(AzureAsyncOperationResults, self).__init__(**kwargs) self.id = None self.type = None @@ -73,34 +82,37 @@ def __init__( class CheckNameAvailabilityRequest(msrest.serialization.Model): """Management group name availability check parameters. - Variables are only populated by the server, and will be ignored when sending a request. - - :param name: the name to check for availability. - :type name: str - :ivar type: fully qualified resource type which includes provider namespace. Default value: - "Microsoft.Management/managementGroups". + :ivar name: the name to check for availability. + :vartype name: str + :ivar type: fully qualified resource type which includes provider namespace. The only + acceptable values to pass in are None and "Microsoft.Management/managementGroups". The default + value is None. :vartype type: str """ - _validation = { - 'type': {'constant': True}, - } - _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, } - type = "Microsoft.Management/managementGroups" - def __init__( self, *, name: Optional[str] = None, + type: Optional[str] = None, **kwargs ): + """ + :keyword name: the name to check for availability. + :paramtype name: str + :keyword type: fully qualified resource type which includes provider namespace. The only + acceptable values to pass in are None and "Microsoft.Management/managementGroups". The default + value is None. + :paramtype type: str + """ super(CheckNameAvailabilityRequest, self).__init__(**kwargs) self.name = name + self.type = type class CheckNameAvailabilityResult(msrest.serialization.Model): @@ -114,7 +126,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): :ivar reason: Required if nameAvailable == false. Invalid indicates the name provided does not match the resource provider's naming requirements (incorrect length, unsupported characters, etc.) AlreadyExists indicates that the name is already in use and is therefore unavailable. - Possible values include: "Invalid", "AlreadyExists". + Known values are: "Invalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.managementgroups.models.Reason :ivar message: Required if nameAvailable == false. Localized. If reason == invalid, provide the user with the reason why the given name is invalid, and provide the resource naming @@ -139,6 +151,8 @@ def __init__( self, **kwargs ): + """ + """ super(CheckNameAvailabilityResult, self).__init__(**kwargs) self.name_available = None self.reason = None @@ -151,7 +165,7 @@ class CreateManagementGroupChildInfo(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The fully qualified resource type which includes provider namespace (e.g. - Microsoft.Management/managementGroups). Possible values include: + Microsoft.Management/managementGroups). Known values are: "Microsoft.Management/managementGroups", "/subscriptions". :vartype type: str or ~azure.mgmt.managementgroups.models.ManagementGroupChildType :ivar id: The fully qualified ID for the child resource (management group or subscription). @@ -186,6 +200,8 @@ def __init__( self, **kwargs ): + """ + """ super(CreateManagementGroupChildInfo, self).__init__(**kwargs) self.type = None self.id = None @@ -205,8 +221,8 @@ class CreateManagementGroupDetails(msrest.serialization.Model): :vartype updated_time: ~datetime.datetime :ivar updated_by: The identity of the principal or process that updated the object. :vartype updated_by: str - :param parent: (Optional) The ID of the parent management group used during creation. - :type parent: ~azure.mgmt.managementgroups.models.CreateParentGroupInfo + :ivar parent: (Optional) The ID of the parent management group used during creation. + :vartype parent: ~azure.mgmt.managementgroups.models.CreateParentGroupInfo """ _validation = { @@ -225,9 +241,13 @@ class CreateManagementGroupDetails(msrest.serialization.Model): def __init__( self, *, - parent: Optional["CreateParentGroupInfo"] = None, + parent: Optional["_models.CreateParentGroupInfo"] = None, **kwargs ): + """ + :keyword parent: (Optional) The ID of the parent management group used during creation. + :paramtype parent: ~azure.mgmt.managementgroups.models.CreateParentGroupInfo + """ super(CreateManagementGroupDetails, self).__init__(**kwargs) self.version = None self.updated_time = None @@ -245,17 +265,17 @@ class CreateManagementGroupRequest(msrest.serialization.Model): :vartype id: str :ivar type: The type of the resource. For example, Microsoft.Management/managementGroups. :vartype type: str - :param name: The name of the management group. For example, + :ivar name: The name of the management group. For example, 00000000-0000-0000-0000-000000000000. - :type name: str + :vartype name: str :ivar tenant_id: The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000. :vartype tenant_id: str - :param display_name: The friendly name of the management group. If no value is passed then this + :ivar display_name: The friendly name of the management group. If no value is passed then this field will be set to the groupId. - :type display_name: str - :param details: The details of a management group used during creation. - :type details: ~azure.mgmt.managementgroups.models.CreateManagementGroupDetails + :vartype display_name: str + :ivar details: The details of a management group used during creation. + :vartype details: ~azure.mgmt.managementgroups.models.CreateManagementGroupDetails :ivar children: The list of children. :vartype children: list[~azure.mgmt.managementgroups.models.CreateManagementGroupChildInfo] """ @@ -282,9 +302,19 @@ def __init__( *, name: Optional[str] = None, display_name: Optional[str] = None, - details: Optional["CreateManagementGroupDetails"] = None, + details: Optional["_models.CreateManagementGroupDetails"] = None, **kwargs ): + """ + :keyword name: The name of the management group. For example, + 00000000-0000-0000-0000-000000000000. + :paramtype name: str + :keyword display_name: The friendly name of the management group. If no value is passed then + this field will be set to the groupId. + :paramtype display_name: str + :keyword details: The details of a management group used during creation. + :paramtype details: ~azure.mgmt.managementgroups.models.CreateManagementGroupDetails + """ super(CreateManagementGroupRequest, self).__init__(**kwargs) self.id = None self.type = None @@ -298,16 +328,16 @@ def __init__( class CreateOrUpdateSettingsRequest(msrest.serialization.Model): """Parameters for creating or updating Management Group settings. - :param require_authorization_for_group_creation: Indicates whether RBAC access is required upon + :ivar require_authorization_for_group_creation: Indicates whether RBAC access is required upon group creation under the root Management Group. If set to true, user will require Microsoft.Management/managementGroups/write action on the root Management Group scope in order to create new Groups directly under the root. This will prevent new users from creating new Management Groups, unless they are given access. - :type require_authorization_for_group_creation: bool - :param default_management_group: Settings that sets the default Management Group under which - new subscriptions get added in this tenant. For example, + :vartype require_authorization_for_group_creation: bool + :ivar default_management_group: Settings that sets the default Management Group under which new + subscriptions get added in this tenant. For example, /providers/Microsoft.Management/managementGroups/defaultGroup. - :type default_management_group: str + :vartype default_management_group: str """ _attribute_map = { @@ -322,6 +352,18 @@ def __init__( default_management_group: Optional[str] = None, **kwargs ): + """ + :keyword require_authorization_for_group_creation: Indicates whether RBAC access is required + upon group creation under the root Management Group. If set to true, user will require + Microsoft.Management/managementGroups/write action on the root Management Group scope in order + to create new Groups directly under the root. This will prevent new users from creating new + Management Groups, unless they are given access. + :paramtype require_authorization_for_group_creation: bool + :keyword default_management_group: Settings that sets the default Management Group under which + new subscriptions get added in this tenant. For example, + /providers/Microsoft.Management/managementGroups/defaultGroup. + :paramtype default_management_group: str + """ super(CreateOrUpdateSettingsRequest, self).__init__(**kwargs) self.require_authorization_for_group_creation = require_authorization_for_group_creation self.default_management_group = default_management_group @@ -332,9 +374,9 @@ class CreateParentGroupInfo(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param id: The fully qualified ID for the parent management group. For example, + :ivar id: The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - :type id: str + :vartype id: str :ivar name: The name of the parent management group. :vartype name: str :ivar display_name: The friendly name of the parent management group. @@ -358,6 +400,11 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: The fully qualified ID for the parent management group. For example, + /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. + :paramtype id: str + """ super(CreateParentGroupInfo, self).__init__(**kwargs) self.id = id self.name = None @@ -378,10 +425,10 @@ class DescendantInfo(msrest.serialization.Model): :vartype type: str :ivar name: The name of the descendant. For example, 00000000-0000-0000-0000-000000000000. :vartype name: str - :param display_name: The friendly name of the management group. - :type display_name: str - :param parent: The ID of the parent management group. - :type parent: ~azure.mgmt.managementgroups.models.DescendantParentGroupInfo + :ivar display_name: The friendly name of the management group. + :vartype display_name: str + :ivar parent: The ID of the parent management group. + :vartype parent: ~azure.mgmt.managementgroups.models.DescendantParentGroupInfo """ _validation = { @@ -402,9 +449,15 @@ def __init__( self, *, display_name: Optional[str] = None, - parent: Optional["DescendantParentGroupInfo"] = None, + parent: Optional["_models.DescendantParentGroupInfo"] = None, **kwargs ): + """ + :keyword display_name: The friendly name of the management group. + :paramtype display_name: str + :keyword parent: The ID of the parent management group. + :paramtype parent: ~azure.mgmt.managementgroups.models.DescendantParentGroupInfo + """ super(DescendantInfo, self).__init__(**kwargs) self.id = None self.type = None @@ -418,8 +471,8 @@ class DescendantListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of descendants. - :type value: list[~azure.mgmt.managementgroups.models.DescendantInfo] + :ivar value: The list of descendants. + :vartype value: list[~azure.mgmt.managementgroups.models.DescendantInfo] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -436,9 +489,13 @@ class DescendantListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["DescendantInfo"]] = None, + value: Optional[List["_models.DescendantInfo"]] = None, **kwargs ): + """ + :keyword value: The list of descendants. + :paramtype value: list[~azure.mgmt.managementgroups.models.DescendantInfo] + """ super(DescendantListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -447,9 +504,9 @@ def __init__( class DescendantParentGroupInfo(msrest.serialization.Model): """The ID of the parent management group. - :param id: The fully qualified ID for the parent management group. For example, + :ivar id: The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - :type id: str + :vartype id: str """ _attribute_map = { @@ -462,6 +519,11 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: The fully qualified ID for the parent management group. For example, + /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. + :paramtype id: str + """ super(DescendantParentGroupInfo, self).__init__(**kwargs) self.id = id @@ -479,13 +541,13 @@ class EntityHierarchyItem(msrest.serialization.Model): :ivar name: The name of the management group. For example, 00000000-0000-0000-0000-000000000000. :vartype name: str - :param display_name: The friendly name of the management group. - :type display_name: str - :param permissions: The users specific permissions to this item. Possible values include: - "noaccess", "view", "edit", "delete". - :type permissions: str or ~azure.mgmt.managementgroups.models.Permissions - :param children: The list of children. - :type children: list[~azure.mgmt.managementgroups.models.EntityHierarchyItem] + :ivar display_name: The friendly name of the management group. + :vartype display_name: str + :ivar permissions: The users specific permissions to this item. Known values are: "noaccess", + "view", "edit", "delete". + :vartype permissions: str or ~azure.mgmt.managementgroups.models.Permissions + :ivar children: The list of children. + :vartype children: list[~azure.mgmt.managementgroups.models.EntityHierarchyItem] """ _validation = { @@ -507,10 +569,19 @@ def __init__( self, *, display_name: Optional[str] = None, - permissions: Optional[Union[str, "Permissions"]] = None, - children: Optional[List["EntityHierarchyItem"]] = None, + permissions: Optional[Union[str, "_models.Permissions"]] = None, + children: Optional[List["_models.EntityHierarchyItem"]] = None, **kwargs ): + """ + :keyword display_name: The friendly name of the management group. + :paramtype display_name: str + :keyword permissions: The users specific permissions to this item. Known values are: + "noaccess", "view", "edit", "delete". + :paramtype permissions: str or ~azure.mgmt.managementgroups.models.Permissions + :keyword children: The list of children. + :paramtype children: list[~azure.mgmt.managementgroups.models.EntityHierarchyItem] + """ super(EntityHierarchyItem, self).__init__(**kwargs) self.id = None self.type = None @@ -532,32 +603,32 @@ class EntityInfo(msrest.serialization.Model): :vartype type: str :ivar name: The name of the entity. For example, 00000000-0000-0000-0000-000000000000. :vartype name: str - :param tenant_id: The AAD Tenant ID associated with the entity. For example, + :ivar tenant_id: The AAD Tenant ID associated with the entity. For example, 00000000-0000-0000-0000-000000000000. - :type tenant_id: str - :param display_name: The friendly name of the management group. - :type display_name: str - :param parent: (Optional) The ID of the parent management group. - :type parent: ~azure.mgmt.managementgroups.models.EntityParentGroupInfo - :param permissions: The users specific permissions to this item. Possible values include: + :vartype tenant_id: str + :ivar display_name: The friendly name of the management group. + :vartype display_name: str + :ivar parent: (Optional) The ID of the parent management group. + :vartype parent: ~azure.mgmt.managementgroups.models.EntityParentGroupInfo + :ivar permissions: The users specific permissions to this item. Known values are: "noaccess", + "view", "edit", "delete". + :vartype permissions: str or ~azure.mgmt.managementgroups.models.Permissions + :ivar inherited_permissions: The users specific permissions to this item. Known values are: "noaccess", "view", "edit", "delete". - :type permissions: str or ~azure.mgmt.managementgroups.models.Permissions - :param inherited_permissions: The users specific permissions to this item. Possible values - include: "noaccess", "view", "edit", "delete". - :type inherited_permissions: str or ~azure.mgmt.managementgroups.models.Permissions - :param number_of_descendants: Number of Descendants. - :type number_of_descendants: int - :param number_of_children: Number of children is the number of Groups and Subscriptions that - are exactly one level underneath the current Group. - :type number_of_children: int - :param number_of_child_groups: Number of children is the number of Groups that are exactly one + :vartype inherited_permissions: str or ~azure.mgmt.managementgroups.models.Permissions + :ivar number_of_descendants: Number of Descendants. + :vartype number_of_descendants: int + :ivar number_of_children: Number of children is the number of Groups and Subscriptions that are + exactly one level underneath the current Group. + :vartype number_of_children: int + :ivar number_of_child_groups: Number of children is the number of Groups that are exactly one level underneath the current Group. - :type number_of_child_groups: int - :param parent_display_name_chain: The parent display name chain from the root group to the + :vartype number_of_child_groups: int + :ivar parent_display_name_chain: The parent display name chain from the root group to the immediate parent. - :type parent_display_name_chain: list[str] - :param parent_name_chain: The parent name chain from the root group to the immediate parent. - :type parent_name_chain: list[str] + :vartype parent_display_name_chain: list[str] + :ivar parent_name_chain: The parent name chain from the root group to the immediate parent. + :vartype parent_name_chain: list[str] """ _validation = { @@ -587,9 +658,9 @@ def __init__( *, tenant_id: Optional[str] = None, display_name: Optional[str] = None, - parent: Optional["EntityParentGroupInfo"] = None, - permissions: Optional[Union[str, "Permissions"]] = None, - inherited_permissions: Optional[Union[str, "Permissions"]] = None, + parent: Optional["_models.EntityParentGroupInfo"] = None, + permissions: Optional[Union[str, "_models.Permissions"]] = None, + inherited_permissions: Optional[Union[str, "_models.Permissions"]] = None, number_of_descendants: Optional[int] = None, number_of_children: Optional[int] = None, number_of_child_groups: Optional[int] = None, @@ -597,6 +668,34 @@ def __init__( parent_name_chain: Optional[List[str]] = None, **kwargs ): + """ + :keyword tenant_id: The AAD Tenant ID associated with the entity. For example, + 00000000-0000-0000-0000-000000000000. + :paramtype tenant_id: str + :keyword display_name: The friendly name of the management group. + :paramtype display_name: str + :keyword parent: (Optional) The ID of the parent management group. + :paramtype parent: ~azure.mgmt.managementgroups.models.EntityParentGroupInfo + :keyword permissions: The users specific permissions to this item. Known values are: + "noaccess", "view", "edit", "delete". + :paramtype permissions: str or ~azure.mgmt.managementgroups.models.Permissions + :keyword inherited_permissions: The users specific permissions to this item. Known values are: + "noaccess", "view", "edit", "delete". + :paramtype inherited_permissions: str or ~azure.mgmt.managementgroups.models.Permissions + :keyword number_of_descendants: Number of Descendants. + :paramtype number_of_descendants: int + :keyword number_of_children: Number of children is the number of Groups and Subscriptions that + are exactly one level underneath the current Group. + :paramtype number_of_children: int + :keyword number_of_child_groups: Number of children is the number of Groups that are exactly + one level underneath the current Group. + :paramtype number_of_child_groups: int + :keyword parent_display_name_chain: The parent display name chain from the root group to the + immediate parent. + :paramtype parent_display_name_chain: list[str] + :keyword parent_name_chain: The parent name chain from the root group to the immediate parent. + :paramtype parent_name_chain: list[str] + """ super(EntityInfo, self).__init__(**kwargs) self.id = None self.type = None @@ -618,8 +717,8 @@ class EntityListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of entities. - :type value: list[~azure.mgmt.managementgroups.models.EntityInfo] + :ivar value: The list of entities. + :vartype value: list[~azure.mgmt.managementgroups.models.EntityInfo] :ivar count: Total count of records that match the filter. :vartype count: int :ivar next_link: The URL to use for getting the next set of results. @@ -640,9 +739,13 @@ class EntityListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["EntityInfo"]] = None, + value: Optional[List["_models.EntityInfo"]] = None, **kwargs ): + """ + :keyword value: The list of entities. + :paramtype value: list[~azure.mgmt.managementgroups.models.EntityInfo] + """ super(EntityListResult, self).__init__(**kwargs) self.value = value self.count = None @@ -652,9 +755,9 @@ def __init__( class EntityParentGroupInfo(msrest.serialization.Model): """(Optional) The ID of the parent management group. - :param id: The fully qualified ID for the parent management group. For example, + :ivar id: The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - :type id: str + :vartype id: str """ _attribute_map = { @@ -667,6 +770,11 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: The fully qualified ID for the parent management group. For example, + /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. + :paramtype id: str + """ super(EntityParentGroupInfo, self).__init__(**kwargs) self.id = id @@ -674,12 +782,12 @@ def __init__( class ErrorDetails(msrest.serialization.Model): """The details of the error. - :param code: One of a server-defined set of error codes. - :type code: str - :param message: A human-readable representation of the error. - :type message: str - :param details: A human-readable representation of the error's details. - :type details: str + :ivar code: One of a server-defined set of error codes. + :vartype code: str + :ivar message: A human-readable representation of the error. + :vartype message: str + :ivar details: A human-readable representation of the error's details. + :vartype details: str """ _attribute_map = { @@ -696,6 +804,14 @@ def __init__( details: Optional[str] = None, **kwargs ): + """ + :keyword code: One of a server-defined set of error codes. + :paramtype code: str + :keyword message: A human-readable representation of the error. + :paramtype message: str + :keyword details: A human-readable representation of the error's details. + :paramtype details: str + """ super(ErrorDetails, self).__init__(**kwargs) self.code = code self.message = message @@ -705,8 +821,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """The error object. - :param error: The details of the error. - :type error: ~azure.mgmt.managementgroups.models.ErrorDetails + :ivar error: The details of the error. + :vartype error: ~azure.mgmt.managementgroups.models.ErrorDetails """ _attribute_map = { @@ -716,9 +832,13 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorDetails"] = None, + error: Optional["_models.ErrorDetails"] = None, **kwargs ): + """ + :keyword error: The details of the error. + :paramtype error: ~azure.mgmt.managementgroups.models.ErrorDetails + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -736,19 +856,19 @@ class HierarchySettings(msrest.serialization.Model): :vartype type: str :ivar name: The name of the object. In this case, default. :vartype name: str - :param tenant_id: The AAD Tenant ID associated with the hierarchy settings. For example, + :ivar tenant_id: The AAD Tenant ID associated with the hierarchy settings. For example, 00000000-0000-0000-0000-000000000000. - :type tenant_id: str - :param require_authorization_for_group_creation: Indicates whether RBAC access is required upon + :vartype tenant_id: str + :ivar require_authorization_for_group_creation: Indicates whether RBAC access is required upon group creation under the root Management Group. If set to true, user will require Microsoft.Management/managementGroups/write action on the root Management Group scope in order to create new Groups directly under the root. This will prevent new users from creating new Management Groups, unless they are given access. - :type require_authorization_for_group_creation: bool - :param default_management_group: Settings that sets the default Management Group under which - new subscriptions get added in this tenant. For example, + :vartype require_authorization_for_group_creation: bool + :ivar default_management_group: Settings that sets the default Management Group under which new + subscriptions get added in this tenant. For example, /providers/Microsoft.Management/managementGroups/defaultGroup. - :type default_management_group: str + :vartype default_management_group: str """ _validation = { @@ -774,6 +894,21 @@ def __init__( default_management_group: Optional[str] = None, **kwargs ): + """ + :keyword tenant_id: The AAD Tenant ID associated with the hierarchy settings. For example, + 00000000-0000-0000-0000-000000000000. + :paramtype tenant_id: str + :keyword require_authorization_for_group_creation: Indicates whether RBAC access is required + upon group creation under the root Management Group. If set to true, user will require + Microsoft.Management/managementGroups/write action on the root Management Group scope in order + to create new Groups directly under the root. This will prevent new users from creating new + Management Groups, unless they are given access. + :paramtype require_authorization_for_group_creation: bool + :keyword default_management_group: Settings that sets the default Management Group under which + new subscriptions get added in this tenant. For example, + /providers/Microsoft.Management/managementGroups/defaultGroup. + :paramtype default_management_group: str + """ super(HierarchySettings, self).__init__(**kwargs) self.id = None self.type = None @@ -796,19 +931,19 @@ class HierarchySettingsInfo(msrest.serialization.Model): :vartype type: str :ivar name: The name of the object. In this case, default. :vartype name: str - :param tenant_id: The AAD Tenant ID associated with the hierarchy settings. For example, + :ivar tenant_id: The AAD Tenant ID associated with the hierarchy settings. For example, 00000000-0000-0000-0000-000000000000. - :type tenant_id: str - :param require_authorization_for_group_creation: Indicates whether RBAC access is required upon + :vartype tenant_id: str + :ivar require_authorization_for_group_creation: Indicates whether RBAC access is required upon group creation under the root Management Group. If set to true, user will require Microsoft.Management/managementGroups/write action on the root Management Group scope in order to create new Groups directly under the root. This will prevent new users from creating new Management Groups, unless they are given access. - :type require_authorization_for_group_creation: bool - :param default_management_group: Settings that sets the default Management Group under which - new subscriptions get added in this tenant. For example, + :vartype require_authorization_for_group_creation: bool + :ivar default_management_group: Settings that sets the default Management Group under which new + subscriptions get added in this tenant. For example, /providers/Microsoft.Management/managementGroups/defaultGroup. - :type default_management_group: str + :vartype default_management_group: str """ _validation = { @@ -834,6 +969,21 @@ def __init__( default_management_group: Optional[str] = None, **kwargs ): + """ + :keyword tenant_id: The AAD Tenant ID associated with the hierarchy settings. For example, + 00000000-0000-0000-0000-000000000000. + :paramtype tenant_id: str + :keyword require_authorization_for_group_creation: Indicates whether RBAC access is required + upon group creation under the root Management Group. If set to true, user will require + Microsoft.Management/managementGroups/write action on the root Management Group scope in order + to create new Groups directly under the root. This will prevent new users from creating new + Management Groups, unless they are given access. + :paramtype require_authorization_for_group_creation: bool + :keyword default_management_group: Settings that sets the default Management Group under which + new subscriptions get added in this tenant. For example, + /providers/Microsoft.Management/managementGroups/defaultGroup. + :paramtype default_management_group: str + """ super(HierarchySettingsInfo, self).__init__(**kwargs) self.id = None self.type = None @@ -848,8 +998,8 @@ class HierarchySettingsList(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of hierarchy settings. - :type value: list[~azure.mgmt.managementgroups.models.HierarchySettingsInfo] + :ivar value: The list of hierarchy settings. + :vartype value: list[~azure.mgmt.managementgroups.models.HierarchySettingsInfo] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -866,9 +1016,13 @@ class HierarchySettingsList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["HierarchySettingsInfo"]] = None, + value: Optional[List["_models.HierarchySettingsInfo"]] = None, **kwargs ): + """ + :keyword value: The list of hierarchy settings. + :paramtype value: list[~azure.mgmt.managementgroups.models.HierarchySettingsInfo] + """ super(HierarchySettingsList, self).__init__(**kwargs) self.value = value self.next_link = None @@ -879,8 +1033,8 @@ class ListSubscriptionUnderManagementGroup(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of subscriptions. - :type value: list[~azure.mgmt.managementgroups.models.SubscriptionUnderManagementGroup] + :ivar value: The list of subscriptions. + :vartype value: list[~azure.mgmt.managementgroups.models.SubscriptionUnderManagementGroup] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -897,9 +1051,13 @@ class ListSubscriptionUnderManagementGroup(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["SubscriptionUnderManagementGroup"]] = None, + value: Optional[List["_models.SubscriptionUnderManagementGroup"]] = None, **kwargs ): + """ + :keyword value: The list of subscriptions. + :paramtype value: list[~azure.mgmt.managementgroups.models.SubscriptionUnderManagementGroup] + """ super(ListSubscriptionUnderManagementGroup, self).__init__(**kwargs) self.value = value self.next_link = None @@ -918,15 +1076,15 @@ class ManagementGroup(msrest.serialization.Model): :ivar name: The name of the management group. For example, 00000000-0000-0000-0000-000000000000. :vartype name: str - :param tenant_id: The AAD Tenant ID associated with the management group. For example, + :ivar tenant_id: The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000. - :type tenant_id: str - :param display_name: The friendly name of the management group. - :type display_name: str - :param details: The details of a management group. - :type details: ~azure.mgmt.managementgroups.models.ManagementGroupDetails - :param children: The list of children. - :type children: list[~azure.mgmt.managementgroups.models.ManagementGroupChildInfo] + :vartype tenant_id: str + :ivar display_name: The friendly name of the management group. + :vartype display_name: str + :ivar details: The details of a management group. + :vartype details: ~azure.mgmt.managementgroups.models.ManagementGroupDetails + :ivar children: The list of children. + :vartype children: list[~azure.mgmt.managementgroups.models.ManagementGroupChildInfo] """ _validation = { @@ -950,10 +1108,21 @@ def __init__( *, tenant_id: Optional[str] = None, display_name: Optional[str] = None, - details: Optional["ManagementGroupDetails"] = None, - children: Optional[List["ManagementGroupChildInfo"]] = None, + details: Optional["_models.ManagementGroupDetails"] = None, + children: Optional[List["_models.ManagementGroupChildInfo"]] = None, **kwargs ): + """ + :keyword tenant_id: The AAD Tenant ID associated with the management group. For example, + 00000000-0000-0000-0000-000000000000. + :paramtype tenant_id: str + :keyword display_name: The friendly name of the management group. + :paramtype display_name: str + :keyword details: The details of a management group. + :paramtype details: ~azure.mgmt.managementgroups.models.ManagementGroupDetails + :keyword children: The list of children. + :paramtype children: list[~azure.mgmt.managementgroups.models.ManagementGroupChildInfo] + """ super(ManagementGroup, self).__init__(**kwargs) self.id = None self.type = None @@ -967,20 +1136,20 @@ def __init__( class ManagementGroupChildInfo(msrest.serialization.Model): """The child information of a management group. - :param type: The fully qualified resource type which includes provider namespace (e.g. - Microsoft.Management/managementGroups). Possible values include: + :ivar type: The fully qualified resource type which includes provider namespace (e.g. + Microsoft.Management/managementGroups). Known values are: "Microsoft.Management/managementGroups", "/subscriptions". - :type type: str or ~azure.mgmt.managementgroups.models.ManagementGroupChildType - :param id: The fully qualified ID for the child resource (management group or subscription). + :vartype type: str or ~azure.mgmt.managementgroups.models.ManagementGroupChildType + :ivar id: The fully qualified ID for the child resource (management group or subscription). For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - :type id: str - :param name: The name of the child entity. - :type name: str - :param display_name: The friendly name of the child resource. - :type display_name: str - :param children: The list of children. - :type children: list[~azure.mgmt.managementgroups.models.ManagementGroupChildInfo] + :vartype id: str + :ivar name: The name of the child entity. + :vartype name: str + :ivar display_name: The friendly name of the child resource. + :vartype display_name: str + :ivar children: The list of children. + :vartype children: list[~azure.mgmt.managementgroups.models.ManagementGroupChildInfo] """ _attribute_map = { @@ -994,13 +1163,29 @@ class ManagementGroupChildInfo(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ManagementGroupChildType"]] = None, + type: Optional[Union[str, "_models.ManagementGroupChildType"]] = None, id: Optional[str] = None, name: Optional[str] = None, display_name: Optional[str] = None, - children: Optional[List["ManagementGroupChildInfo"]] = None, + children: Optional[List["_models.ManagementGroupChildInfo"]] = None, **kwargs ): + """ + :keyword type: The fully qualified resource type which includes provider namespace (e.g. + Microsoft.Management/managementGroups). Known values are: + "Microsoft.Management/managementGroups", "/subscriptions". + :paramtype type: str or ~azure.mgmt.managementgroups.models.ManagementGroupChildType + :keyword id: The fully qualified ID for the child resource (management group or subscription). + For example, + /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. + :paramtype id: str + :keyword name: The name of the child entity. + :paramtype name: str + :keyword display_name: The friendly name of the child resource. + :paramtype display_name: str + :keyword children: The list of children. + :paramtype children: list[~azure.mgmt.managementgroups.models.ManagementGroupChildInfo] + """ super(ManagementGroupChildInfo, self).__init__(**kwargs) self.type = type self.id = id @@ -1012,21 +1197,21 @@ def __init__( class ManagementGroupDetails(msrest.serialization.Model): """The details of a management group. - :param version: The version number of the object. - :type version: int - :param updated_time: The date and time when this object was last updated. - :type updated_time: ~datetime.datetime - :param updated_by: The identity of the principal or process that updated the object. - :type updated_by: str - :param parent: (Optional) The ID of the parent management group. - :type parent: ~azure.mgmt.managementgroups.models.ParentGroupInfo - :param path: The path from the root to the current group. - :type path: list[~azure.mgmt.managementgroups.models.ManagementGroupPathElement] - :param management_group_ancestors: The ancestors of the management group. - :type management_group_ancestors: list[str] - :param management_group_ancestors_chain: The ancestors of the management group displayed in + :ivar version: The version number of the object. + :vartype version: int + :ivar updated_time: The date and time when this object was last updated. + :vartype updated_time: ~datetime.datetime + :ivar updated_by: The identity of the principal or process that updated the object. + :vartype updated_by: str + :ivar parent: (Optional) The ID of the parent management group. + :vartype parent: ~azure.mgmt.managementgroups.models.ParentGroupInfo + :ivar path: The path from the root to the current group. + :vartype path: list[~azure.mgmt.managementgroups.models.ManagementGroupPathElement] + :ivar management_group_ancestors: The ancestors of the management group. + :vartype management_group_ancestors: list[str] + :ivar management_group_ancestors_chain: The ancestors of the management group displayed in reversed order, from immediate parent to the root. - :type management_group_ancestors_chain: + :vartype management_group_ancestors_chain: list[~azure.mgmt.managementgroups.models.ManagementGroupPathElement] """ @@ -1046,12 +1231,30 @@ def __init__( version: Optional[int] = None, updated_time: Optional[datetime.datetime] = None, updated_by: Optional[str] = None, - parent: Optional["ParentGroupInfo"] = None, - path: Optional[List["ManagementGroupPathElement"]] = 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["ManagementGroupPathElement"]] = None, + management_group_ancestors_chain: Optional[List["_models.ManagementGroupPathElement"]] = None, **kwargs ): + """ + :keyword version: The version number of the object. + :paramtype version: int + :keyword updated_time: The date and time when this object was last updated. + :paramtype updated_time: ~datetime.datetime + :keyword updated_by: The identity of the principal or process that updated the object. + :paramtype updated_by: str + :keyword parent: (Optional) The ID of the parent management group. + :paramtype parent: ~azure.mgmt.managementgroups.models.ParentGroupInfo + :keyword path: The path from the root to the current group. + :paramtype path: list[~azure.mgmt.managementgroups.models.ManagementGroupPathElement] + :keyword management_group_ancestors: The ancestors of the management group. + :paramtype management_group_ancestors: list[str] + :keyword management_group_ancestors_chain: The ancestors of the management group displayed in + reversed order, from immediate parent to the root. + :paramtype management_group_ancestors_chain: + list[~azure.mgmt.managementgroups.models.ManagementGroupPathElement] + """ super(ManagementGroupDetails, self).__init__(**kwargs) self.version = version self.updated_time = updated_time @@ -1075,11 +1278,11 @@ class ManagementGroupInfo(msrest.serialization.Model): :ivar name: The name of the management group. For example, 00000000-0000-0000-0000-000000000000. :vartype name: str - :param tenant_id: The AAD Tenant ID associated with the management group. For example, + :ivar tenant_id: The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000. - :type tenant_id: str - :param display_name: The friendly name of the management group. - :type display_name: str + :vartype tenant_id: str + :ivar display_name: The friendly name of the management group. + :vartype display_name: str """ _validation = { @@ -1103,6 +1306,13 @@ def __init__( display_name: Optional[str] = None, **kwargs ): + """ + :keyword tenant_id: The AAD Tenant ID associated with the management group. For example, + 00000000-0000-0000-0000-000000000000. + :paramtype tenant_id: str + :keyword display_name: The friendly name of the management group. + :paramtype display_name: str + """ super(ManagementGroupInfo, self).__init__(**kwargs) self.id = None self.type = None @@ -1116,8 +1326,8 @@ class ManagementGroupListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of management groups. - :type value: list[~azure.mgmt.managementgroups.models.ManagementGroupInfo] + :ivar value: The list of management groups. + :vartype value: list[~azure.mgmt.managementgroups.models.ManagementGroupInfo] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -1134,9 +1344,13 @@ class ManagementGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ManagementGroupInfo"]] = None, + value: Optional[List["_models.ManagementGroupInfo"]] = None, **kwargs ): + """ + :keyword value: The list of management groups. + :paramtype value: list[~azure.mgmt.managementgroups.models.ManagementGroupInfo] + """ super(ManagementGroupListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1145,10 +1359,10 @@ def __init__( class ManagementGroupPathElement(msrest.serialization.Model): """A path element of a management group ancestors. - :param name: The name of the group. - :type name: str - :param display_name: The friendly name of the group. - :type display_name: str + :ivar name: The name of the group. + :vartype name: str + :ivar display_name: The friendly name of the group. + :vartype display_name: str """ _attribute_map = { @@ -1163,6 +1377,12 @@ def __init__( display_name: Optional[str] = None, **kwargs ): + """ + :keyword name: The name of the group. + :paramtype name: str + :keyword display_name: The friendly name of the group. + :paramtype display_name: str + """ super(ManagementGroupPathElement, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -1175,8 +1395,8 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{operation}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.managementgroups.models.OperationDisplayProperties + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.managementgroups.models.OperationDisplayProperties """ _validation = { @@ -1191,9 +1411,13 @@ class Operation(msrest.serialization.Model): def __init__( self, *, - display: Optional["OperationDisplayProperties"] = None, + display: Optional["_models.OperationDisplayProperties"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.managementgroups.models.OperationDisplayProperties + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = display @@ -1232,6 +1456,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplayProperties, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1264,6 +1490,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1282,11 +1510,11 @@ class OperationResults(msrest.serialization.Model): :ivar name: The name of the management group. For example, 00000000-0000-0000-0000-000000000000. :vartype name: str - :param tenant_id: The AAD Tenant ID associated with the management group. For example, + :ivar tenant_id: The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000. - :type tenant_id: str - :param display_name: The friendly name of the management group. - :type display_name: str + :vartype tenant_id: str + :ivar display_name: The friendly name of the management group. + :vartype display_name: str """ _validation = { @@ -1310,6 +1538,13 @@ def __init__( display_name: Optional[str] = None, **kwargs ): + """ + :keyword tenant_id: The AAD Tenant ID associated with the management group. For example, + 00000000-0000-0000-0000-000000000000. + :paramtype tenant_id: str + :keyword display_name: The friendly name of the management group. + :paramtype display_name: str + """ super(OperationResults, self).__init__(**kwargs) self.id = None self.type = None @@ -1321,13 +1556,13 @@ def __init__( class ParentGroupInfo(msrest.serialization.Model): """(Optional) The ID of the parent management group. - :param id: The fully qualified ID for the parent management group. For example, + :ivar id: The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - :type id: str - :param name: The name of the parent management group. - :type name: str - :param display_name: The friendly name of the parent management group. - :type display_name: str + :vartype id: str + :ivar name: The name of the parent management group. + :vartype name: str + :ivar display_name: The friendly name of the parent management group. + :vartype display_name: str """ _attribute_map = { @@ -1344,6 +1579,15 @@ def __init__( display_name: Optional[str] = None, **kwargs ): + """ + :keyword id: The fully qualified ID for the parent management group. For example, + /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. + :paramtype id: str + :keyword name: The name of the parent management group. + :paramtype name: str + :keyword display_name: The friendly name of the parent management group. + :paramtype display_name: str + """ super(ParentGroupInfo, self).__init__(**kwargs) self.id = id self.name = name @@ -1353,11 +1597,11 @@ def __init__( class PatchManagementGroupRequest(msrest.serialization.Model): """Management group patch parameters. - :param display_name: The friendly name of the management group. - :type display_name: str - :param parent_group_id: (Optional) The fully qualified ID for the parent management group. For + :ivar display_name: The friendly name of the management group. + :vartype display_name: str + :ivar parent_group_id: (Optional) The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. - :type parent_group_id: str + :vartype parent_group_id: str """ _attribute_map = { @@ -1372,6 +1616,14 @@ def __init__( parent_group_id: Optional[str] = None, **kwargs ): + """ + :keyword display_name: The friendly name of the management group. + :paramtype display_name: str + :keyword parent_group_id: (Optional) The fully qualified ID for the parent management group. + For example, + /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000. + :paramtype parent_group_id: str + """ super(PatchManagementGroupRequest, self).__init__(**kwargs) self.display_name = display_name self.parent_group_id = parent_group_id @@ -1391,15 +1643,15 @@ class SubscriptionUnderManagementGroup(msrest.serialization.Model): :ivar name: The stringified id of the subscription. For example, 00000000-0000-0000-0000-000000000000. :vartype name: str - :param tenant: The AAD Tenant ID associated with the subscription. For example, + :ivar tenant: The AAD Tenant ID associated with the subscription. For example, 00000000-0000-0000-0000-000000000000. - :type tenant: str - :param display_name: The friendly name of the subscription. - :type display_name: str - :param parent: The ID of the parent management group. - :type parent: ~azure.mgmt.managementgroups.models.DescendantParentGroupInfo - :param state: The state of the subscription. - :type state: str + :vartype tenant: str + :ivar display_name: The friendly name of the subscription. + :vartype display_name: str + :ivar parent: The ID of the parent management group. + :vartype parent: ~azure.mgmt.managementgroups.models.DescendantParentGroupInfo + :ivar state: The state of the subscription. + :vartype state: str """ _validation = { @@ -1423,10 +1675,21 @@ def __init__( *, tenant: Optional[str] = None, display_name: Optional[str] = None, - parent: Optional["DescendantParentGroupInfo"] = None, + parent: Optional["_models.DescendantParentGroupInfo"] = None, state: Optional[str] = None, **kwargs ): + """ + :keyword tenant: The AAD Tenant ID associated with the subscription. For example, + 00000000-0000-0000-0000-000000000000. + :paramtype tenant: str + :keyword display_name: The friendly name of the subscription. + :paramtype display_name: str + :keyword parent: The ID of the parent management group. + :paramtype parent: ~azure.mgmt.managementgroups.models.DescendantParentGroupInfo + :keyword state: The state of the subscription. + :paramtype state: str + """ super(SubscriptionUnderManagementGroup, self).__init__(**kwargs) self.id = None self.type = None @@ -1445,7 +1708,7 @@ class TenantBackfillStatusResult(msrest.serialization.Model): :ivar tenant_id: The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000. :vartype tenant_id: str - :ivar status: The status of the Tenant Backfill. Possible values include: "NotStarted", + :ivar status: The status of the Tenant Backfill. Known values are: "NotStarted", "NotStartedButGroupsExist", "Started", "Failed", "Cancelled", "Completed". :vartype status: str or ~azure.mgmt.managementgroups.models.Status """ @@ -1464,6 +1727,8 @@ def __init__( self, **kwargs ): + """ + """ super(TenantBackfillStatusResult, self).__init__(**kwargs) self.tenant_id = None self.status = None diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/models/_patch.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ 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 d3c6bc42bbef..2daa6ac3837c 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 @@ -13,6 +13,9 @@ from ._management_groups_api_operations import ManagementGroupsAPIOperationsMixin from ._entities_operations import EntitiesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ManagementGroupsOperations', 'ManagementGroupSubscriptionsOperations', @@ -21,3 +24,5 @@ 'ManagementGroupsAPIOperationsMixin', 'EntitiesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 282767c9130e..78948d176c4f 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,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,77 +6,133 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + *, + skiptoken: Optional[str] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + select: Optional[str] = None, + search: Optional[Union[str, "_models.EntitySearchType"]] = None, + filter: Optional[str] = None, + view: Optional[Union[str, "_models.EntityViewParameterType"]] = None, + group_name: Optional[str] = None, + cache_control: Optional[str] = "no-cache", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/getEntities") + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skiptoken is not None: + _params['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + if skip is not None: + _params['$skip'] = _SERIALIZER.query("skip", skip, 'int') + if top is not None: + _params['$top'] = _SERIALIZER.query("top", top, 'int') + if select is not None: + _params['$select'] = _SERIALIZER.query("select", select, 'str') + if search is not None: + _params['$search'] = _SERIALIZER.query("search", search, 'str') + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if view is not None: + _params['$view'] = _SERIALIZER.query("view", view, 'str') + if group_name is not None: + _params['groupName'] = _SERIALIZER.query("group_name", group_name, 'str') + + # Construct headers + if cache_control is not None: + _headers['Cache-Control'] = _SERIALIZER.header("cache_control", cache_control, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class EntitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class EntitiesOperations(object): - """EntitiesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.managementgroups.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.managementgroups.ManagementGroupsAPI`'s + :attr:`entities` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, - skiptoken=None, # type: Optional[str] - skip=None, # type: Optional[int] - top=None, # type: Optional[int] - select=None, # type: Optional[str] - search=None, # type: Optional[Union[str, "_models.Enum2"]] - filter=None, # type: Optional[str] - view=None, # type: Optional[Union[str, "_models.Enum3"]] - group_name=None, # type: Optional[str] - cache_control="no-cache", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EntityListResult"] + skiptoken: Optional[str] = None, + skip: Optional[int] = None, + top: Optional[int] = None, + select: Optional[str] = None, + search: Optional[Union[str, "_models.EntitySearchType"]] = None, + filter: Optional[str] = None, + view: Optional[Union[str, "_models.EntityViewParameterType"]] = None, + group_name: Optional[str] = None, + cache_control: Optional[str] = "no-cache", + **kwargs: Any + ) -> Iterable[_models.EntityListResult]: """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 partial result. If a previous response contains a nextLink element, the value of the nextLink element will - include a token parameter that specifies a starting point to use for subsequent calls. + include a token parameter that specifies a starting point to use for subsequent calls. Default + value is None. :type skiptoken: str :param skip: Number of entities to skip over when retrieving results. Passing this in will - override $skipToken. + override $skipToken. Default value is None. :type skip: int :param top: Number of elements to return when retrieving results. Passing this in will override - $skipToken. + $skipToken. Default value is None. :type top: int :param select: This parameter specifies the fields to include in the response. Can include any combination of Name,DisplayName,Type,ParentDisplayNameChain,ParentChain, e.g. '$select=Name,DisplayName,Type,ParentDisplayNameChain,ParentNameChain'. When specified the - $select parameter can override select in $skipToken. + $select parameter can override select in $skipToken. Default value is None. :type select: str :param search: The $search parameter is used in conjunction with the $filter parameter to return three different outputs depending on the parameter passed in. @@ -90,75 +147,84 @@ def list( one of the descendants of the group. With $search=ChildrenOnly the API will return only the first level of children of the group entity info specified in $filter. The user must have direct access to the children entities or - one of it's descendants for it to show up in the results. - :type search: str or ~azure.mgmt.managementgroups.models.Enum2 + one of it's descendants for it to show up in the results. Default value is None. + :type search: str or ~azure.mgmt.managementgroups.models.EntitySearchType :param filter: The filter parameter allows you to filter on the the name or display name fields. You can check for equality on the name field (e.g. name eq '{entityName}') and you can check for substrings on either the name or display name fields(e.g. contains(name, '{substringToSearch}'), contains(displayName, '{substringToSearch')). Note that the - '{entityName}' and '{substringToSearch}' fields are checked case insensitively. + '{entityName}' and '{substringToSearch}' fields are checked case insensitively. Default value + is None. :type filter: str :param view: The view parameter allows clients to filter the type of data that is returned by - the getEntities call. - :type view: str or ~azure.mgmt.managementgroups.models.Enum3 + the getEntities call. Default value is None. + :type view: str or ~azure.mgmt.managementgroups.models.EntityViewParameterType :param group_name: A filter which allows the get entities call to focus on a particular group - (i.e. "$filter=name eq 'groupName'"). + (i.e. "$filter=name eq 'groupName'"). Default value is None. :type group_name: str :param cache_control: Indicates whether the request should utilize any caches. Populate the - header with 'no-cache' value to bypass existing caches. + header with 'no-cache' value to bypass existing caches. Default value is "no-cache". :type cache_control: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EntityListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.managementgroups.models.EntityListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EntityListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EntityListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if cache_control is not None: - header_parameters['Cache-Control'] = self._serialize.header("cache_control", cache_control, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - if skip is not None: - query_parameters['$skip'] = self._serialize.query("skip", skip, 'int') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if select is not None: - query_parameters['$select'] = self._serialize.query("select", select, 'str') - if search is not None: - query_parameters['$search'] = self._serialize.query("search", search, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if view is not None: - query_parameters['$view'] = self._serialize.query("view", view, 'str') - if group_name is not None: - query_parameters['groupName'] = self._serialize.query("group_name", group_name, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + skiptoken=skiptoken, + skip=skip, + top=top, + select=select, + search=search, + filter=filter, + view=view, + group_name=group_name, + cache_control=cache_control, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + skiptoken=skiptoken, + skip=skip, + top=top, + select=select, + search=search, + filter=filter, + view=view, + group_name=group_name, + cache_control=cache_control, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EntityListResult', pipeline_response) + deserialized = self._deserialize("EntityListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -167,17 +233,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Management/getEntities'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Management/getEntities"} # type: ignore 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 b665034a2f52..0073e8d1d018 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,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,51 +6,232 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + group_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/settings") + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + group_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/settings/default") + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + group_id: str, + *, + json: Optional[_models.CreateOrUpdateSettingsRequest] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/settings/default") + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + group_id: str, + *, + json: Optional[_models.CreateOrUpdateSettingsRequest] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/settings/default") + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + group_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/settings/default") + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class HierarchySettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class HierarchySettingsOperations(object): - """HierarchySettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.managementgroups.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.managementgroups.ManagementGroupsAPI`'s + :attr:`hierarchy_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, - group_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.HierarchySettingsList" + group_id: str, + **kwargs: Any + ) -> _models.HierarchySettingsList: """Gets all the hierarchy settings defined at the Management Group level. Settings can only be set on the root Management Group of the hierarchy. @@ -60,36 +242,38 @@ def list( :rtype: ~azure.mgmt.managementgroups.models.HierarchySettingsList :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HierarchySettingsList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.HierarchySettingsList] + + + request = build_list_request( + group_id=group_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -98,14 +282,16 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/settings'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/settings"} # type: ignore + + + @distributed_trace def get( self, - group_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.HierarchySettings" + group_id: str, + **kwargs: Any + ) -> _models.HierarchySettings: """Gets the hierarchy settings defined at the Management Group level. Settings can only be set on the root Management Group of the hierarchy. @@ -116,36 +302,38 @@ def get( :rtype: ~azure.mgmt.managementgroups.models.HierarchySettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HierarchySettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.HierarchySettings] + + + request = build_get_request( + group_id=group_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -154,61 +342,65 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/settings/default'} # type: ignore + get.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/settings/default"} # type: ignore + + + @distributed_trace def create_or_update( self, - group_id, # type: str - create_tenant_settings_request, # type: "_models.CreateOrUpdateSettingsRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.HierarchySettings" + group_id: str, + create_tenant_settings_request: _models.CreateOrUpdateSettingsRequest, + **kwargs: Any + ) -> _models.HierarchySettings: """Creates or updates the hierarchy settings defined at the Management Group level. :param group_id: Management Group ID. :type group_id: str :param create_tenant_settings_request: Tenant level settings request parameter. - :type create_tenant_settings_request: ~azure.mgmt.managementgroups.models.CreateOrUpdateSettingsRequest + :type create_tenant_settings_request: + ~azure.mgmt.managementgroups.models.CreateOrUpdateSettingsRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: HierarchySettings, or the result of cls(response) :rtype: ~azure.mgmt.managementgroups.models.HierarchySettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HierarchySettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_tenant_settings_request, 'CreateOrUpdateSettingsRequest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.HierarchySettings] + + _json = self._serialize.body(create_tenant_settings_request, 'CreateOrUpdateSettingsRequest') + + request = build_create_or_update_request( + group_id=group_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -217,61 +409,65 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/settings/default'} # type: ignore + create_or_update.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/settings/default"} # type: ignore + + + @distributed_trace def update( self, - group_id, # type: str - create_tenant_settings_request, # type: "_models.CreateOrUpdateSettingsRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.HierarchySettings" + group_id: str, + create_tenant_settings_request: _models.CreateOrUpdateSettingsRequest, + **kwargs: Any + ) -> _models.HierarchySettings: """Updates the hierarchy settings defined at the Management Group level. :param group_id: Management Group ID. :type group_id: str :param create_tenant_settings_request: Tenant level settings request parameter. - :type create_tenant_settings_request: ~azure.mgmt.managementgroups.models.CreateOrUpdateSettingsRequest + :type create_tenant_settings_request: + ~azure.mgmt.managementgroups.models.CreateOrUpdateSettingsRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: HierarchySettings, or the result of cls(response) :rtype: ~azure.mgmt.managementgroups.models.HierarchySettings :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HierarchySettings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_tenant_settings_request, 'CreateOrUpdateSettingsRequest') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.HierarchySettings] + + _json = self._serialize.body(create_tenant_settings_request, 'CreateOrUpdateSettingsRequest') + + request = build_update_request( + group_id=group_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -280,14 +476,16 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/settings/default'} # type: ignore - def delete( + update.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/settings/default"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - group_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + group_id: str, + **kwargs: Any + ) -> None: """Deletes the hierarchy settings defined at the Management Group level. :param group_id: Management Group ID. @@ -297,39 +495,42 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + group_id=group_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/settings/default'} # type: ignore + delete.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/settings/default"} # type: ignore + 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 00d4e9b4ef7f..2e7333548016 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,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,54 +6,208 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request( + group_id: str, + subscription_id: str, + *, + cache_control: Optional[str] = "no-cache", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # 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'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if cache_control is not None: + _headers['Cache-Control'] = _SERIALIZER.header("cache_control", cache_control, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + group_id: str, + subscription_id: str, + *, + cache_control: Optional[str] = "no-cache", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # 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'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if cache_control is not None: + _headers['Cache-Control'] = _SERIALIZER.header("cache_control", cache_control, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_subscription_request( + group_id: str, + subscription_id: str, + *, + cache_control: Optional[str] = "no-cache", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # 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'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if cache_control is not None: + _headers['Cache-Control'] = _SERIALIZER.header("cache_control", cache_control, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_subscriptions_under_management_group_request( + group_id: str, + *, + skiptoken: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions") + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skiptoken is not None: + _params['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ManagementGroupSubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ManagementGroupSubscriptionsOperations(object): - """ManagementGroupSubscriptionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.managementgroups.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.managementgroups.ManagementGroupsAPI`'s + :attr:`management_group_subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def create( self, - group_id, # type: str - subscription_id, # type: str - cache_control="no-cache", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.SubscriptionUnderManagementGroup" + group_id: str, + subscription_id: str, + cache_control: Optional[str] = "no-cache", + **kwargs: Any + ) -> _models.SubscriptionUnderManagementGroup: """Associates existing subscription with the management group. :param group_id: Management Group ID. @@ -60,46 +215,47 @@ def create( :param subscription_id: Subscription ID. :type subscription_id: str :param cache_control: Indicates whether the request should utilize any caches. Populate the - header with 'no-cache' value to bypass existing caches. + header with 'no-cache' value to bypass existing caches. Default value is "no-cache". :type cache_control: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionUnderManagementGroup, or the result of cls(response) :rtype: ~azure.mgmt.managementgroups.models.SubscriptionUnderManagementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionUnderManagementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if cache_control is not None: - header_parameters['Cache-Control'] = self._serialize.header("cache_control", cache_control, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionUnderManagementGroup] + + + request = build_create_request( + group_id=group_id, + subscription_id=subscription_id, + api_version=api_version, + cache_control=cache_control, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -108,16 +264,18 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}'} # type: ignore - def delete( + create.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - group_id, # type: str - subscription_id, # type: str - cache_control="no-cache", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + group_id: str, + subscription_id: str, + cache_control: Optional[str] = "no-cache", + **kwargs: Any + ) -> None: """De-associates subscription from the management group. :param group_id: Management Group ID. @@ -125,61 +283,63 @@ def delete( :param subscription_id: Subscription ID. :type subscription_id: str :param cache_control: Indicates whether the request should utilize any caches. Populate the - header with 'no-cache' value to bypass existing caches. + header with 'no-cache' value to bypass existing caches. Default value is "no-cache". :type cache_control: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if cache_control is not None: - header_parameters['Cache-Control'] = self._serialize.header("cache_control", cache_control, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + group_id=group_id, + subscription_id=subscription_id, + api_version=api_version, + cache_control=cache_control, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}'} # type: ignore + delete.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}"} # type: ignore + + @distributed_trace def get_subscription( self, - group_id, # type: str - subscription_id, # type: str - cache_control="no-cache", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.SubscriptionUnderManagementGroup" + group_id: str, + subscription_id: str, + cache_control: Optional[str] = "no-cache", + **kwargs: Any + ) -> _models.SubscriptionUnderManagementGroup: """Retrieves details about given subscription which is associated with the management group. :param group_id: Management Group ID. @@ -187,46 +347,47 @@ def get_subscription( :param subscription_id: Subscription ID. :type subscription_id: str :param cache_control: Indicates whether the request should utilize any caches. Populate the - header with 'no-cache' value to bypass existing caches. + header with 'no-cache' value to bypass existing caches. Default value is "no-cache". :type cache_control: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionUnderManagementGroup, or the result of cls(response) :rtype: ~azure.mgmt.managementgroups.models.SubscriptionUnderManagementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionUnderManagementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if cache_control is not None: - header_parameters['Cache-Control'] = self._serialize.header("cache_control", cache_control, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SubscriptionUnderManagementGroup] + + + request = build_get_subscription_request( + group_id=group_id, + subscription_id=subscription_id, + api_version=api_version, + cache_control=cache_control, + template_url=self.get_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -235,15 +396,17 @@ def get_subscription( return cls(pipeline_response, deserialized, {}) return deserialized - get_subscription.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}'} # type: ignore + get_subscription.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}"} # type: ignore + + + @distributed_trace def get_subscriptions_under_management_group( self, - group_id, # type: str - skiptoken=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ListSubscriptionUnderManagementGroup"] + group_id: str, + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.ListSubscriptionUnderManagementGroup]: """Retrieves details about all subscriptions which are associated with the management group. :param group_id: Management Group ID. @@ -251,48 +414,57 @@ def get_subscriptions_under_management_group( :param skiptoken: Page continuation token is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will - include a token parameter that specifies a starting point to use for subsequent calls. + include a token parameter that specifies a starting point to use for subsequent calls. Default + value is None. :type skiptoken: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListSubscriptionUnderManagementGroup or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.managementgroups.models.ListSubscriptionUnderManagementGroup] + :return: An iterator like instance of either ListSubscriptionUnderManagementGroup or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managementgroups.models.ListSubscriptionUnderManagementGroup] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListSubscriptionUnderManagementGroup"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListSubscriptionUnderManagementGroup] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_subscriptions_under_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_subscriptions_under_management_group_request( + group_id=group_id, + api_version=api_version, + skiptoken=skiptoken, + template_url=self.get_subscriptions_under_management_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_subscriptions_under_management_group_request( + group_id=group_id, + api_version=api_version, + skiptoken=skiptoken, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ListSubscriptionUnderManagementGroup', pipeline_response) + deserialized = self._deserialize("ListSubscriptionUnderManagementGroup", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -301,17 +473,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - get_subscriptions_under_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions'} # type: ignore + get_subscriptions_under_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions"} # type: ignore 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 eeded7040bc1..3365cec381e4 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,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,71 +6,167 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ManagementGroupsAPIOperationsMixin(object): - +from .._vendor import MixinABC, _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_check_name_availability_request( + *, + json: Optional[_models.CheckNameAvailabilityRequest] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/checkNameAvailability") + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_start_tenant_backfill_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/startTenantBackfill") + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_tenant_backfill_status_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/tenantBackfillStatus") + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ManagementGroupsAPIOperationsMixin(MixinABC): + + @distributed_trace def check_name_availability( self, - check_name_availability_request, # type: "_models.CheckNameAvailabilityRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.CheckNameAvailabilityResult" + check_name_availability_request: _models.CheckNameAvailabilityRequest, + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: """Checks if the specified management group name is valid and unique. :param check_name_availability_request: Management group name availability check parameters. - :type check_name_availability_request: ~azure.mgmt.managementgroups.models.CheckNameAvailabilityRequest + :type check_name_availability_request: + ~azure.mgmt.managementgroups.models.CheckNameAvailabilityRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckNameAvailabilityResult, or the result of cls(response) :rtype: ~azure.mgmt.managementgroups.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(check_name_availability_request, 'CheckNameAvailabilityRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + + _json = self._serialize.body(check_name_availability_request, 'CheckNameAvailabilityRequest') + + request = build_check_name_availability_request( + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -78,13 +175,15 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/providers/Microsoft.Management/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/providers/Microsoft.Management/checkNameAvailability"} # type: ignore + + + @distributed_trace def start_tenant_backfill( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.TenantBackfillStatusResult" + **kwargs: Any + ) -> _models.TenantBackfillStatusResult: """Starts backfilling subscriptions for the Tenant. :keyword callable cls: A custom type or function that will be passed the direct response @@ -92,32 +191,37 @@ def start_tenant_backfill( :rtype: ~azure.mgmt.managementgroups.models.TenantBackfillStatusResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantBackfillStatusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.start_tenant_backfill.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TenantBackfillStatusResult] + + + request = build_start_tenant_backfill_request( + api_version=api_version, + template_url=self.start_tenant_backfill.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -126,13 +230,15 @@ def start_tenant_backfill( return cls(pipeline_response, deserialized, {}) return deserialized - start_tenant_backfill.metadata = {'url': '/providers/Microsoft.Management/startTenantBackfill'} # type: ignore + start_tenant_backfill.metadata = {'url': "/providers/Microsoft.Management/startTenantBackfill"} # type: ignore + + + @distributed_trace def tenant_backfill_status( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.TenantBackfillStatusResult" + **kwargs: Any + ) -> _models.TenantBackfillStatusResult: """Gets tenant backfill status. :keyword callable cls: A custom type or function that will be passed the direct response @@ -140,32 +246,37 @@ def tenant_backfill_status( :rtype: ~azure.mgmt.managementgroups.models.TenantBackfillStatusResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TenantBackfillStatusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.tenant_backfill_status.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TenantBackfillStatusResult] + + + request = build_tenant_backfill_status_request( + api_version=api_version, + template_url=self.tenant_backfill_status.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -174,4 +285,6 @@ def tenant_backfill_status( return cls(pipeline_response, deserialized, {}) return deserialized - tenant_backfill_status.metadata = {'url': '/providers/Microsoft.Management/tenantBackfillStatus'} # type: ignore + + tenant_backfill_status.metadata = {'url': "/providers/Microsoft.Management/tenantBackfillStatus"} # type: ignore + 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 2302df2fd337..cfdeac539531 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,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,359 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._vendor import MixinABC, _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + *, + cache_control: Optional[str] = "no-cache", + skiptoken: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups") + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skiptoken is not None: + _params['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + + # Construct headers + if cache_control is not None: + _headers['Cache-Control'] = _SERIALIZER.header("cache_control", cache_control, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + group_id: str, + *, + expand: Optional[Union[str, "_models.ManagementGroupExpandType"]] = None, + recurse: Optional[bool] = None, + filter: Optional[str] = None, + cache_control: Optional[str] = "no-cache", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}") + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if recurse is not None: + _params['$recurse'] = _SERIALIZER.query("recurse", recurse, 'bool') + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + if cache_control is not None: + _headers['Cache-Control'] = _SERIALIZER.header("cache_control", cache_control, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request_initial( + group_id: str, + *, + json: Optional[_models.CreateManagementGroupRequest] = None, + content: Any = None, + cache_control: Optional[str] = "no-cache", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}") + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if cache_control is not None: + _headers['Cache-Control'] = _SERIALIZER.header("cache_control", cache_control, 'str') + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + group_id: str, + *, + json: Optional[_models.PatchManagementGroupRequest] = None, + content: Any = None, + cache_control: Optional[str] = "no-cache", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}") + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if cache_control is not None: + _headers['Cache-Control'] = _SERIALIZER.header("cache_control", cache_control, 'str') + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + group_id: str, + *, + cache_control: Optional[str] = "no-cache", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}") + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if cache_control is not None: + _headers['Cache-Control'] = _SERIALIZER.header("cache_control", cache_control, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_descendants_request( + group_id: str, + *, + skiptoken: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{groupId}/descendants") + path_format_arguments = { + "groupId": _SERIALIZER.url("group_id", group_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skiptoken is not None: + _params['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + if top is not None: + _params['$top'] = _SERIALIZER.query("top", top, 'int') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ManagementGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ManagementGroupsOperations(object): - """ManagementGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.managementgroups.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.managementgroups.ManagementGroupsAPI`'s + :attr:`management_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, - cache_control="no-cache", # type: Optional[str] - skiptoken=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagementGroupListResult"] + cache_control: Optional[str] = "no-cache", + skiptoken: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.ManagementGroupListResult]: """List management groups for the authenticated user. :param cache_control: Indicates whether the request should utilize any caches. Populate the - header with 'no-cache' value to bypass existing caches. + header with 'no-cache' value to bypass existing caches. Default value is "no-cache". :type cache_control: str :param skiptoken: Page continuation token is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will - include a token parameter that specifies a starting point to use for subsequent calls. + include a token parameter that specifies a starting point to use for subsequent calls. Default + value is None. :type skiptoken: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementGroupListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.managementgroups.models.ManagementGroupListResult] + :return: An iterator like instance of either ManagementGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managementgroups.models.ManagementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroupListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if cache_control is not None: - header_parameters['Cache-Control'] = self._serialize.header("cache_control", cache_control, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + cache_control=cache_control, + skiptoken=skiptoken, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + cache_control=cache_control, + skiptoken=skiptoken, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ManagementGroupListResult', pipeline_response) + deserialized = self._deserialize("ManagementGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,92 +367,96 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Management/managementGroups'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Management/managementGroups"} # type: ignore + @distributed_trace def get( self, - group_id, # type: str - expand=None, # type: Optional[Union[str, "_models.Enum0"]] - recurse=None, # type: Optional[bool] - filter=None, # type: Optional[str] - cache_control="no-cache", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagementGroup" + group_id: str, + expand: Optional[Union[str, "_models.ManagementGroupExpandType"]] = None, + recurse: Optional[bool] = None, + filter: Optional[str] = None, + cache_control: Optional[str] = "no-cache", + **kwargs: Any + ) -> _models.ManagementGroup: """Get the details of the management group. :param group_id: Management Group ID. :type group_id: str :param expand: The $expand=children query string parameter allows clients to request inclusion of children in the response payload. $expand=path includes the path from the root group to the - current group. $expand=ancestors includes the ancestor Ids of the current group. - :type expand: str or ~azure.mgmt.managementgroups.models.Enum0 + current group. $expand=ancestors includes the ancestor Ids of the current group. Default value + is None. + :type expand: str or ~azure.mgmt.managementgroups.models.ManagementGroupExpandType :param recurse: The $recurse=true query string parameter allows clients to request inclusion of entire hierarchy in the response payload. Note that $expand=children must be passed up if - $recurse is set to true. + $recurse is set to true. Default value is None. :type recurse: bool :param filter: A filter which allows the exclusion of subscriptions from results (i.e. - '$filter=children.childType ne Subscription'). + '$filter=children.childType ne Subscription'). Default value is None. :type filter: str :param cache_control: Indicates whether the request should utilize any caches. Populate the - header with 'no-cache' value to bypass existing caches. + header with 'no-cache' value to bypass existing caches. Default value is "no-cache". :type cache_control: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementGroup, or the result of cls(response) :rtype: ~azure.mgmt.managementgroups.models.ManagementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if recurse is not None: - query_parameters['$recurse'] = self._serialize.query("recurse", recurse, 'bool') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if cache_control is not None: - header_parameters['Cache-Control'] = self._serialize.header("cache_control", cache_control, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroup] + + + request = build_get_request( + group_id=group_id, + api_version=api_version, + expand=expand, + recurse=recurse, + filter=filter, + cache_control=cache_control, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -204,54 +465,54 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}'} # type: ignore + + get.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}"} # type: ignore + def _create_or_update_initial( self, - group_id, # type: str - create_management_group_request, # type: "_models.CreateManagementGroupRequest" - cache_control="no-cache", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Union["_models.ManagementGroup", "_models.AzureAsyncOperationResults"] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.ManagementGroup", "_models.AzureAsyncOperationResults"]] + group_id: str, + create_management_group_request: _models.CreateManagementGroupRequest, + cache_control: Optional[str] = "no-cache", + **kwargs: Any + ) -> Union[_models.ManagementGroup, _models.AzureAsyncOperationResults]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if cache_control is not None: - header_parameters['Cache-Control'] = self._serialize.header("cache_control", cache_control, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_management_group_request, 'CreateManagementGroupRequest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Union[_models.ManagementGroup, _models.AzureAsyncOperationResults]] + + _json = self._serialize.body(create_management_group_request, 'CreateManagementGroupRequest') + + request = build_create_or_update_request_initial( + group_id=group_id, + api_version=api_version, + content_type=content_type, + json=_json, + cache_control=cache_control, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 200: @@ -260,22 +521,25 @@ def _create_or_update_initial( if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + deserialized = self._deserialize('AzureAsyncOperationResults', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}"} # type: ignore + + + @distributed_trace def begin_create_or_update( self, - group_id, # type: str - create_management_group_request, # type: "_models.CreateManagementGroupRequest" - cache_control="no-cache", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[Union["_models.ManagementGroup", "_models.AzureAsyncOperationResults"]] + group_id: str, + create_management_group_request: _models.CreateManagementGroupRequest, + cache_control: Optional[str] = "no-cache", + **kwargs: Any + ) -> LROPoller[Union[_models.ManagementGroup, _models.AzureAsyncOperationResults]]: """Create or update a management group. If a management group is already created and a subsequent create request is issued with different properties, the management group properties will be updated. @@ -283,52 +547,66 @@ def begin_create_or_update( :param group_id: Management Group ID. :type group_id: str :param create_management_group_request: Management group creation parameters. - :type create_management_group_request: ~azure.mgmt.managementgroups.models.CreateManagementGroupRequest + :type create_management_group_request: + ~azure.mgmt.managementgroups.models.CreateManagementGroupRequest :param cache_control: Indicates whether the request should utilize any caches. Populate the - header with 'no-cache' value to bypass existing caches. + header with 'no-cache' value to bypass existing caches. Default value is "no-cache". :type cache_control: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ManagementGroup or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managementgroups.models.ManagementGroup] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ManagementGroup or + AzureAsyncOperationResults or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managementgroups.models.ManagementGroup or + ~azure.mgmt.managementgroups.models.AzureAsyncOperationResults] + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Union[_models.ManagementGroup, _models.AzureAsyncOperationResults]] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.ManagementGroup", "_models.AzureAsyncOperationResults"]] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore group_id=group_id, create_management_group_request=create_management_group_request, cache_control=cache_control, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('ManagementGroup', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -337,18 +615,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}"} # type: ignore + @distributed_trace def update( self, - group_id, # type: str - patch_group_request, # type: "_models.PatchManagementGroupRequest" - cache_control="no-cache", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagementGroup" + group_id: str, + patch_group_request: _models.PatchManagementGroupRequest, + cache_control: Optional[str] = "no-cache", + **kwargs: Any + ) -> _models.ManagementGroup: """Update a management group. :param group_id: Management Group ID. @@ -356,50 +634,50 @@ def update( :param patch_group_request: Management group patch parameters. :type patch_group_request: ~azure.mgmt.managementgroups.models.PatchManagementGroupRequest :param cache_control: Indicates whether the request should utilize any caches. Populate the - header with 'no-cache' value to bypass existing caches. + header with 'no-cache' value to bypass existing caches. Default value is "no-cache". :type cache_control: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementGroup, or the result of cls(response) :rtype: ~azure.mgmt.managementgroups.models.ManagementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if cache_control is not None: - header_parameters['Cache-Control'] = self._serialize.header("cache_control", cache_control, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(patch_group_request, 'PatchManagementGroupRequest') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementGroup] + + _json = self._serialize.body(patch_group_request, 'PatchManagementGroupRequest') + + request = build_update_request( + group_id=group_id, + api_version=api_version, + content_type=content_type, + json=_json, + cache_control=cache_control, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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) @@ -408,122 +686,138 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}'} # type: ignore + + update.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}"} # type: ignore + def _delete_initial( self, - group_id, # type: str - cache_control="no-cache", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.AzureAsyncOperationResults"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AzureAsyncOperationResults"]] + group_id: str, + cache_control: Optional[str] = "no-cache", + **kwargs: Any + ) -> Optional[_models.AzureAsyncOperationResults]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if cache_control is not None: - header_parameters['Cache-Control'] = self._serialize.header("cache_control", cache_control, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.AzureAsyncOperationResults]] + + + request = build_delete_request_initial( + group_id=group_id, + api_version=api_version, + cache_control=cache_control, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + deserialized = self._deserialize('AzureAsyncOperationResults', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _delete_initial.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}'} # type: ignore + _delete_initial.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}"} # type: ignore + + + @distributed_trace def begin_delete( self, - group_id, # type: str - cache_control="no-cache", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.AzureAsyncOperationResults"] + group_id: str, + cache_control: Optional[str] = "no-cache", + **kwargs: Any + ) -> LROPoller[_models.AzureAsyncOperationResults]: """Delete management group. If a management group contains child resources, the request will fail. :param group_id: Management Group ID. :type group_id: str :param cache_control: Indicates whether the request should utilize any caches. Populate the - header with 'no-cache' value to bypass existing caches. + header with 'no-cache' value to bypass existing caches. Default value is "no-cache". :type cache_control: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either AzureAsyncOperationResults or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managementgroups.models.AzureAsyncOperationResults] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AzureAsyncOperationResults or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managementgroups.models.AzureAsyncOperationResults] + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AzureAsyncOperationResults] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureAsyncOperationResults"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore group_id=group_id, cache_control=cache_control, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + deserialized = self._deserialize('AzureAsyncOperationResults', pipeline_response) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -532,18 +826,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}"} # type: ignore + @distributed_trace def get_descendants( self, - group_id, # type: str - skiptoken=None, # type: Optional[str] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DescendantListResult"] + group_id: str, + skiptoken: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable[_models.DescendantListResult]: """List all entities that descend from a management group. :param group_id: Management Group ID. @@ -551,53 +845,61 @@ def get_descendants( :param skiptoken: Page continuation token is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will - include a token parameter that specifies a starting point to use for subsequent calls. + include a token parameter that specifies a starting point to use for subsequent calls. Default + value is None. :type skiptoken: str :param top: Number of elements to return when retrieving results. Passing this in will override - $skipToken. + $skipToken. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DescendantListResult or the result of cls(response) + :return: An iterator like instance of either DescendantListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.managementgroups.models.DescendantListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DescendantListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DescendantListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_descendants.metadata['url'] # type: ignore - path_format_arguments = { - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_descendants_request( + group_id=group_id, + api_version=api_version, + skiptoken=skiptoken, + top=top, + template_url=self.get_descendants.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_descendants_request( + group_id=group_id, + api_version=api_version, + skiptoken=skiptoken, + top=top, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DescendantListResult', pipeline_response) + deserialized = self._deserialize("DescendantListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -606,17 +908,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - get_descendants.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/descendants'} # type: ignore + get_descendants.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{groupId}/descendants"} # type: ignore 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 13bf9a70bc0c..da865cbaca5a 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,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,51 +6,78 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import MixinABC, _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/operations") -class Operations(object): - """Operations operations. + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.managementgroups.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.managementgroups.ManagementGroupsAPI`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable[_models.OperationListResult]: """Lists all of the available Management REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -57,35 +85,43 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.managementgroups.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,17 +130,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Management/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Management/operations"} # type: ignore diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_patch.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """