diff --git a/sdk/managementgroups/azure-mgmt-managementgroups/_meta.json b/sdk/managementgroups/azure-mgmt-managementgroups/_meta.json index dd31d1077c15..2376f8aa459a 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.12.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "e5bdbb00cf31e34dfaffe74432b80a110f86e06a", + "commit": "524ca84e56312adce52c62004b9a463e277d6da2", "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 --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.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..0ffe29071795 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/__init__.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ManagementGroupsAPI'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..079e53d01db9 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_configuration.py +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_configuration.py @@ -6,18 +6,16 @@ # 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 @@ -33,13 +31,12 @@ class ManagementGroupsAPIConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + **kwargs: Any + ) -> None: + super(ManagementGroupsAPIConfiguration, self).__init__(**kwargs) 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" @@ -62,4 +59,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..ebcbb7644bf8 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,27 +6,20 @@ # 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, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +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 typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -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 - class ManagementGroupsAPI(ManagementGroupsAPIOperationsMixin): """The Azure Management Groups API enables consolidation of multiple @@ -36,7 +29,8 @@ class ManagementGroupsAPI(ManagementGroupsAPIOperationsMixin): :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 +39,57 @@ 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 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.management_group_subscriptions = ManagementGroupSubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.hierarchy_settings = HierarchySettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.entities = EntitiesOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_groups = ManagementGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.management_group_subscriptions = ManagementGroupSubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.hierarchy_settings = HierarchySettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.entities = EntitiesOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + + def _send_request( + self, + request, # type: 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 index 33210bd110be..781489662105 100644 --- a/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_metadata.json +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_metadata.json @@ -5,13 +5,13 @@ "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, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": 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\"]}}}" + "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\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"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\"]}}}" }, "global_parameters": { "sync": { @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -62,7 +62,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -79,11 +79,10 @@ "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\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"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\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "management_groups": "ManagementGroupsOperations", @@ -93,24 +92,24 @@ "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\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", "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\"\"\"" + "signature": "def check_name_availability(\n self,\n check_name_availability_request, # type: \"_models.CheckNameAvailabilityRequest\"\n **kwargs # type: Any\n):\n # type: (...) -\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:\n ~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\"\"\"" + "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:\n ~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", + "signature": "def start_tenant_backfill(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\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\"\"\"" }, "async": { @@ -122,7 +121,7 @@ }, "tenant_backfill_status" : { "sync": { - "signature": "def tenant_backfill_status(\n self,\n **kwargs # type: Any\n):\n", + "signature": "def tenant_backfill_status(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\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\"\"\"" }, "async": { 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..74e48ecd07cf --- /dev/null +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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..138f663c53a4 --- /dev/null +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/_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 azure.core.pipeline.transport import HttpRequest + +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) 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..fe0d5a0b414c 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 = "2019-05-01T00:00:00.000Z" 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..c73ccd73a8ca 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 @@ -8,3 +8,8 @@ from ._management_groups_api import ManagementGroupsAPI __all__ = ['ManagementGroupsAPI'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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..cc2efc757d9b 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 @@ -34,9 +34,9 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(ManagementGroupsAPIConfiguration, self).__init__(**kwargs) 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" @@ -58,4 +58,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..13e296d595f8 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,92 @@ # 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, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +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 -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 - - 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. :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 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.management_group_subscriptions = ManagementGroupSubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.hierarchy_settings = HierarchySettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.entities = EntitiesOperations(self._client, self._config, self._serialize, self._deserialize) + - self.management_groups = ManagementGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.management_group_subscriptions = ManagementGroupSubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.hierarchy_settings = HierarchySettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.entities = EntitiesOperations( - 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..74e48ecd07cf --- /dev/null +++ b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ 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..b981c5e8699b 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._entities_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,15 +46,16 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @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 @@ -86,7 +92,7 @@ def list( 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 + :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, @@ -95,7 +101,7 @@ def list( :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 + :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'"). :type group_name: str @@ -104,7 +110,8 @@ def list( :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"] @@ -112,48 +119,45 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - 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( + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -166,12 +170,13 @@ async def get_next(next_link=None): 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 ) 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..42096f697b1f 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, group_id: str, @@ -60,31 +65,21 @@ async def list( 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') + + request = build_list_request( + group_id=group_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) 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,8 +88,11 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/settings'} # type: ignore + + @distributed_trace_async async def get( self, group_id: str, @@ -115,31 +113,21 @@ async def get( 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 = build_get_request( + group_id=group_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +136,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/settings/default'} # type: ignore + + @distributed_trace_async async def create_or_update( self, group_id: str, @@ -161,7 +152,8 @@ async def create_or_update( :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 @@ -172,36 +164,26 @@ async def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(create_tenant_settings_request, 'CreateOrUpdateSettingsRequest') + + request = build_create_or_update_request( + group_id=group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,8 +192,11 @@ 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 + + @distributed_trace_async async def update( self, group_id: str, @@ -223,7 +208,8 @@ async def update( :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 @@ -234,36 +220,26 @@ async def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(create_tenant_settings_request, 'CreateOrUpdateSettingsRequest') - # 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') + request = build_update_request( + group_id=group_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,8 +248,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/settings/default'} # type: ignore + + @distributed_trace_async async def delete( self, group_id: str, @@ -293,34 +272,25 @@ async def delete( 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) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + group_id=group_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 + 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..90ae022e2867 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create( self, group_id: str, @@ -67,34 +73,23 @@ async def create( 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') + + request = build_create_request( + group_id=group_id, + subscription_id=subscription_id, + cache_control=cache_control, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +98,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}'} # type: ignore + + @distributed_trace_async async def delete( self, group_id: str, @@ -131,34 +129,23 @@ async def delete( 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) - - # 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') + + request = build_delete_request( + group_id=group_id, + subscription_id=subscription_id, + cache_control=cache_control, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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: @@ -166,6 +153,8 @@ async def delete( delete.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}'} # type: ignore + + @distributed_trace_async async def get_subscription( self, group_id: str, @@ -192,34 +181,23 @@ async def get_subscription( 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') + + request = build_get_subscription_request( + group_id=group_id, + subscription_id=subscription_id, + cache_control=cache_control, + template_url=self.get_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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,8 +206,11 @@ async def get_subscription( return cls(pipeline_response, deserialized, {}) return deserialized + 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, @@ -246,8 +227,10 @@ def get_subscriptions_under_management_group( include a token parameter that specifies a starting point to use for subsequent calls. :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"] @@ -255,36 +238,31 @@ def get_subscriptions_under_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - 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, + skiptoken=skiptoken, + template_url=self.get_subscriptions_under_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + skiptoken=skiptoken, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -297,12 +275,13 @@ async def get_next(next_link=None): 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 ) 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..6bbbb2723917 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 @@ -5,21 +5,26 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ManagementGroupsAPIOperationsMixin: + @distributed_trace_async async def check_name_availability( self, check_name_availability_request: "_models.CheckNameAvailabilityRequest", @@ -28,7 +33,8 @@ async def check_name_availability( """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 @@ -39,32 +45,25 @@ async def check_name_availability( 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) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(check_name_availability_request, 'CheckNameAvailabilityRequest') + + request = build_check_name_availability_request( + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(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,8 +72,11 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/providers/Microsoft.Management/checkNameAvailability'} # type: ignore + + @distributed_trace_async async def start_tenant_backfill( self, **kwargs: Any @@ -91,27 +93,20 @@ async def start_tenant_backfill( 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') + + request = build_start_tenant_backfill_request( + template_url=self.start_tenant_backfill.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) 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,8 +115,11 @@ async def start_tenant_backfill( return cls(pipeline_response, deserialized, {}) return deserialized + start_tenant_backfill.metadata = {'url': '/providers/Microsoft.Management/startTenantBackfill'} # type: ignore + + @distributed_trace_async async def tenant_backfill_status( self, **kwargs: Any @@ -138,27 +136,20 @@ async def tenant_backfill_status( 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') + + request = build_tenant_backfill_status_request( + template_url=self.tenant_backfill_status.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) 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 +158,6 @@ async def tenant_backfill_status( return cls(pipeline_response, deserialized, {}) return deserialized + 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..828e48880222 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 @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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.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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, cache_control: Optional[str] = "no-cache", @@ -60,8 +66,10 @@ def list( include a token parameter that specifies a starting point to use for subsequent calls. :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"] @@ -69,34 +77,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - 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( + cache_control=cache_control, + skiptoken=skiptoken, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + cache_control=cache_control, + skiptoken=skiptoken, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -109,21 +114,23 @@ async def get_next(next_link=None): 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 + @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", @@ -136,7 +143,7 @@ async def get( :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 + :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. @@ -157,39 +164,25 @@ async def get( 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) + + request = build_get_request( + group_id=group_id, + expand=expand, + recurse=recurse, + filter=filter, + cache_control=cache_control, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(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,8 +191,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}'} # type: ignore + async def _create_or_update_initial( self, group_id: str, @@ -212,39 +207,27 @@ async def _create_or_update_initial( 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) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(create_management_group_request, 'CreateManagementGroupRequest') + + request = build_create_or_update_request_initial( + group_id=group_id, + content_type=content_type, + json=_json, + cache_control=cache_control, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(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,14 +236,18 @@ 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 + + @distributed_trace_async async def begin_create_or_update( self, group_id: str, @@ -275,21 +262,27 @@ 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. :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.ManagementGroup", "_models.AzureAsyncOperationResults"]] lro_delay = kwargs.pop( 'polling_interval', @@ -301,25 +294,21 @@ async def begin_create_or_update( group_id=group_id, create_management_group_request=create_management_group_request, cache_control=cache_control, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_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) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -331,8 +320,10 @@ def get_long_running_output(pipeline_response): ) 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 + @distributed_trace_async async def update( self, group_id: str, @@ -359,38 +350,27 @@ async def update( 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) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(patch_group_request, 'PatchManagementGroupRequest') + + request = build_update_request( + group_id=group_id, + content_type=content_type, + json=_json, + cache_control=cache_control, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(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,8 +379,10 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}'} # type: ignore + async def _delete_initial( self, group_id: str, @@ -412,48 +394,40 @@ async def _delete_initial( 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') + + request = build_delete_request_initial( + group_id=group_id, + cache_control=cache_control, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(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 + + @distributed_trace_async async def begin_delete( self, group_id: str, @@ -470,15 +444,19 @@ async def begin_delete( :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureAsyncOperationResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -492,26 +470,21 @@ async def begin_delete( cls=lambda x,y,z: x, **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) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -523,8 +496,10 @@ def get_long_running_output(pipeline_response): ) else: 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, @@ -545,8 +520,10 @@ def get_descendants( $skipToken. :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"] @@ -554,38 +531,33 @@ def get_descendants( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - 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, + skiptoken=skiptoken, + top=top, + template_url=self.get_descendants.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + skiptoken=skiptoken, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -598,12 +570,13 @@ async def get_next(next_link=None): 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 ) 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..93b4c319e756 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - 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( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -93,12 +97,13 @@ async def get_next(next_link=None): 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 ) 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..bf492f4e16af 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,84 +6,48 @@ # 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, @@ -125,10 +89,10 @@ 'PatchManagementGroupRequest', 'SubscriptionUnderManagementGroup', 'TenantBackfillStatusResult', - 'Enum0', - 'Enum2', - 'Enum3', + 'EntitySearchType', + 'EntityViewParameterType', 'ManagementGroupChildType', + 'ManagementGroupExpandType', 'Permissions', 'Reason', 'Status', 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..aa287ccae6bb 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,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +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(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ALLOWED_PARENTS = "AllowedParents" ALLOWED_CHILDREN = "AllowedChildren" @@ -40,21 +19,27 @@ class Enum2(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PARENT_ONLY = "ParentOnly" CHILDREN_ONLY = "ChildrenOnly" -class Enum3(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EntityViewParameterType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FULL_HIERARCHY = "FullHierarchy" GROUPS_ONLY = "GroupsOnly" SUBSCRIPTIONS_ONLY = "SubscriptionsOnly" AUDIT = "Audit" -class ManagementGroupChildType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagementGroupChildType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of child resource. """ MICROSOFT_MANAGEMENT_MANAGEMENT_GROUPS = "Microsoft.Management/managementGroups" _SUBSCRIPTIONS = "/subscriptions" -class Permissions(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagementGroupExpandType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + + CHILDREN = "children" + PATH = "path" + ANCESTORS = "ancestors" + +class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The users specific permissions to this item. """ @@ -63,7 +48,7 @@ class Permissions(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): EDIT = "edit" DELETE = "delete" -class Reason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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 +57,7 @@ class Reason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class Status(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Status(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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..32536a9b4b1d 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 @@ -31,11 +31,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 +61,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 +80,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): @@ -139,6 +149,8 @@ def __init__( self, **kwargs ): + """ + """ super(CheckNameAvailabilityResult, self).__init__(**kwargs) self.name_available = None self.reason = None @@ -186,6 +198,8 @@ def __init__( self, **kwargs ): + """ + """ super(CreateManagementGroupChildInfo, self).__init__(**kwargs) self.type = None self.id = None @@ -205,8 +219,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 = { @@ -228,6 +242,10 @@ def __init__( parent: Optional["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 +263,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] """ @@ -285,6 +303,16 @@ def __init__( details: Optional["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 +326,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 +350,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 +372,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 +398,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 +423,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 = { @@ -405,6 +450,12 @@ def __init__( parent: Optional["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 +469,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 """ @@ -439,6 +490,10 @@ def __init__( value: Optional[List["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 +502,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 +517,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 +539,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: + :ivar display_name: The friendly name of the management group. + :vartype display_name: str + :ivar 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] + :vartype permissions: str or ~azure.mgmt.managementgroups.models.Permissions + :ivar children: The list of children. + :vartype children: list[~azure.mgmt.managementgroups.models.EntityHierarchyItem] """ _validation = { @@ -511,6 +571,15 @@ def __init__( children: Optional[List["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. Possible values include: + "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 +601,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. 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 + :vartype permissions: str or ~azure.mgmt.managementgroups.models.Permissions + :ivar 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 = { @@ -597,6 +666,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. Possible values include: + "noaccess", "view", "edit", "delete". + :paramtype permissions: str or ~azure.mgmt.managementgroups.models.Permissions + :keyword inherited_permissions: The users specific permissions to this item. Possible values + include: "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 +715,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. @@ -643,6 +740,10 @@ def __init__( value: Optional[List["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 +753,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 +768,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 +780,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 +802,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 +819,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 = { @@ -719,6 +833,10 @@ def __init__( error: Optional["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 +854,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 +892,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 +929,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 +967,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 +996,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 """ @@ -869,6 +1017,10 @@ def __init__( value: Optional[List["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 +1031,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 """ @@ -900,6 +1052,10 @@ def __init__( value: Optional[List["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 +1074,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 = { @@ -954,6 +1110,17 @@ def __init__( children: Optional[List["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 +1134,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. + :ivar 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). + :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 = { @@ -1001,6 +1168,22 @@ def __init__( children: Optional[List["ManagementGroupChildInfo"]] = None, **kwargs ): + """ + :keyword type: The fully qualified resource type which includes provider namespace (e.g. + Microsoft.Management/managementGroups). Possible values include: + "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 +1195,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] """ @@ -1052,6 +1235,24 @@ def __init__( management_group_ancestors_chain: Optional[List["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 +1276,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 +1304,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 +1324,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 """ @@ -1137,6 +1345,10 @@ def __init__( value: Optional[List["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 +1357,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 +1375,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 +1393,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 = { @@ -1194,6 +1412,10 @@ def __init__( display: Optional["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 +1454,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplayProperties, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1264,6 +1488,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1282,11 +1508,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 +1536,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 +1554,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 +1577,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 +1595,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 +1614,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 +1641,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 = { @@ -1427,6 +1677,17 @@ def __init__( 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 @@ -1464,6 +1725,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/operations/_entities_operations.py b/sdk/managementgroups/azure-mgmt-managementgroups/azure/mgmt/managementgroups/operations/_entities_operations.py index 282767c9130e..be2b360e62bb 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 @@ -5,23 +5,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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _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: + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/getEntities') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + if skip is not None: + query_parameters['$skip'] = _SERIALIZER.query("skip", skip, 'int') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if select is not None: + query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + if search is not None: + query_parameters['$search'] = _SERIALIZER.query("search", search, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if view is not None: + query_parameters['$view'] = _SERIALIZER.query("view", view, 'str') + if group_name is not None: + query_parameters['groupName'] = _SERIALIZER.query("group_name", group_name, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if cache_control is not None: + header_parameters['Cache-Control'] = _SERIALIZER.header("cache_control", cache_control, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class EntitiesOperations(object): """EntitiesOperations operations. @@ -45,20 +100,20 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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 @@ -91,7 +146,7 @@ def list( 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 + :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, @@ -100,7 +155,7 @@ def list( :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 + :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'"). :type group_name: str @@ -117,48 +172,45 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - 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( + 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'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + 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, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -171,12 +223,13 @@ def get_next(next_link=None): 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 ) 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..ddf6e1020595 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 @@ -5,22 +5,198 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer 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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2021-04-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + group_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-04-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + group_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + group_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + group_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-04-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class HierarchySettingsOperations(object): """HierarchySettingsOperations operations. @@ -44,12 +220,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -65,31 +241,21 @@ def list( 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 = build_list_request( + group_id=group_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +264,16 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -121,31 +289,21 @@ def get( 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') + + request = build_get_request( + group_id=group_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) 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,21 +312,24 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + 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 @@ -179,36 +340,26 @@ def create_or_update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(create_tenant_settings_request, 'CreateOrUpdateSettingsRequest') - # 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') + request = build_create_or_update_request( + group_id=group_id, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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,21 +368,24 @@ 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 + + @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 @@ -242,36 +396,26 @@ def update( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(create_tenant_settings_request, 'CreateOrUpdateSettingsRequest') - # 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') + request = build_update_request( + group_id=group_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) 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 +424,16 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/settings/default'} # type: ignore + + @distributed_trace def delete( 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. @@ -302,34 +448,25 @@ def delete( 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) - - # 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 = build_delete_request( + group_id=group_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 + 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..22200b6079fd 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 @@ -5,23 +5,171 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _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: + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if cache_control is not None: + header_parameters['Cache-Control'] = _SERIALIZER.header("cache_control", cache_control, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + group_id: str, + subscription_id: str, + *, + cache_control: Optional[str] = "no-cache", + **kwargs: Any +) -> HttpRequest: + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if cache_control is not None: + header_parameters['Cache-Control'] = _SERIALIZER.header("cache_control", cache_control, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_subscription_request( + group_id: str, + subscription_id: str, + *, + cache_control: Optional[str] = "no-cache", + **kwargs: Any +) -> HttpRequest: + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}') + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if cache_control is not None: + header_parameters['Cache-Control'] = _SERIALIZER.header("cache_control", cache_control, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_subscriptions_under_management_group_request( + group_id: str, + *, + skiptoken: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-04-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagementGroupSubscriptionsOperations(object): """ManagementGroupSubscriptionsOperations operations. @@ -45,14 +193,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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. @@ -72,34 +220,23 @@ def create( 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') + + request = build_create_request( + group_id=group_id, + subscription_id=subscription_id, + cache_control=cache_control, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +245,18 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}'} # type: ignore + + @distributed_trace def delete( 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. @@ -137,34 +276,23 @@ def delete( 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) - # 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') + + request = build_delete_request( + group_id=group_id, + subscription_id=subscription_id, + cache_control=cache_control, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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: @@ -172,14 +300,15 @@ def delete( 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. @@ -199,34 +328,23 @@ def get_subscription( 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') + + request = build_get_subscription_request( + group_id=group_id, + subscription_id=subscription_id, + cache_control=cache_control, + template_url=self.get_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 +353,17 @@ def get_subscription( return cls(pipeline_response, deserialized, {}) return deserialized + 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. @@ -254,8 +374,10 @@ def get_subscriptions_under_management_group( include a token parameter that specifies a starting point to use for subsequent calls. :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"] @@ -263,36 +385,31 @@ def get_subscriptions_under_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - 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, + skiptoken=skiptoken, + template_url=self.get_subscriptions_under_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + skiptoken=skiptoken, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -305,12 +422,13 @@ def get_next(next_link=None): 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 ) 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..79babb8238cf 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 @@ -5,35 +5,123 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer 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]] +from .._vendor import _convert_request +T = TypeVar('T') +JSONType = Any +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: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/checkNameAvailability') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_start_tenant_backfill_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/startTenantBackfill') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_tenant_backfill_status_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/tenantBackfillStatus') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagementGroupsAPIOperationsMixin(object): + @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 @@ -44,32 +132,25 @@ def check_name_availability( 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) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(check_name_availability_request, 'CheckNameAvailabilityRequest') + + request = build_check_name_availability_request( + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(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 +159,15 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + 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 @@ -97,27 +180,20 @@ def start_tenant_backfill( 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 + + request = build_start_tenant_backfill_request( + template_url=self.start_tenant_backfill.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) 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 +202,15 @@ def start_tenant_backfill( return cls(pipeline_response, deserialized, {}) return deserialized + 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 @@ -145,27 +223,20 @@ def tenant_backfill_status( 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 + + request = build_tenant_backfill_status_request( + template_url=self.tenant_backfill_status.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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) 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 +245,6 @@ def tenant_backfill_status( return cls(pipeline_response, deserialized, {}) return deserialized + 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..e0ca8cdc88fe 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 @@ -5,25 +5,263 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings 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.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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: + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if cache_control is not None: + header_parameters['Cache-Control'] = _SERIALIZER.header("cache_control", cache_control, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **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: + api_version = "2021-04-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if recurse is not None: + query_parameters['$recurse'] = _SERIALIZER.query("recurse", recurse, 'bool') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if cache_control is not None: + header_parameters['Cache-Control'] = _SERIALIZER.header("cache_control", cache_control, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + group_id: str, + *, + json: JSONType = None, + content: Any = None, + cache_control: Optional[str] = "no-cache", + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if cache_control is not None: + header_parameters['Cache-Control'] = _SERIALIZER.header("cache_control", cache_control, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + group_id: str, + *, + json: JSONType = None, + content: Any = None, + cache_control: Optional[str] = "no-cache", + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if cache_control is not None: + header_parameters['Cache-Control'] = _SERIALIZER.header("cache_control", cache_control, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + group_id: str, + *, + cache_control: Optional[str] = "no-cache", + **kwargs: Any +) -> HttpRequest: + api_version = "2021-04-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if cache_control is not None: + header_parameters['Cache-Control'] = _SERIALIZER.header("cache_control", cache_control, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_descendants_request( + group_id: str, + *, + skiptoken: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-04-01" + 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 + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ManagementGroupsOperations(object): """ManagementGroupsOperations operations. @@ -47,13 +285,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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 @@ -65,8 +303,10 @@ def list( include a token parameter that specifies a starting point to use for subsequent calls. :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"] @@ -74,34 +314,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - 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( + cache_control=cache_control, + skiptoken=skiptoken, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + cache_control=cache_control, + skiptoken=skiptoken, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -114,27 +351,28 @@ def get_next(next_link=None): 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 + @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. @@ -142,7 +380,7 @@ def get( :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 + :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. @@ -163,39 +401,25 @@ def get( 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) + + request = build_get_request( + group_id=group_id, + expand=expand, + recurse=recurse, + filter=filter, + cache_control=cache_control, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(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 +428,43 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + 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"] + group_id: str, + 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"]] 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) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(create_management_group_request, 'CreateManagementGroupRequest') + + request = build_create_or_update_request_initial( + group_id=group_id, + content_type=content_type, + json=_json, + cache_control=cache_control, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(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 +473,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 + + @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,21 +499,27 @@ 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. :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.ManagementGroup", "_models.AzureAsyncOperationResults"]] lro_delay = kwargs.pop( 'polling_interval', @@ -309,25 +531,21 @@ def begin_create_or_update( group_id=group_id, create_management_group_request=create_management_group_request, cache_control=cache_control, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_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) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -339,16 +557,17 @@ def get_long_running_output(pipeline_response): ) 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 + @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. @@ -368,38 +587,27 @@ def update( 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) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(patch_group_request, 'PatchManagementGroupRequest') + + request = build_update_request( + group_id=group_id, + content_type=content_type, + json=_json, + cache_control=cache_control, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(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,69 +616,61 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + 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"] + group_id: str, + cache_control: Optional[str] = "no-cache", + **kwargs: Any + ) -> Optional["_models.AzureAsyncOperationResults"]: cls = kwargs.pop('cls', None) # type: ClsType[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') + + request = build_delete_request_initial( + group_id=group_id, + cache_control=cache_control, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(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 + + @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. @@ -481,15 +681,19 @@ def begin_delete( :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 """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureAsyncOperationResults"] lro_delay = kwargs.pop( 'polling_interval', @@ -503,26 +707,21 @@ def begin_delete( cls=lambda x,y,z: x, **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) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -534,16 +733,17 @@ def get_long_running_output(pipeline_response): ) else: 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. @@ -557,7 +757,8 @@ def get_descendants( $skipToken. :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 """ @@ -566,38 +767,33 @@ def get_descendants( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - 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, + skiptoken=skiptoken, + top=top, + template_url=self.get_descendants.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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, + skiptoken=skiptoken, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -610,12 +806,13 @@ def get_next(next_link=None): 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 ) 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..43279205ad92 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 @@ -5,23 +5,50 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings 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.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -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]] +from .._vendor import _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: + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @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 @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - 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( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) @@ -98,12 +122,13 @@ def get_next(next_link=None): 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 )