From 076414cbf904a4f3df7a3a8e5385a8f9b0d7fdf6 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 10 Jan 2022 23:15:18 +0000 Subject: [PATCH] CodeGen from PR 17089 in Azure/azure-rest-api-specs Merge 992b6f571d1069b5b4b283e70a5c1e2367c288c5 into 5e455f9123f2c0c7fe22f3e43e0402ae8cf8e807 --- .../azure-mgmt-managedservices/_meta.json | 11 +- .../azure/mgmt/managedservices/__init__.py | 9 +- .../mgmt/managedservices/_configuration.py | 19 +- .../_managed_services_client.py | 115 +-- .../azure/mgmt/managedservices/_metadata.json | 30 +- .../azure/mgmt/managedservices/_patch.py | 31 + .../azure/mgmt/managedservices/_vendor.py | 27 + .../azure/mgmt/managedservices/_version.py | 2 +- .../mgmt/managedservices/aio/__init__.py | 5 + .../managedservices/aio/_configuration.py | 8 +- .../aio/_managed_services_client.py | 105 +-- .../azure/mgmt/managedservices/aio/_patch.py | 31 + .../aio/operations/__init__.py | 2 + ...ace_registration_definitions_operations.py | 106 ++- ...on_definitions_without_scope_operations.py | 94 ++- .../aio/operations/_operations.py | 34 +- .../_operations_with_scope_operations.py | 92 +++ .../_registration_assignments_operations.py | 260 +++--- .../_registration_definitions_operations.py | 221 +++-- .../mgmt/managedservices/models/__init__.py | 67 +- .../models/_managed_services_client_enums.py | 27 +- .../mgmt/managedservices/models/_models.py | 772 ------------------ .../managedservices/models/_models_py3.py | 646 +++++++++++---- .../managedservices/operations/__init__.py | 2 + ...ace_registration_definitions_operations.py | 199 +++-- ...on_definitions_without_scope_operations.py | 175 ++-- .../managedservices/operations/_operations.py | 74 +- .../_operations_with_scope_operations.py | 125 +++ .../_registration_assignments_operations.py | 472 +++++++---- .../_registration_definitions_operations.py | 413 ++++++---- 30 files changed, 2182 insertions(+), 1992 deletions(-) create mode 100644 sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_patch.py create mode 100644 sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_vendor.py create mode 100644 sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/_patch.py create mode 100644 sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_operations_with_scope_operations.py delete mode 100644 sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/models/_models.py create mode 100644 sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_operations_with_scope_operations.py diff --git a/sdk/managedservices/azure-mgmt-managedservices/_meta.json b/sdk/managedservices/azure-mgmt-managedservices/_meta.json index 54ee6fe946b4..2b12c5bff79c 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/_meta.json +++ b/sdk/managedservices/azure-mgmt-managedservices/_meta.json @@ -1,8 +1,11 @@ { - "autorest": "3.3.0", - "use": "@autorest/python@5.6.6", - "commit": "528c0cffd4de3d4acdf451a1ea5f7cf6f3cb790c", + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "e22e26d9e369486b2d5da395d10f06b860da1241", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/managedservices/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.6.6 --version=3.3.0", + "autorest_command": "autorest specification/managedservices/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/managedservices/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/__init__.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/__init__.py index 7a72a1618164..a1a76b2cfc7c 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/__init__.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ManagedServicesClient'] -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/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_configuration.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_configuration.py index bd3d9ff2cae3..4058a167de04 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_configuration.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_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,16 +31,15 @@ class ManagedServicesClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + **kwargs: Any + ) -> None: + super(ManagedServicesClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(ManagedServicesClientConfiguration, self).__init__(**kwargs) self.credential = credential - self.api_version = "2020-02-01-preview" + self.api_version = "2022-01-01-preview" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-managedservices/{}'.format(VERSION)) self._configure(**kwargs) @@ -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/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_managed_services_client.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_managed_services_client.py index fe7680c90761..3969819cf57b 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_managed_services_client.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_managed_services_client.py @@ -6,88 +6,97 @@ # 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 ManagedServicesClientConfiguration +from .operations import MarketplaceRegistrationDefinitionsOperations, MarketplaceRegistrationDefinitionsWithoutScopeOperations, Operations, OperationsWithScopeOperations, RegistrationAssignmentsOperations, RegistrationDefinitionsOperations + 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 ManagedServicesClientConfiguration -from .operations import RegistrationDefinitionsOperations -from .operations import RegistrationAssignmentsOperations -from .operations import MarketplaceRegistrationDefinitionsOperations -from .operations import MarketplaceRegistrationDefinitionsWithoutScopeOperations -from .operations import Operations -from . import models - -class ManagedServicesClient(object): - """Specification for ManagedServices. +class ManagedServicesClient: + """The specification for ManagedServices. :ivar registration_definitions: RegistrationDefinitionsOperations operations - :vartype registration_definitions: azure.mgmt.managedservices.operations.RegistrationDefinitionsOperations + :vartype registration_definitions: + azure.mgmt.managedservices.operations.RegistrationDefinitionsOperations :ivar registration_assignments: RegistrationAssignmentsOperations operations - :vartype registration_assignments: azure.mgmt.managedservices.operations.RegistrationAssignmentsOperations - :ivar marketplace_registration_definitions: MarketplaceRegistrationDefinitionsOperations operations - :vartype marketplace_registration_definitions: azure.mgmt.managedservices.operations.MarketplaceRegistrationDefinitionsOperations - :ivar marketplace_registration_definitions_without_scope: MarketplaceRegistrationDefinitionsWithoutScopeOperations operations - :vartype marketplace_registration_definitions_without_scope: azure.mgmt.managedservices.operations.MarketplaceRegistrationDefinitionsWithoutScopeOperations + :vartype registration_assignments: + azure.mgmt.managedservices.operations.RegistrationAssignmentsOperations + :ivar marketplace_registration_definitions: MarketplaceRegistrationDefinitionsOperations + operations + :vartype marketplace_registration_definitions: + azure.mgmt.managedservices.operations.MarketplaceRegistrationDefinitionsOperations + :ivar marketplace_registration_definitions_without_scope: + MarketplaceRegistrationDefinitionsWithoutScopeOperations operations + :vartype marketplace_registration_definitions_without_scope: + azure.mgmt.managedservices.operations.MarketplaceRegistrationDefinitionsWithoutScopeOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.managedservices.operations.Operations + :ivar operations_with_scope: OperationsWithScopeOperations operations + :vartype operations_with_scope: + azure.mgmt.managedservices.operations.OperationsWithScopeOperations :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 = ManagedServicesClientConfiguration(credential, **kwargs) + credential: "TokenCredential", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ManagedServicesClientConfiguration(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.registration_definitions = RegistrationDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.registration_assignments = RegistrationAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.marketplace_registration_definitions = MarketplaceRegistrationDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.marketplace_registration_definitions_without_scope = MarketplaceRegistrationDefinitionsWithoutScopeOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.operations_with_scope = OperationsWithScopeOperations(self._client, self._config, self._serialize, self._deserialize) - self.registration_definitions = RegistrationDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.registration_assignments = RegistrationAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.marketplace_registration_definitions = MarketplaceRegistrationDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.marketplace_registration_definitions_without_scope = MarketplaceRegistrationDefinitionsWithoutScopeOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - 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/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_metadata.json b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_metadata.json index 669a7cbee049..b9c719333e89 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_metadata.json +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_metadata.json @@ -1,17 +1,17 @@ { - "chosen_version": "2020-02-01-preview", - "total_api_version_list": ["2020-02-01-preview"], + "chosen_version": "2022-01-01-preview", + "total_api_version_list": ["2022-01-01-preview"], "client": { "name": "ManagedServicesClient", "filename": "_managed_services_client", - "description": "Specification for ManagedServices.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "description": "The specification for ManagedServices.", + "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\": [\"ManagedServicesClientConfiguration\"]}}, \"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\": [\"ManagedServicesClientConfiguration\"]}}, \"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\": [\"ManagedServicesClientConfiguration\"]}}, \"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\": [\"ManagedServicesClientConfiguration\"]}}, \"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,17 +79,17 @@ "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": { "registration_definitions": "RegistrationDefinitionsOperations", "registration_assignments": "RegistrationAssignmentsOperations", "marketplace_registration_definitions": "MarketplaceRegistrationDefinitionsOperations", "marketplace_registration_definitions_without_scope": "MarketplaceRegistrationDefinitionsWithoutScopeOperations", - "operations": "Operations" + "operations": "Operations", + "operations_with_scope": "OperationsWithScopeOperations" } } \ No newline at end of file diff --git a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_patch.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_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/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_vendor.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_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/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_version.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_version.py index caf312bd2d0b..eae7c95b6fbd 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_version.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "6.0.0" +VERSION = "0.1.0" diff --git a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/__init__.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/__init__.py index aa6b8e3a0046..2e993f76bb8c 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/__init__.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/__init__.py @@ -8,3 +8,8 @@ from ._managed_services_client import ManagedServicesClient __all__ = ['ManagedServicesClient'] + +# `._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/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/_configuration.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/_configuration.py index 8137912f6407..1cb0e6688988 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/_configuration.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/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,12 +34,12 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(ManagedServicesClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(ManagedServicesClientConfiguration, self).__init__(**kwargs) self.credential = credential - self.api_version = "2020-02-01-preview" + self.api_version = "2022-01-01-preview" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-managedservices/{}'.format(VERSION)) self._configure(**kwargs) @@ -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/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/_managed_services_client.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/_managed_services_client.py index 17ff8623156c..b645c7bf74fd 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/_managed_services_client.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/_managed_services_client.py @@ -6,84 +6,97 @@ # 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 ManagedServicesClientConfiguration +from .operations import MarketplaceRegistrationDefinitionsOperations, MarketplaceRegistrationDefinitionsWithoutScopeOperations, Operations, OperationsWithScopeOperations, RegistrationAssignmentsOperations, RegistrationDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ManagedServicesClientConfiguration -from .operations import RegistrationDefinitionsOperations -from .operations import RegistrationAssignmentsOperations -from .operations import MarketplaceRegistrationDefinitionsOperations -from .operations import MarketplaceRegistrationDefinitionsWithoutScopeOperations -from .operations import Operations -from .. import models - - -class ManagedServicesClient(object): - """Specification for ManagedServices. +class ManagedServicesClient: + """The specification for ManagedServices. :ivar registration_definitions: RegistrationDefinitionsOperations operations - :vartype registration_definitions: azure.mgmt.managedservices.aio.operations.RegistrationDefinitionsOperations + :vartype registration_definitions: + azure.mgmt.managedservices.aio.operations.RegistrationDefinitionsOperations :ivar registration_assignments: RegistrationAssignmentsOperations operations - :vartype registration_assignments: azure.mgmt.managedservices.aio.operations.RegistrationAssignmentsOperations - :ivar marketplace_registration_definitions: MarketplaceRegistrationDefinitionsOperations operations - :vartype marketplace_registration_definitions: azure.mgmt.managedservices.aio.operations.MarketplaceRegistrationDefinitionsOperations - :ivar marketplace_registration_definitions_without_scope: MarketplaceRegistrationDefinitionsWithoutScopeOperations operations - :vartype marketplace_registration_definitions_without_scope: azure.mgmt.managedservices.aio.operations.MarketplaceRegistrationDefinitionsWithoutScopeOperations + :vartype registration_assignments: + azure.mgmt.managedservices.aio.operations.RegistrationAssignmentsOperations + :ivar marketplace_registration_definitions: MarketplaceRegistrationDefinitionsOperations + operations + :vartype marketplace_registration_definitions: + azure.mgmt.managedservices.aio.operations.MarketplaceRegistrationDefinitionsOperations + :ivar marketplace_registration_definitions_without_scope: + MarketplaceRegistrationDefinitionsWithoutScopeOperations operations + :vartype marketplace_registration_definitions_without_scope: + azure.mgmt.managedservices.aio.operations.MarketplaceRegistrationDefinitionsWithoutScopeOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.managedservices.aio.operations.Operations + :ivar operations_with_scope: OperationsWithScopeOperations operations + :vartype operations_with_scope: + azure.mgmt.managedservices.aio.operations.OperationsWithScopeOperations :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 = ManagedServicesClientConfiguration(credential, **kwargs) + self._config = ManagedServicesClientConfiguration(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.registration_definitions = RegistrationDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.registration_assignments = RegistrationAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.marketplace_registration_definitions = MarketplaceRegistrationDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.marketplace_registration_definitions_without_scope = MarketplaceRegistrationDefinitionsWithoutScopeOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.operations_with_scope = OperationsWithScopeOperations(self._client, self._config, self._serialize, self._deserialize) + - self.registration_definitions = RegistrationDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.registration_assignments = RegistrationAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.marketplace_registration_definitions = MarketplaceRegistrationDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.marketplace_registration_definitions_without_scope = MarketplaceRegistrationDefinitionsWithoutScopeOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - 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/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/_patch.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/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/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/__init__.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/__init__.py index e52c6c86461f..7fe69ff48a7c 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/__init__.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/__init__.py @@ -11,6 +11,7 @@ from ._marketplace_registration_definitions_operations import MarketplaceRegistrationDefinitionsOperations from ._marketplace_registration_definitions_without_scope_operations import MarketplaceRegistrationDefinitionsWithoutScopeOperations from ._operations import Operations +from ._operations_with_scope_operations import OperationsWithScopeOperations __all__ = [ 'RegistrationDefinitionsOperations', @@ -18,4 +19,5 @@ 'MarketplaceRegistrationDefinitionsOperations', 'MarketplaceRegistrationDefinitionsWithoutScopeOperations', 'Operations', + 'OperationsWithScopeOperations', ] diff --git a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_marketplace_registration_definitions_operations.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_marketplace_registration_definitions_operations.py index 1358ed0dde29..827dd7207cf6 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_marketplace_registration_definitions_operations.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_marketplace_registration_definitions_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._marketplace_registration_definitions_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,22 +46,24 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, scope: str, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.MarketplaceRegistrationDefinitionList"]: """Gets a list of the marketplace registration definitions for the marketplace identifier. - :param scope: Scope of the resource. + :param scope: The scope of the resource. :type scope: str - :param filter: The filter query parameter. Might be used to filter marketplace registration - definition by plan identifier, publisher, version etc. + :param filter: The filter query parameter to filter managed services resources by. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MarketplaceRegistrationDefinitionList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedservices.models.MarketplaceRegistrationDefinitionList] + :return: An iterator like instance of either MarketplaceRegistrationDefinitionList or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedservices.models.MarketplaceRegistrationDefinitionList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MarketplaceRegistrationDefinitionList"] @@ -64,36 +71,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - 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 - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + filter=filter, + 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( + scope=scope, + filter=filter, + 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('MarketplaceRegistrationDefinitionList', pipeline_response) + deserialized = self._deserialize("MarketplaceRegistrationDefinitionList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,28 +108,30 @@ 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': '/{scope}/providers/Microsoft.ManagedServices/marketplaceRegistrationDefinitions'} # type: ignore + @distributed_trace_async async def get( self, scope: str, marketplace_identifier: str, - **kwargs + **kwargs: Any ) -> "_models.MarketplaceRegistrationDefinition": """Get the marketplace registration definition for the marketplace identifier. - :param scope: Scope of the resource. + :param scope: The scope of the resource. :type scope: str - :param marketplace_identifier: Market place identifier. Expected Formats - + :param marketplace_identifier: The Azure Marketplace identifier. Expected formats: {publisher}.{product[-preview]}.{planName}.{version} or {publisher}.{product[-preview]}.{planName} or {publisher}.{product[-preview]} or {publisher}). :type marketplace_identifier: str @@ -141,32 +145,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'marketplaceIdentifier': self._serialize.url("marketplace_identifier", marketplace_identifier, '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( + scope=scope, + marketplace_identifier=marketplace_identifier, + 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('MarketplaceRegistrationDefinition', pipeline_response) @@ -175,4 +169,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.ManagedServices/marketplaceRegistrationDefinitions/{marketplaceIdentifier}'} # type: ignore + diff --git a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_marketplace_registration_definitions_without_scope_operations.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_marketplace_registration_definitions_without_scope_operations.py index 0c1b77114e06..6fca0e495cfd 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_marketplace_registration_definitions_without_scope_operations.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_marketplace_registration_definitions_without_scope_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._marketplace_registration_definitions_without_scope_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,19 +46,21 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.MarketplaceRegistrationDefinitionList"]: """Gets a list of the marketplace registration definitions for the marketplace identifier. - :param filter: The filter query parameter. Might be used to filter marketplace registration - definition by plan identifier, publisher, version etc. + :param filter: The filter query parameter to filter managed services resources by. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MarketplaceRegistrationDefinitionList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedservices.models.MarketplaceRegistrationDefinitionList] + :return: An iterator like instance of either MarketplaceRegistrationDefinitionList or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedservices.models.MarketplaceRegistrationDefinitionList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MarketplaceRegistrationDefinitionList"] @@ -61,32 +68,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + filter=filter, + 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( + filter=filter, + 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('MarketplaceRegistrationDefinitionList', pipeline_response) + deserialized = self._deserialize("MarketplaceRegistrationDefinitionList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -99,25 +103,27 @@ 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.ManagedServices/marketplaceRegistrationDefinitions'} # type: ignore + @distributed_trace_async async def get( self, marketplace_identifier: str, - **kwargs + **kwargs: Any ) -> "_models.MarketplaceRegistrationDefinition": """Get the marketplace registration definition for the marketplace identifier. - :param marketplace_identifier: Market place identifier. Expected Formats - + :param marketplace_identifier: The Azure Marketplace identifier. Expected formats: {publisher}.{product[-preview]}.{planName}.{version} or {publisher}.{product[-preview]}.{planName} or {publisher}.{product[-preview]} or {publisher}). :type marketplace_identifier: str @@ -131,31 +137,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - accept = "application/json" - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'marketplaceIdentifier': self._serialize.url("marketplace_identifier", marketplace_identifier, '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( + marketplace_identifier=marketplace_identifier, + 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('MarketplaceRegistrationDefinition', pipeline_response) @@ -164,4 +160,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.ManagedServices/marketplaceRegistrationDefinitions/{marketplaceIdentifier}'} # type: ignore + diff --git a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_operations.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_operations.py index f87b95beb0d7..5940189d4af6 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_operations.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_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._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,9 +44,10 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, - **kwargs + **kwargs: Any ) -> "_models.OperationList": """Gets a list of the operations. @@ -56,27 +61,20 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - accept = "application/json" - - # 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, '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) 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('OperationList', pipeline_response) @@ -85,4 +83,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/providers/Microsoft.ManagedServices/operations'} # type: ignore + diff --git a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_operations_with_scope_operations.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_operations_with_scope_operations.py new file mode 100644 index 000000000000..e0d3550c01a9 --- /dev/null +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_operations_with_scope_operations.py @@ -0,0 +1,92 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) 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 +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._operations_with_scope_operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class OperationsWithScopeOperations: + """OperationsWithScopeOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.managedservices.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def list( + self, + scope: str, + **kwargs: Any + ) -> "_models.OperationList": + """Gets a list of the operations with the scope. + + :param scope: The scope of the resource. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationList, or the result of cls(response) + :rtype: ~azure.mgmt.managedservices.models.OperationList + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_list_request( + scope=scope, + template_url=self.list.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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('OperationList', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {'url': '/{scope}/providers/Microsoft.ManagedServices/operations'} # type: ignore + diff --git a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_registration_assignments_operations.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_registration_assignments_operations.py index fd0f198794e3..3f440caa6e6c 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_registration_assignments_operations.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_registration_assignments_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._registration_assignments_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,21 +48,22 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, scope: str, registration_assignment_id: str, expand_registration_definition: Optional[bool] = None, - **kwargs + **kwargs: Any ) -> "_models.RegistrationAssignment": - """Gets the details of specified registration assignment. + """Gets the details of the specified registration assignment. - :param scope: Scope of the resource. + :param scope: The scope of the resource. :type scope: str - :param registration_assignment_id: Guid of the registration assignment. + :param registration_assignment_id: The GUID of the registration assignment. :type registration_assignment_id: str - :param expand_registration_definition: Tells whether to return registration definition details - also along with registration assignment details. + :param expand_registration_definition: The flag indicating whether to return the registration + definition details along with the registration assignment details. :type expand_registration_definition: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: RegistrationAssignment, or the result of cls(response) @@ -69,34 +75,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'registrationAssignmentId': self._serialize.url("registration_assignment_id", registration_assignment_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand_registration_definition is not None: - query_parameters['$expandRegistrationDefinition'] = self._serialize.query("expand_registration_definition", expand_registration_definition, 'bool') - 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( + scope=scope, + registration_assignment_id=registration_assignment_id, + expand_registration_definition=expand_registration_definition, + 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('RegistrationAssignment', pipeline_response) @@ -105,75 +100,70 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.ManagedServices/registrationAssignments/{registrationAssignmentId}'} # type: ignore + async def _delete_initial( self, scope: str, registration_assignment_id: str, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'registrationAssignmentId': self._serialize.url("registration_assignment_id", registration_assignment_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_initial( + scope=scope, + registration_assignment_id=registration_assignment_id, + 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 [200, 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) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/{scope}/providers/Microsoft.ManagedServices/registrationAssignments/{registrationAssignmentId}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, scope: str, registration_assignment_id: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified registration assignment. - :param scope: Scope of the resource. + :param scope: The scope of the resource. :type scope: str - :param registration_assignment_id: Guid of the registration assignment. + :param registration_assignment_id: The GUID of the registration assignment. :type registration_assignment_id: 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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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. + :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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :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[None] lro_delay = kwargs.pop( 'polling_interval', @@ -187,20 +177,14 @@ 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): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'registrationAssignmentId': self._serialize.url("registration_assignment_id", registration_assignment_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -212,6 +196,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/{scope}/providers/Microsoft.ManagedServices/registrationAssignments/{registrationAssignmentId}'} # type: ignore async def _create_or_update_initial( @@ -219,45 +204,34 @@ async def _create_or_update_initial( scope: str, registration_assignment_id: str, request_body: "_models.RegistrationAssignment", - **kwargs + **kwargs: Any ) -> "_models.RegistrationAssignment": cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistrationAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'registrationAssignmentId': self._serialize.url("registration_assignment_id", registration_assignment_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(request_body, 'RegistrationAssignment') + + request = build_create_or_update_request_initial( + scope=scope, + registration_assignment_id=registration_assignment_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.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(request_body, 'RegistrationAssignment') - 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, 201]: 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) if response.status_code == 200: deserialized = self._deserialize('RegistrationAssignment', pipeline_response) @@ -269,34 +243,42 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/{scope}/providers/Microsoft.ManagedServices/registrationAssignments/{registrationAssignmentId}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, scope: str, registration_assignment_id: str, request_body: "_models.RegistrationAssignment", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.RegistrationAssignment"]: """Creates or updates a registration assignment. - :param scope: Scope of the resource. + :param scope: The scope of the resource. :type scope: str - :param registration_assignment_id: Guid of the registration assignment. + :param registration_assignment_id: The GUID of the registration assignment. :type registration_assignment_id: str :param request_body: The parameters required to create new registration assignment. :type request_body: ~azure.mgmt.managedservices.models.RegistrationAssignment :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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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 RegistrationAssignment or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedservices.models.RegistrationAssignment] - :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 RegistrationAssignment or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedservices.models.RegistrationAssignment] + :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["_models.RegistrationAssignment"] lro_delay = kwargs.pop( 'polling_interval', @@ -308,26 +290,21 @@ async def begin_create_or_update( scope=scope, registration_assignment_id=registration_assignment_id, request_body=request_body, + 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('RegistrationAssignment', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'registrationAssignmentId': self._serialize.url("registration_assignment_id", registration_assignment_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -339,24 +316,31 @@ 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': '/{scope}/providers/Microsoft.ManagedServices/registrationAssignments/{registrationAssignmentId}'} # type: ignore + @distributed_trace def list( self, scope: str, expand_registration_definition: Optional[bool] = None, - **kwargs + filter: Optional[str] = None, + **kwargs: Any ) -> AsyncIterable["_models.RegistrationAssignmentList"]: """Gets a list of the registration assignments. - :param scope: Scope of the resource. + :param scope: The scope of the resource. :type scope: str - :param expand_registration_definition: Tells whether to return registration definition details - also along with registration assignment details. + :param expand_registration_definition: The flag indicating whether to return the registration + definition details along with the registration assignment details. :type expand_registration_definition: bool + :param filter: The filter query parameter to filter managed services resources by. + :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistrationAssignmentList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedservices.models.RegistrationAssignmentList] + :return: An iterator like instance of either RegistrationAssignmentList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedservices.models.RegistrationAssignmentList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistrationAssignmentList"] @@ -364,36 +348,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - 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 - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand_registration_definition is not None: - query_parameters['$expandRegistrationDefinition'] = self._serialize.query("expand_registration_definition", expand_registration_definition, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + expand_registration_definition=expand_registration_definition, + filter=filter, + 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( + scope=scope, + expand_registration_definition=expand_registration_definition, + filter=filter, + 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('RegistrationAssignmentList', pipeline_response) + deserialized = self._deserialize("RegistrationAssignmentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -406,12 +387,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/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_registration_definitions_operations.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_registration_definitions_operations.py index 7603275c230a..b6f2f730c055 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_registration_definitions_operations.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/aio/operations/_registration_definitions_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._registration_definitions_operations import build_create_or_update_request_initial, build_delete_request, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,17 +48,18 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, scope: str, registration_definition_id: str, - **kwargs + **kwargs: Any ) -> "_models.RegistrationDefinition": """Gets the registration definition details. - :param scope: Scope of the resource. + :param scope: The scope of the resource. :type scope: str - :param registration_definition_id: Guid of the registration definition. + :param registration_definition_id: The GUID of the registration definition. :type registration_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RegistrationDefinition, or the result of cls(response) @@ -65,32 +71,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'registrationDefinitionId': self._serialize.url("registration_definition_id", registration_definition_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( + scope=scope, + registration_definition_id=registration_definition_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('RegistrationDefinition', pipeline_response) @@ -99,19 +95,22 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.ManagedServices/registrationDefinitions/{registrationDefinitionId}'} # type: ignore + + @distributed_trace_async async def delete( self, registration_definition_id: str, scope: str, - **kwargs + **kwargs: Any ) -> None: """Deletes the registration definition. - :param registration_definition_id: Guid of the registration definition. + :param registration_definition_id: The GUID of the registration definition. :type registration_definition_id: str - :param scope: Scope of the resource. + :param scope: The scope of the resource. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) @@ -123,32 +122,22 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'registrationDefinitionId': self._serialize.url("registration_definition_id", registration_definition_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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( + registration_definition_id=registration_definition_id, + scope=scope, + 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: @@ -156,50 +145,40 @@ async def delete( delete.metadata = {'url': '/{scope}/providers/Microsoft.ManagedServices/registrationDefinitions/{registrationDefinitionId}'} # type: ignore + async def _create_or_update_initial( self, registration_definition_id: str, scope: str, request_body: "_models.RegistrationDefinition", - **kwargs + **kwargs: Any ) -> "_models.RegistrationDefinition": cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistrationDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - 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 = { - 'registrationDefinitionId': self._serialize.url("registration_definition_id", registration_definition_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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(request_body, 'RegistrationDefinition') - # 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_initial( + registration_definition_id=registration_definition_id, + scope=scope, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.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(request_body, 'RegistrationDefinition') - 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, 201]: 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) if response.status_code == 200: deserialized = self._deserialize('RegistrationDefinition', pipeline_response) @@ -211,34 +190,42 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/{scope}/providers/Microsoft.ManagedServices/registrationDefinitions/{registrationDefinitionId}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, registration_definition_id: str, scope: str, request_body: "_models.RegistrationDefinition", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.RegistrationDefinition"]: """Creates or updates a registration definition. - :param registration_definition_id: Guid of the registration definition. + :param registration_definition_id: The GUID of the registration definition. :type registration_definition_id: str - :param scope: Scope of the resource. + :param scope: The scope of the resource. :type scope: str - :param request_body: The parameters required to create new registration definition. + :param request_body: The parameters required to create a new registration definition. :type request_body: ~azure.mgmt.managedservices.models.RegistrationDefinition :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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or 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 RegistrationDefinition or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedservices.models.RegistrationDefinition] - :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 RegistrationDefinition or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.managedservices.models.RegistrationDefinition] + :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["_models.RegistrationDefinition"] lro_delay = kwargs.pop( 'polling_interval', @@ -250,26 +237,21 @@ async def begin_create_or_update( registration_definition_id=registration_definition_id, scope=scope, request_body=request_body, + 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('RegistrationDefinition', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'registrationDefinitionId': self._serialize.url("registration_definition_id", registration_definition_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -281,20 +263,27 @@ 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': '/{scope}/providers/Microsoft.ManagedServices/registrationDefinitions/{registrationDefinitionId}'} # type: ignore + @distributed_trace def list( self, scope: str, - **kwargs + filter: Optional[str] = None, + **kwargs: Any ) -> AsyncIterable["_models.RegistrationDefinitionList"]: """Gets a list of the registration definitions. - :param scope: Scope of the resource. + :param scope: The scope of the resource. :type scope: str + :param filter: The filter query parameter to filter managed services resources by. + :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistrationDefinitionList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedservices.models.RegistrationDefinitionList] + :return: An iterator like instance of either RegistrationDefinitionList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.managedservices.models.RegistrationDefinitionList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistrationDefinitionList"] @@ -302,34 +291,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - 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 - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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 = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + filter=filter, + 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( + scope=scope, + filter=filter, + 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('RegistrationDefinitionList', pipeline_response) + deserialized = self._deserialize("RegistrationDefinitionList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -342,12 +328,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/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/models/__init__.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/models/__init__.py index a4aab1875126..2aec33c36f8a 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/models/__init__.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/models/__init__.py @@ -6,48 +6,29 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import Authorization - from ._models_py3 import EligibleAuthorization - from ._models_py3 import ErrorDefinition - from ._models_py3 import ErrorResponse - from ._models_py3 import JustInTimeAccessPolicy - from ._models_py3 import MarketplaceRegistrationDefinition - from ._models_py3 import MarketplaceRegistrationDefinitionList - from ._models_py3 import MarketplaceRegistrationDefinitionProperties - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationList - from ._models_py3 import Plan - from ._models_py3 import RegistrationAssignment - from ._models_py3 import RegistrationAssignmentList - from ._models_py3 import RegistrationAssignmentProperties - from ._models_py3 import RegistrationAssignmentPropertiesRegistrationDefinition - from ._models_py3 import RegistrationAssignmentPropertiesRegistrationDefinitionProperties - from ._models_py3 import RegistrationDefinition - from ._models_py3 import RegistrationDefinitionList - from ._models_py3 import RegistrationDefinitionProperties -except (SyntaxError, ImportError): - from ._models import Authorization # type: ignore - from ._models import EligibleAuthorization # type: ignore - from ._models import ErrorDefinition # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import JustInTimeAccessPolicy # type: ignore - from ._models import MarketplaceRegistrationDefinition # type: ignore - from ._models import MarketplaceRegistrationDefinitionList # type: ignore - from ._models import MarketplaceRegistrationDefinitionProperties # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationList # type: ignore - from ._models import Plan # type: ignore - from ._models import RegistrationAssignment # type: ignore - from ._models import RegistrationAssignmentList # type: ignore - from ._models import RegistrationAssignmentProperties # type: ignore - from ._models import RegistrationAssignmentPropertiesRegistrationDefinition # type: ignore - from ._models import RegistrationAssignmentPropertiesRegistrationDefinitionProperties # type: ignore - from ._models import RegistrationDefinition # type: ignore - from ._models import RegistrationDefinitionList # type: ignore - from ._models import RegistrationDefinitionProperties # type: ignore +from ._models_py3 import Authorization +from ._models_py3 import EligibleApprover +from ._models_py3 import EligibleAuthorization +from ._models_py3 import ErrorDefinition +from ._models_py3 import ErrorResponse +from ._models_py3 import JustInTimeAccessPolicy +from ._models_py3 import MarketplaceRegistrationDefinition +from ._models_py3 import MarketplaceRegistrationDefinitionList +from ._models_py3 import MarketplaceRegistrationDefinitionProperties +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationList +from ._models_py3 import Plan +from ._models_py3 import RegistrationAssignment +from ._models_py3 import RegistrationAssignmentList +from ._models_py3 import RegistrationAssignmentProperties +from ._models_py3 import RegistrationAssignmentPropertiesRegistrationDefinition +from ._models_py3 import RegistrationAssignmentPropertiesRegistrationDefinitionProperties +from ._models_py3 import RegistrationDefinition +from ._models_py3 import RegistrationDefinitionList +from ._models_py3 import RegistrationDefinitionProperties +from ._models_py3 import SystemData + from ._managed_services_client_enums import ( MultiFactorAuthProvider, @@ -56,6 +37,7 @@ __all__ = [ 'Authorization', + 'EligibleApprover', 'EligibleAuthorization', 'ErrorDefinition', 'ErrorResponse', @@ -75,6 +57,7 @@ 'RegistrationDefinition', 'RegistrationDefinitionList', 'RegistrationDefinitionProperties', + 'SystemData', 'MultiFactorAuthProvider', 'ProvisioningState', ] diff --git a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/models/_managed_services_client_enums.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/models/_managed_services_client_enums.py index 92e26e80ee8a..5adb60ce1323 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/models/_managed_services_client_enums.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/models/_managed_services_client_enums.py @@ -6,35 +6,20 @@ # 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 MultiFactorAuthProvider(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """MFA provider. +class MultiFactorAuthProvider(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The multi-factor authorization provider to be used for just-in-time access requests. """ AZURE = "Azure" NONE = "None" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Current state of the registration definition. +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The current provisioning state of the registration definition. """ NOT_SPECIFIED = "NotSpecified" diff --git a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/models/_models.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/models/_models.py deleted file mode 100644 index 1f44f236a6ac..000000000000 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/models/_models.py +++ /dev/null @@ -1,772 +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 Authorization(msrest.serialization.Model): - """Authorization tuple containing principal Id (of user/service principal/security group) and role definition id. - - All required parameters must be populated in order to send to Azure. - - :param principal_id: Required. Principal Id of the security group/service principal/user that - would be assigned permissions to the projected subscription. - :type principal_id: str - :param principal_id_display_name: Display name of the principal Id. - :type principal_id_display_name: str - :param role_definition_id: Required. The role definition identifier. This role will define all - the permissions that the security group/service principal/user must have on the projected - subscription. This role cannot be an owner role. - :type role_definition_id: str - :param delegated_role_definition_ids: The delegatedRoleDefinitionIds field is required when the - roleDefinitionId refers to the User Access Administrator Role. It is the list of role - definition ids which define all the permissions that the user in the authorization can assign - to other security groups/service principals/users. - :type delegated_role_definition_ids: list[str] - """ - - _validation = { - 'principal_id': {'required': True}, - 'role_definition_id': {'required': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'principal_id_display_name': {'key': 'principalIdDisplayName', 'type': 'str'}, - 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, - 'delegated_role_definition_ids': {'key': 'delegatedRoleDefinitionIds', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(Authorization, self).__init__(**kwargs) - self.principal_id = kwargs['principal_id'] - self.principal_id_display_name = kwargs.get('principal_id_display_name', None) - self.role_definition_id = kwargs['role_definition_id'] - self.delegated_role_definition_ids = kwargs.get('delegated_role_definition_ids', None) - - -class EligibleAuthorization(msrest.serialization.Model): - """Eligible authorization tuple containing principle Id (of user/service principal/security group), role definition id, and the just-in-time access setting. - - All required parameters must be populated in order to send to Azure. - - :param principal_id: Required. Principal Id of the security group/service principal/user that - would be delegated permissions to the projected subscription. - :type principal_id: str - :param principal_id_display_name: Display name of the principal Id. - :type principal_id_display_name: str - :param role_definition_id: Required. The role definition identifier. This role will delegate - all the permissions that the security group/service principal/user must have on the projected - subscription. This role cannot be an owner role. - :type role_definition_id: str - :param just_in_time_access_policy: Just-in-time access policy setting. - :type just_in_time_access_policy: ~azure.mgmt.managedservices.models.JustInTimeAccessPolicy - """ - - _validation = { - 'principal_id': {'required': True}, - 'role_definition_id': {'required': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'principal_id_display_name': {'key': 'principalIdDisplayName', 'type': 'str'}, - 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, - 'just_in_time_access_policy': {'key': 'justInTimeAccessPolicy', 'type': 'JustInTimeAccessPolicy'}, - } - - def __init__( - self, - **kwargs - ): - super(EligibleAuthorization, self).__init__(**kwargs) - self.principal_id = kwargs['principal_id'] - self.principal_id_display_name = kwargs.get('principal_id_display_name', None) - self.role_definition_id = kwargs['role_definition_id'] - self.just_in_time_access_policy = kwargs.get('just_in_time_access_policy', None) - - -class ErrorDefinition(msrest.serialization.Model): - """Error response indicates Azure Resource Manager is not able to process the incoming request. The reason is provided in the error message. - - All required parameters must be populated in order to send to Azure. - - :param code: Required. Error code. - :type code: str - :param message: Required. Error message indicating why the operation failed. - :type message: str - :param details: Internal error details. - :type details: list[~azure.mgmt.managedservices.models.ErrorDefinition] - """ - - _validation = { - 'code': {'required': True}, - 'message': {'required': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDefinition]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDefinition, self).__init__(**kwargs) - self.code = kwargs['code'] - self.message = kwargs['message'] - self.details = kwargs.get('details', None) - - -class ErrorResponse(msrest.serialization.Model): - """Error response. - - :param error: The error details. - :type error: ~azure.mgmt.managedservices.models.ErrorDefinition - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinition'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class JustInTimeAccessPolicy(msrest.serialization.Model): - """Just-in-time access policy setting. - - All required parameters must be populated in order to send to Azure. - - :param multi_factor_auth_provider: Required. MFA provider. Possible values include: "Azure", - "None". - :type multi_factor_auth_provider: str or - ~azure.mgmt.managedservices.models.MultiFactorAuthProvider - :param maximum_activation_duration: Maximum access duration in ISO 8601 format. The default - value is "PT8H". - :type maximum_activation_duration: ~datetime.timedelta - """ - - _validation = { - 'multi_factor_auth_provider': {'required': True}, - } - - _attribute_map = { - 'multi_factor_auth_provider': {'key': 'multiFactorAuthProvider', 'type': 'str'}, - 'maximum_activation_duration': {'key': 'maximumActivationDuration', 'type': 'duration'}, - } - - def __init__( - self, - **kwargs - ): - super(JustInTimeAccessPolicy, self).__init__(**kwargs) - self.multi_factor_auth_provider = kwargs['multi_factor_auth_provider'] - self.maximum_activation_duration = kwargs.get('maximum_activation_duration', None) - - -class MarketplaceRegistrationDefinition(msrest.serialization.Model): - """MarketplaceRegistrationDefinition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: Properties of a marketplace registration definition. - :type properties: - ~azure.mgmt.managedservices.models.MarketplaceRegistrationDefinitionProperties - :param plan: Plan details for the managed services. - :type plan: ~azure.mgmt.managedservices.models.Plan - :ivar id: Fully qualified path of the marketplace registration definition. - :vartype id: str - :ivar type: Type of the resource. - :vartype type: str - :ivar name: Name of the marketplace registration definition. - :vartype name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'MarketplaceRegistrationDefinitionProperties'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MarketplaceRegistrationDefinition, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.plan = kwargs.get('plan', None) - self.id = None - self.type = None - self.name = None - - -class MarketplaceRegistrationDefinitionList(msrest.serialization.Model): - """List of marketplace registration definitions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of marketplace registration definitions. - :vartype value: list[~azure.mgmt.managedservices.models.MarketplaceRegistrationDefinition] - :ivar next_link: Link to next page of marketplace registration definitions. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MarketplaceRegistrationDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MarketplaceRegistrationDefinitionList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class MarketplaceRegistrationDefinitionProperties(msrest.serialization.Model): - """Properties of a marketplace registration definition. - - All required parameters must be populated in order to send to Azure. - - :param managed_by_tenant_id: Required. Id of the managedBy tenant. - :type managed_by_tenant_id: str - :param authorizations: Required. Authorization tuple containing principal id of the - user/security group or service principal and id of the build-in role. - :type authorizations: list[~azure.mgmt.managedservices.models.Authorization] - :param eligible_authorizations: Eligible PIM authorization tuple containing principal id of the - user/security group or service principal, id of the built-in role, and just-in-time access - policy setting. - :type eligible_authorizations: list[~azure.mgmt.managedservices.models.EligibleAuthorization] - :param offer_display_name: The marketplace offer display name. - :type offer_display_name: str - :param publisher_display_name: The marketplace publisher display name. - :type publisher_display_name: str - :param plan_display_name: The marketplace plan display name. - :type plan_display_name: str - """ - - _validation = { - 'managed_by_tenant_id': {'required': True}, - 'authorizations': {'required': True}, - } - - _attribute_map = { - 'managed_by_tenant_id': {'key': 'managedByTenantId', 'type': 'str'}, - 'authorizations': {'key': 'authorizations', 'type': '[Authorization]'}, - 'eligible_authorizations': {'key': 'eligibleAuthorizations', 'type': '[EligibleAuthorization]'}, - 'offer_display_name': {'key': 'offerDisplayName', 'type': 'str'}, - 'publisher_display_name': {'key': 'publisherDisplayName', 'type': 'str'}, - 'plan_display_name': {'key': 'planDisplayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MarketplaceRegistrationDefinitionProperties, self).__init__(**kwargs) - self.managed_by_tenant_id = kwargs['managed_by_tenant_id'] - self.authorizations = kwargs['authorizations'] - self.eligible_authorizations = kwargs.get('eligible_authorizations', None) - self.offer_display_name = kwargs.get('offer_display_name', None) - self.publisher_display_name = kwargs.get('publisher_display_name', None) - self.plan_display_name = kwargs.get('plan_display_name', None) - - -class Operation(msrest.serialization.Model): - """Object that describes a single Microsoft.ManagedServices operation. - - 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 - :ivar display: The object that represents the operation. - :vartype display: ~azure.mgmt.managedservices.models.OperationDisplay - """ - - _validation = { - 'name': {'readonly': True}, - 'display': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = None - - -class OperationDisplay(msrest.serialization.Model): - """The object that represents the operation. - - :param provider: Service provider: Microsoft.ManagedServices. - :type provider: str - :param resource: Resource on which the operation is performed: Registration definition, - registration assignment etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str - """ - - _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(OperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationList(msrest.serialization.Model): - """List of the operations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of Microsoft.ManagedServices operations. - :vartype value: list[~azure.mgmt.managedservices.models.Operation] - """ - - _validation = { - 'value': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationList, self).__init__(**kwargs) - self.value = None - - -class Plan(msrest.serialization.Model): - """Plan details for the managed services. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The plan name. - :type name: str - :param publisher: Required. The publisher ID. - :type publisher: str - :param product: Required. The product code. - :type product: str - :param version: Required. The plan's version. - :type version: str - """ - - _validation = { - 'name': {'required': True}, - 'publisher': {'required': True}, - 'product': {'required': True}, - 'version': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Plan, self).__init__(**kwargs) - self.name = kwargs['name'] - self.publisher = kwargs['publisher'] - self.product = kwargs['product'] - self.version = kwargs['version'] - - -class RegistrationAssignment(msrest.serialization.Model): - """Registration assignment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: Properties of a registration assignment. - :type properties: ~azure.mgmt.managedservices.models.RegistrationAssignmentProperties - :ivar id: The fully qualified path of the registration assignment. - :vartype id: str - :ivar type: Type of the resource. - :vartype type: str - :ivar name: Name of the registration assignment. - :vartype name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RegistrationAssignmentProperties'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistrationAssignment, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.type = None - self.name = None - - -class RegistrationAssignmentList(msrest.serialization.Model): - """List of registration assignments. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of registration assignments. - :vartype value: list[~azure.mgmt.managedservices.models.RegistrationAssignment] - :ivar next_link: Link to next page of registration assignments. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RegistrationAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistrationAssignmentList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class RegistrationAssignmentProperties(msrest.serialization.Model): - """Properties of a registration assignment. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param registration_definition_id: Required. Fully qualified path of the registration - definition. - :type registration_definition_id: str - :ivar provisioning_state: Current state of the registration assignment. Possible values - include: "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", - "Deleted", "Canceled", "Failed", "Succeeded", "Updating". - :vartype provisioning_state: str or ~azure.mgmt.managedservices.models.ProvisioningState - :ivar registration_definition: Registration definition inside registration assignment. - :vartype registration_definition: - ~azure.mgmt.managedservices.models.RegistrationAssignmentPropertiesRegistrationDefinition - """ - - _validation = { - 'registration_definition_id': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'registration_definition': {'readonly': True}, - } - - _attribute_map = { - 'registration_definition_id': {'key': 'registrationDefinitionId', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'registration_definition': {'key': 'registrationDefinition', 'type': 'RegistrationAssignmentPropertiesRegistrationDefinition'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistrationAssignmentProperties, self).__init__(**kwargs) - self.registration_definition_id = kwargs['registration_definition_id'] - self.provisioning_state = None - self.registration_definition = None - - -class RegistrationAssignmentPropertiesRegistrationDefinition(msrest.serialization.Model): - """Registration definition inside registration assignment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: Properties of registration definition inside registration assignment. - :type properties: - ~azure.mgmt.managedservices.models.RegistrationAssignmentPropertiesRegistrationDefinitionProperties - :param plan: Plan details for the managed services. - :type plan: ~azure.mgmt.managedservices.models.Plan - :ivar id: Fully qualified path of the registration definition. - :vartype id: str - :ivar type: Type of the resource (Microsoft.ManagedServices/registrationDefinitions). - :vartype type: str - :ivar name: Name of the registration definition. - :vartype name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RegistrationAssignmentPropertiesRegistrationDefinitionProperties'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistrationAssignmentPropertiesRegistrationDefinition, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.plan = kwargs.get('plan', None) - self.id = None - self.type = None - self.name = None - - -class RegistrationAssignmentPropertiesRegistrationDefinitionProperties(msrest.serialization.Model): - """Properties of registration definition inside registration assignment. - - :param description: Description of the registration definition. - :type description: str - :param authorizations: Authorization tuple containing principal id of the user/security group - or service principal and id of the build-in role. - :type authorizations: list[~azure.mgmt.managedservices.models.Authorization] - :param eligible_authorizations: Eligible PIM authorization tuple containing principal id of the - user/security group or service principal, id of the built-in role, and just-in-time access - policy setting. - :type eligible_authorizations: list[~azure.mgmt.managedservices.models.EligibleAuthorization] - :param registration_definition_name: Name of the registration definition. - :type registration_definition_name: str - :param provisioning_state: Current state of the registration definition. Possible values - include: "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", - "Deleted", "Canceled", "Failed", "Succeeded", "Updating". - :type provisioning_state: str or ~azure.mgmt.managedservices.models.ProvisioningState - :param managee_tenant_id: Id of the home tenant. - :type managee_tenant_id: str - :param managee_tenant_name: Name of the home tenant. - :type managee_tenant_name: str - :param managed_by_tenant_id: Id of the managedBy tenant. - :type managed_by_tenant_id: str - :param managed_by_tenant_name: Name of the managedBy tenant. - :type managed_by_tenant_name: str - """ - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'authorizations': {'key': 'authorizations', 'type': '[Authorization]'}, - 'eligible_authorizations': {'key': 'eligibleAuthorizations', 'type': '[EligibleAuthorization]'}, - 'registration_definition_name': {'key': 'registrationDefinitionName', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'managee_tenant_id': {'key': 'manageeTenantId', 'type': 'str'}, - 'managee_tenant_name': {'key': 'manageeTenantName', 'type': 'str'}, - 'managed_by_tenant_id': {'key': 'managedByTenantId', 'type': 'str'}, - 'managed_by_tenant_name': {'key': 'managedByTenantName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistrationAssignmentPropertiesRegistrationDefinitionProperties, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.authorizations = kwargs.get('authorizations', None) - self.eligible_authorizations = kwargs.get('eligible_authorizations', None) - self.registration_definition_name = kwargs.get('registration_definition_name', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.managee_tenant_id = kwargs.get('managee_tenant_id', None) - self.managee_tenant_name = kwargs.get('managee_tenant_name', None) - self.managed_by_tenant_id = kwargs.get('managed_by_tenant_id', None) - self.managed_by_tenant_name = kwargs.get('managed_by_tenant_name', None) - - -class RegistrationDefinition(msrest.serialization.Model): - """Registration definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: Properties of a registration definition. - :type properties: ~azure.mgmt.managedservices.models.RegistrationDefinitionProperties - :param plan: Plan details for the managed services. - :type plan: ~azure.mgmt.managedservices.models.Plan - :ivar id: Fully qualified path of the registration definition. - :vartype id: str - :ivar type: Type of the resource. - :vartype type: str - :ivar name: Name of the registration definition. - :vartype name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RegistrationDefinitionProperties'}, - 'plan': {'key': 'plan', 'type': 'Plan'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistrationDefinition, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.plan = kwargs.get('plan', None) - self.id = None - self.type = None - self.name = None - - -class RegistrationDefinitionList(msrest.serialization.Model): - """List of registration definitions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of registration definitions. - :vartype value: list[~azure.mgmt.managedservices.models.RegistrationDefinition] - :ivar next_link: Link to next page of registration definitions. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RegistrationDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistrationDefinitionList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class RegistrationDefinitionProperties(msrest.serialization.Model): - """Properties of a registration definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param description: Description of the registration definition. - :type description: str - :param authorizations: Required. Authorization tuple containing principal id of the - user/security group or service principal and id of the build-in role. - :type authorizations: list[~azure.mgmt.managedservices.models.Authorization] - :param eligible_authorizations: Eligible PIM authorization tuple containing principal id of the - user/security group or service principal, id of the built-in role, and just-in-time access - policy setting. - :type eligible_authorizations: list[~azure.mgmt.managedservices.models.EligibleAuthorization] - :param registration_definition_name: Name of the registration definition. - :type registration_definition_name: str - :param managed_by_tenant_id: Required. Id of the managedBy tenant. - :type managed_by_tenant_id: str - :ivar provisioning_state: Current state of the registration definition. Possible values - include: "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", - "Deleted", "Canceled", "Failed", "Succeeded", "Updating". - :vartype provisioning_state: str or ~azure.mgmt.managedservices.models.ProvisioningState - :ivar managed_by_tenant_name: Name of the managedBy tenant. - :vartype managed_by_tenant_name: str - """ - - _validation = { - 'authorizations': {'required': True}, - 'managed_by_tenant_id': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'managed_by_tenant_name': {'readonly': True}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'authorizations': {'key': 'authorizations', 'type': '[Authorization]'}, - 'eligible_authorizations': {'key': 'eligibleAuthorizations', 'type': '[EligibleAuthorization]'}, - 'registration_definition_name': {'key': 'registrationDefinitionName', 'type': 'str'}, - 'managed_by_tenant_id': {'key': 'managedByTenantId', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'managed_by_tenant_name': {'key': 'managedByTenantName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistrationDefinitionProperties, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.authorizations = kwargs['authorizations'] - self.eligible_authorizations = kwargs.get('eligible_authorizations', None) - self.registration_definition_name = kwargs.get('registration_definition_name', None) - self.managed_by_tenant_id = kwargs['managed_by_tenant_id'] - self.provisioning_state = None - self.managed_by_tenant_name = None diff --git a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/models/_models_py3.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/models/_models_py3.py index 22899f6fd634..d4f2196d35c4 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/models/_models_py3.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/models/_models_py3.py @@ -16,24 +16,22 @@ class Authorization(msrest.serialization.Model): - """Authorization tuple containing principal Id (of user/service principal/security group) and role definition id. + """The Azure Active Directory principal identifier and Azure built-in role that describes the access the principal will receive on the delegated resource in the managed tenant. All required parameters must be populated in order to send to Azure. - :param principal_id: Required. Principal Id of the security group/service principal/user that - would be assigned permissions to the projected subscription. - :type principal_id: str - :param principal_id_display_name: Display name of the principal Id. - :type principal_id_display_name: str - :param role_definition_id: Required. The role definition identifier. This role will define all - the permissions that the security group/service principal/user must have on the projected - subscription. This role cannot be an owner role. - :type role_definition_id: str - :param delegated_role_definition_ids: The delegatedRoleDefinitionIds field is required when the + :ivar principal_id: Required. The identifier of the Azure Active Directory principal. + :vartype principal_id: str + :ivar principal_id_display_name: The display name of the Azure Active Directory principal. + :vartype principal_id_display_name: str + :ivar role_definition_id: Required. The identifier of the Azure built-in role that defines the + permissions that the Azure Active Directory principal will have on the projected scope. + :vartype role_definition_id: str + :ivar delegated_role_definition_ids: The delegatedRoleDefinitionIds field is required when the roleDefinitionId refers to the User Access Administrator Role. It is the list of role definition ids which define all the permissions that the user in the authorization can assign - to other security groups/service principals/users. - :type delegated_role_definition_ids: list[str] + to other principals. + :vartype delegated_role_definition_ids: list[str] """ _validation = { @@ -57,6 +55,20 @@ def __init__( delegated_role_definition_ids: Optional[List[str]] = None, **kwargs ): + """ + :keyword principal_id: Required. The identifier of the Azure Active Directory principal. + :paramtype principal_id: str + :keyword principal_id_display_name: The display name of the Azure Active Directory principal. + :paramtype principal_id_display_name: str + :keyword role_definition_id: Required. The identifier of the Azure built-in role that defines + the permissions that the Azure Active Directory principal will have on the projected scope. + :paramtype role_definition_id: str + :keyword delegated_role_definition_ids: The delegatedRoleDefinitionIds field is required when + the roleDefinitionId refers to the User Access Administrator Role. It is the list of role + definition ids which define all the permissions that the user in the authorization can assign + to other principals. + :paramtype delegated_role_definition_ids: list[str] + """ super(Authorization, self).__init__(**kwargs) self.principal_id = principal_id self.principal_id_display_name = principal_id_display_name @@ -64,22 +76,58 @@ def __init__( self.delegated_role_definition_ids = delegated_role_definition_ids +class EligibleApprover(msrest.serialization.Model): + """Defines the Azure Active Directory principal that can approve any just-in-time access requests by the principal defined in the EligibleAuthorization. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: Required. The identifier of the Azure Active Directory principal. + :vartype principal_id: str + :ivar principal_id_display_name: The display name of the Azure Active Directory principal. + :vartype principal_id_display_name: str + """ + + _validation = { + 'principal_id': {'required': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'principal_id_display_name': {'key': 'principalIdDisplayName', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: str, + principal_id_display_name: Optional[str] = None, + **kwargs + ): + """ + :keyword principal_id: Required. The identifier of the Azure Active Directory principal. + :paramtype principal_id: str + :keyword principal_id_display_name: The display name of the Azure Active Directory principal. + :paramtype principal_id_display_name: str + """ + super(EligibleApprover, self).__init__(**kwargs) + self.principal_id = principal_id + self.principal_id_display_name = principal_id_display_name + + class EligibleAuthorization(msrest.serialization.Model): - """Eligible authorization tuple containing principle Id (of user/service principal/security group), role definition id, and the just-in-time access setting. + """The Azure Active Directory principal identifier, Azure built-in role, and just-in-time access policy that describes the just-in-time access the principal will receive on the delegated resource in the managed tenant. All required parameters must be populated in order to send to Azure. - :param principal_id: Required. Principal Id of the security group/service principal/user that - would be delegated permissions to the projected subscription. - :type principal_id: str - :param principal_id_display_name: Display name of the principal Id. - :type principal_id_display_name: str - :param role_definition_id: Required. The role definition identifier. This role will delegate - all the permissions that the security group/service principal/user must have on the projected - subscription. This role cannot be an owner role. - :type role_definition_id: str - :param just_in_time_access_policy: Just-in-time access policy setting. - :type just_in_time_access_policy: ~azure.mgmt.managedservices.models.JustInTimeAccessPolicy + :ivar principal_id: Required. The identifier of the Azure Active Directory principal. + :vartype principal_id: str + :ivar principal_id_display_name: The display name of the Azure Active Directory principal. + :vartype principal_id_display_name: str + :ivar role_definition_id: Required. The identifier of the Azure built-in role that defines the + permissions that the Azure Active Directory principal will have on the projected scope. + :vartype role_definition_id: str + :ivar just_in_time_access_policy: The just-in-time access policy setting. + :vartype just_in_time_access_policy: ~azure.mgmt.managedservices.models.JustInTimeAccessPolicy """ _validation = { @@ -103,6 +151,18 @@ def __init__( just_in_time_access_policy: Optional["JustInTimeAccessPolicy"] = None, **kwargs ): + """ + :keyword principal_id: Required. The identifier of the Azure Active Directory principal. + :paramtype principal_id: str + :keyword principal_id_display_name: The display name of the Azure Active Directory principal. + :paramtype principal_id_display_name: str + :keyword role_definition_id: Required. The identifier of the Azure built-in role that defines + the permissions that the Azure Active Directory principal will have on the projected scope. + :paramtype role_definition_id: str + :keyword just_in_time_access_policy: The just-in-time access policy setting. + :paramtype just_in_time_access_policy: + ~azure.mgmt.managedservices.models.JustInTimeAccessPolicy + """ super(EligibleAuthorization, self).__init__(**kwargs) self.principal_id = principal_id self.principal_id_display_name = principal_id_display_name @@ -111,16 +171,16 @@ def __init__( class ErrorDefinition(msrest.serialization.Model): - """Error response indicates Azure Resource Manager is not able to process the incoming request. The reason is provided in the error message. + """The error response indicating why the incoming request wasn’t able to be processed. All required parameters must be populated in order to send to Azure. - :param code: Required. Error code. - :type code: str - :param message: Required. Error message indicating why the operation failed. - :type message: str - :param details: Internal error details. - :type details: list[~azure.mgmt.managedservices.models.ErrorDefinition] + :ivar code: Required. The error code. + :vartype code: str + :ivar message: Required. The error message indicating why the operation failed. + :vartype message: str + :ivar details: The internal error details. + :vartype details: list[~azure.mgmt.managedservices.models.ErrorDefinition] """ _validation = { @@ -142,6 +202,14 @@ def __init__( details: Optional[List["ErrorDefinition"]] = None, **kwargs ): + """ + :keyword code: Required. The error code. + :paramtype code: str + :keyword message: Required. The error message indicating why the operation failed. + :paramtype message: str + :keyword details: The internal error details. + :paramtype details: list[~azure.mgmt.managedservices.models.ErrorDefinition] + """ super(ErrorDefinition, self).__init__(**kwargs) self.code = code self.message = message @@ -151,8 +219,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error response. - :param error: The error details. - :type error: ~azure.mgmt.managedservices.models.ErrorDefinition + :ivar error: The error details. + :vartype error: ~azure.mgmt.managedservices.models.ErrorDefinition """ _attribute_map = { @@ -165,6 +233,10 @@ def __init__( error: Optional["ErrorDefinition"] = None, **kwargs ): + """ + :keyword error: The error details. + :paramtype error: ~azure.mgmt.managedservices.models.ErrorDefinition + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -174,13 +246,17 @@ class JustInTimeAccessPolicy(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param multi_factor_auth_provider: Required. MFA provider. Possible values include: "Azure", + :ivar multi_factor_auth_provider: Required. The multi-factor authorization provider to be used + for just-in-time access requests. Possible values include: "Azure", "None". Default value: "None". - :type multi_factor_auth_provider: str or + :vartype multi_factor_auth_provider: str or ~azure.mgmt.managedservices.models.MultiFactorAuthProvider - :param maximum_activation_duration: Maximum access duration in ISO 8601 format. The default - value is "PT8H". - :type maximum_activation_duration: ~datetime.timedelta + :ivar maximum_activation_duration: The maximum access duration in ISO 8601 format for + just-in-time access requests. + :vartype maximum_activation_duration: ~datetime.timedelta + :ivar managed_by_tenant_approvers: The list of managedByTenant approvers for the eligible + authorization. + :vartype managed_by_tenant_approvers: list[~azure.mgmt.managedservices.models.EligibleApprover] """ _validation = { @@ -190,18 +266,35 @@ class JustInTimeAccessPolicy(msrest.serialization.Model): _attribute_map = { 'multi_factor_auth_provider': {'key': 'multiFactorAuthProvider', 'type': 'str'}, 'maximum_activation_duration': {'key': 'maximumActivationDuration', 'type': 'duration'}, + 'managed_by_tenant_approvers': {'key': 'managedByTenantApprovers', 'type': '[EligibleApprover]'}, } def __init__( self, *, - multi_factor_auth_provider: Union[str, "MultiFactorAuthProvider"], - maximum_activation_duration: Optional[datetime.timedelta] = None, + multi_factor_auth_provider: Union[str, "MultiFactorAuthProvider"] = "None", + maximum_activation_duration: Optional[datetime.timedelta] = "PT8H", + managed_by_tenant_approvers: Optional[List["EligibleApprover"]] = None, **kwargs ): + """ + :keyword multi_factor_auth_provider: Required. The multi-factor authorization provider to be + used for just-in-time access requests. Possible values include: "Azure", "None". Default value: + "None". + :paramtype multi_factor_auth_provider: str or + ~azure.mgmt.managedservices.models.MultiFactorAuthProvider + :keyword maximum_activation_duration: The maximum access duration in ISO 8601 format for + just-in-time access requests. + :paramtype maximum_activation_duration: ~datetime.timedelta + :keyword managed_by_tenant_approvers: The list of managedByTenant approvers for the eligible + authorization. + :paramtype managed_by_tenant_approvers: + list[~azure.mgmt.managedservices.models.EligibleApprover] + """ super(JustInTimeAccessPolicy, self).__init__(**kwargs) self.multi_factor_auth_provider = multi_factor_auth_provider self.maximum_activation_duration = maximum_activation_duration + self.managed_by_tenant_approvers = managed_by_tenant_approvers class MarketplaceRegistrationDefinition(msrest.serialization.Model): @@ -209,16 +302,17 @@ class MarketplaceRegistrationDefinition(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: Properties of a marketplace registration definition. - :type properties: + :ivar properties: The properties of the marketplace registration definition. + :vartype properties: ~azure.mgmt.managedservices.models.MarketplaceRegistrationDefinitionProperties - :param plan: Plan details for the managed services. - :type plan: ~azure.mgmt.managedservices.models.Plan - :ivar id: Fully qualified path of the marketplace registration definition. + :ivar plan: The details for the Managed Services offer’s plan in Azure Marketplace. + :vartype plan: ~azure.mgmt.managedservices.models.Plan + :ivar id: The fully qualified path of the marketplace registration definition. :vartype id: str - :ivar type: Type of the resource. + :ivar type: The type of the Azure resource + (Microsoft.ManagedServices/marketplaceRegistrationDefinitions). :vartype type: str - :ivar name: Name of the marketplace registration definition. + :ivar name: The name of the marketplace registration definition. :vartype name: str """ @@ -243,6 +337,13 @@ def __init__( plan: Optional["Plan"] = None, **kwargs ): + """ + :keyword properties: The properties of the marketplace registration definition. + :paramtype properties: + ~azure.mgmt.managedservices.models.MarketplaceRegistrationDefinitionProperties + :keyword plan: The details for the Managed Services offer’s plan in Azure Marketplace. + :paramtype plan: ~azure.mgmt.managedservices.models.Plan + """ super(MarketplaceRegistrationDefinition, self).__init__(**kwargs) self.properties = properties self.plan = plan @@ -252,13 +353,13 @@ def __init__( class MarketplaceRegistrationDefinitionList(msrest.serialization.Model): - """List of marketplace registration definitions. + """The list of marketplace registration definitions. Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: List of marketplace registration definitions. + :ivar value: The list of marketplace registration definitions. :vartype value: list[~azure.mgmt.managedservices.models.MarketplaceRegistrationDefinition] - :ivar next_link: Link to next page of marketplace registration definitions. + :ivar next_link: The link to the next page of marketplace registration definitions. :vartype next_link: str """ @@ -276,31 +377,35 @@ def __init__( self, **kwargs ): + """ + """ super(MarketplaceRegistrationDefinitionList, self).__init__(**kwargs) self.value = None self.next_link = None class MarketplaceRegistrationDefinitionProperties(msrest.serialization.Model): - """Properties of a marketplace registration definition. + """The properties of the marketplace registration definition. All required parameters must be populated in order to send to Azure. - :param managed_by_tenant_id: Required. Id of the managedBy tenant. - :type managed_by_tenant_id: str - :param authorizations: Required. Authorization tuple containing principal id of the - user/security group or service principal and id of the build-in role. - :type authorizations: list[~azure.mgmt.managedservices.models.Authorization] - :param eligible_authorizations: Eligible PIM authorization tuple containing principal id of the - user/security group or service principal, id of the built-in role, and just-in-time access - policy setting. - :type eligible_authorizations: list[~azure.mgmt.managedservices.models.EligibleAuthorization] - :param offer_display_name: The marketplace offer display name. - :type offer_display_name: str - :param publisher_display_name: The marketplace publisher display name. - :type publisher_display_name: str - :param plan_display_name: The marketplace plan display name. - :type plan_display_name: str + :ivar managed_by_tenant_id: Required. The identifier of the managedBy tenant. + :vartype managed_by_tenant_id: str + :ivar authorizations: Required. The collection of authorization objects describing the access + Azure Active Directory principals in the managedBy tenant will receive on the delegated + resource in the managed tenant. + :vartype authorizations: list[~azure.mgmt.managedservices.models.Authorization] + :ivar eligible_authorizations: The collection of eligible authorization objects describing the + just-in-time access Azure Active Directory principals in the managedBy tenant will receive on + the delegated resource in the managed tenant. + :vartype eligible_authorizations: + list[~azure.mgmt.managedservices.models.EligibleAuthorization] + :ivar offer_display_name: The marketplace offer display name. + :vartype offer_display_name: str + :ivar publisher_display_name: The marketplace publisher display name. + :vartype publisher_display_name: str + :ivar plan_display_name: The marketplace plan display name. + :vartype plan_display_name: str """ _validation = { @@ -328,6 +433,25 @@ def __init__( plan_display_name: Optional[str] = None, **kwargs ): + """ + :keyword managed_by_tenant_id: Required. The identifier of the managedBy tenant. + :paramtype managed_by_tenant_id: str + :keyword authorizations: Required. The collection of authorization objects describing the + access Azure Active Directory principals in the managedBy tenant will receive on the delegated + resource in the managed tenant. + :paramtype authorizations: list[~azure.mgmt.managedservices.models.Authorization] + :keyword eligible_authorizations: The collection of eligible authorization objects describing + the just-in-time access Azure Active Directory principals in the managedBy tenant will receive + on the delegated resource in the managed tenant. + :paramtype eligible_authorizations: + list[~azure.mgmt.managedservices.models.EligibleAuthorization] + :keyword offer_display_name: The marketplace offer display name. + :paramtype offer_display_name: str + :keyword publisher_display_name: The marketplace publisher display name. + :paramtype publisher_display_name: str + :keyword plan_display_name: The marketplace plan display name. + :paramtype plan_display_name: str + """ super(MarketplaceRegistrationDefinitionProperties, self).__init__(**kwargs) self.managed_by_tenant_id = managed_by_tenant_id self.authorizations = authorizations @@ -338,11 +462,11 @@ def __init__( class Operation(msrest.serialization.Model): - """Object that describes a single Microsoft.ManagedServices operation. + """The object that describes a single Microsoft.ManagedServices operation. Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: Operation name: {provider}/{resource}/{operation}. + :ivar name: The operation name with the format: {provider}/{resource}/{operation}. :vartype name: str :ivar display: The object that represents the operation. :vartype display: ~azure.mgmt.managedservices.models.OperationDisplay @@ -362,6 +486,8 @@ def __init__( self, **kwargs ): + """ + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = None @@ -370,15 +496,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider: Microsoft.ManagedServices. - :type provider: str - :param resource: Resource on which the operation is performed: Registration definition, - registration assignment etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: The service provider. + :vartype provider: str + :ivar resource: The resource on which the operation is performed. + :vartype resource: str + :ivar operation: The operation type. + :vartype operation: str + :ivar description: The description of the operation. + :vartype description: str """ _attribute_map = { @@ -397,6 +522,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: The service provider. + :paramtype provider: str + :keyword resource: The resource on which the operation is performed. + :paramtype resource: str + :keyword operation: The operation type. + :paramtype operation: str + :keyword description: The description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -405,11 +540,11 @@ def __init__( class OperationList(msrest.serialization.Model): - """List of the operations. + """The list of the operations. Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: List of Microsoft.ManagedServices operations. + :ivar value: The list of Microsoft.ManagedServices operations. :vartype value: list[~azure.mgmt.managedservices.models.Operation] """ @@ -425,23 +560,25 @@ def __init__( self, **kwargs ): + """ + """ super(OperationList, self).__init__(**kwargs) self.value = None class Plan(msrest.serialization.Model): - """Plan details for the managed services. + """The details for the Managed Services offer’s plan in Azure Marketplace. All required parameters must be populated in order to send to Azure. - :param name: Required. The plan name. - :type name: str - :param publisher: Required. The publisher ID. - :type publisher: str - :param product: Required. The product code. - :type product: str - :param version: Required. The plan's version. - :type version: str + :ivar name: Required. Azure Marketplace plan name. + :vartype name: str + :ivar publisher: Required. Azure Marketplace publisher ID. + :vartype publisher: str + :ivar product: Required. Azure Marketplace product code. + :vartype product: str + :ivar version: Required. Azure Marketplace plan's version. + :vartype version: str """ _validation = { @@ -467,6 +604,16 @@ def __init__( version: str, **kwargs ): + """ + :keyword name: Required. Azure Marketplace plan name. + :paramtype name: str + :keyword publisher: Required. Azure Marketplace publisher ID. + :paramtype publisher: str + :keyword product: Required. Azure Marketplace product code. + :paramtype product: str + :keyword version: Required. Azure Marketplace plan's version. + :paramtype version: str + """ super(Plan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -475,24 +622,27 @@ def __init__( class RegistrationAssignment(msrest.serialization.Model): - """Registration assignment. + """The registration assignment. Variables are only populated by the server, and will be ignored when sending a request. - :param properties: Properties of a registration assignment. - :type properties: ~azure.mgmt.managedservices.models.RegistrationAssignmentProperties + :ivar properties: The properties of a registration assignment. + :vartype properties: ~azure.mgmt.managedservices.models.RegistrationAssignmentProperties :ivar id: The fully qualified path of the registration assignment. :vartype id: str - :ivar type: Type of the resource. + :ivar type: The type of the Azure resource (Microsoft.ManagedServices/registrationAssignments). :vartype type: str - :ivar name: Name of the registration assignment. + :ivar name: The name of the registration assignment. :vartype name: str + :ivar system_data: The metadata for the registration assignment resource. + :vartype system_data: ~azure.mgmt.managedservices.models.SystemData """ _validation = { 'id': {'readonly': True}, 'type': {'readonly': True}, 'name': {'readonly': True}, + 'system_data': {'readonly': True}, } _attribute_map = { @@ -500,6 +650,7 @@ class RegistrationAssignment(msrest.serialization.Model): 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( @@ -508,21 +659,26 @@ def __init__( properties: Optional["RegistrationAssignmentProperties"] = None, **kwargs ): + """ + :keyword properties: The properties of a registration assignment. + :paramtype properties: ~azure.mgmt.managedservices.models.RegistrationAssignmentProperties + """ super(RegistrationAssignment, self).__init__(**kwargs) self.properties = properties self.id = None self.type = None self.name = None + self.system_data = None class RegistrationAssignmentList(msrest.serialization.Model): - """List of registration assignments. + """The list of registration assignments. Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: List of registration assignments. + :ivar value: The list of registration assignments. :vartype value: list[~azure.mgmt.managedservices.models.RegistrationAssignment] - :ivar next_link: Link to next page of registration assignments. + :ivar next_link: The link to the next page of registration assignments. :vartype next_link: str """ @@ -540,26 +696,29 @@ def __init__( self, **kwargs ): + """ + """ super(RegistrationAssignmentList, self).__init__(**kwargs) self.value = None self.next_link = None class RegistrationAssignmentProperties(msrest.serialization.Model): - """Properties of a registration assignment. + """The properties of the registration assignment. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param registration_definition_id: Required. Fully qualified path of the registration + :ivar registration_definition_id: Required. The fully qualified path of the registration definition. - :type registration_definition_id: str - :ivar provisioning_state: Current state of the registration assignment. Possible values - include: "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", - "Deleted", "Canceled", "Failed", "Succeeded", "Updating". + :vartype registration_definition_id: str + :ivar provisioning_state: The current provisioning state of the registration assignment. + Possible values include: "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", + "Deleting", "Deleted", "Canceled", "Failed", "Succeeded", "Updating". :vartype provisioning_state: str or ~azure.mgmt.managedservices.models.ProvisioningState - :ivar registration_definition: Registration definition inside registration assignment. + :ivar registration_definition: The registration definition associated with the registration + assignment. :vartype registration_definition: ~azure.mgmt.managedservices.models.RegistrationAssignmentPropertiesRegistrationDefinition """ @@ -582,6 +741,11 @@ def __init__( registration_definition_id: str, **kwargs ): + """ + :keyword registration_definition_id: Required. The fully qualified path of the registration + definition. + :paramtype registration_definition_id: str + """ super(RegistrationAssignmentProperties, self).__init__(**kwargs) self.registration_definition_id = registration_definition_id self.provisioning_state = None @@ -589,27 +753,31 @@ def __init__( class RegistrationAssignmentPropertiesRegistrationDefinition(msrest.serialization.Model): - """Registration definition inside registration assignment. + """The registration definition associated with the registration assignment. Variables are only populated by the server, and will be ignored when sending a request. - :param properties: Properties of registration definition inside registration assignment. - :type properties: + :ivar properties: The properties of the registration definition associated with the + registration assignment. + :vartype properties: ~azure.mgmt.managedservices.models.RegistrationAssignmentPropertiesRegistrationDefinitionProperties - :param plan: Plan details for the managed services. - :type plan: ~azure.mgmt.managedservices.models.Plan - :ivar id: Fully qualified path of the registration definition. + :ivar plan: The details for the Managed Services offer’s plan in Azure Marketplace. + :vartype plan: ~azure.mgmt.managedservices.models.Plan + :ivar id: The fully qualified path of the registration definition. :vartype id: str - :ivar type: Type of the resource (Microsoft.ManagedServices/registrationDefinitions). + :ivar type: The type of the Azure resource (Microsoft.ManagedServices/registrationDefinitions). :vartype type: str - :ivar name: Name of the registration definition. + :ivar name: The name of the registration definition. :vartype name: str + :ivar system_data: The metadata for the registration definition resource. + :vartype system_data: ~azure.mgmt.managedservices.models.SystemData """ _validation = { 'id': {'readonly': True}, 'type': {'readonly': True}, 'name': {'readonly': True}, + 'system_data': {'readonly': True}, } _attribute_map = { @@ -618,6 +786,7 @@ class RegistrationAssignmentPropertiesRegistrationDefinition(msrest.serializatio 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( @@ -627,40 +796,51 @@ def __init__( plan: Optional["Plan"] = None, **kwargs ): + """ + :keyword properties: The properties of the registration definition associated with the + registration assignment. + :paramtype properties: + ~azure.mgmt.managedservices.models.RegistrationAssignmentPropertiesRegistrationDefinitionProperties + :keyword plan: The details for the Managed Services offer’s plan in Azure Marketplace. + :paramtype plan: ~azure.mgmt.managedservices.models.Plan + """ super(RegistrationAssignmentPropertiesRegistrationDefinition, self).__init__(**kwargs) self.properties = properties self.plan = plan self.id = None self.type = None self.name = None + self.system_data = None class RegistrationAssignmentPropertiesRegistrationDefinitionProperties(msrest.serialization.Model): - """Properties of registration definition inside registration assignment. - - :param description: Description of the registration definition. - :type description: str - :param authorizations: Authorization tuple containing principal id of the user/security group - or service principal and id of the build-in role. - :type authorizations: list[~azure.mgmt.managedservices.models.Authorization] - :param eligible_authorizations: Eligible PIM authorization tuple containing principal id of the - user/security group or service principal, id of the built-in role, and just-in-time access - policy setting. - :type eligible_authorizations: list[~azure.mgmt.managedservices.models.EligibleAuthorization] - :param registration_definition_name: Name of the registration definition. - :type registration_definition_name: str - :param provisioning_state: Current state of the registration definition. Possible values - include: "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", - "Deleted", "Canceled", "Failed", "Succeeded", "Updating". - :type provisioning_state: str or ~azure.mgmt.managedservices.models.ProvisioningState - :param managee_tenant_id: Id of the home tenant. - :type managee_tenant_id: str - :param managee_tenant_name: Name of the home tenant. - :type managee_tenant_name: str - :param managed_by_tenant_id: Id of the managedBy tenant. - :type managed_by_tenant_id: str - :param managed_by_tenant_name: Name of the managedBy tenant. - :type managed_by_tenant_name: str + """The properties of the registration definition associated with the registration assignment. + + :ivar description: The description of the registration definition. + :vartype description: str + :ivar authorizations: The collection of authorization objects describing the access Azure + Active Directory principals in the managedBy tenant will receive on the delegated resource in + the managed tenant. + :vartype authorizations: list[~azure.mgmt.managedservices.models.Authorization] + :ivar eligible_authorizations: The collection of eligible authorization objects describing the + just-in-time access Azure Active Directory principals in the managedBy tenant will receive on + the delegated resource in the managed tenant. + :vartype eligible_authorizations: + list[~azure.mgmt.managedservices.models.EligibleAuthorization] + :ivar registration_definition_name: The name of the registration definition. + :vartype registration_definition_name: str + :ivar provisioning_state: The current provisioning state of the registration definition. + Possible values include: "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", + "Deleting", "Deleted", "Canceled", "Failed", "Succeeded", "Updating". + :vartype provisioning_state: str or ~azure.mgmt.managedservices.models.ProvisioningState + :ivar managee_tenant_id: The identifier of the managed tenant. + :vartype managee_tenant_id: str + :ivar managee_tenant_name: The name of the managed tenant. + :vartype managee_tenant_name: str + :ivar managed_by_tenant_id: The identifier of the managedBy tenant. + :vartype managed_by_tenant_id: str + :ivar managed_by_tenant_name: The name of the managedBy tenant. + :vartype managed_by_tenant_name: str """ _attribute_map = { @@ -689,6 +869,33 @@ def __init__( managed_by_tenant_name: Optional[str] = None, **kwargs ): + """ + :keyword description: The description of the registration definition. + :paramtype description: str + :keyword authorizations: The collection of authorization objects describing the access Azure + Active Directory principals in the managedBy tenant will receive on the delegated resource in + the managed tenant. + :paramtype authorizations: list[~azure.mgmt.managedservices.models.Authorization] + :keyword eligible_authorizations: The collection of eligible authorization objects describing + the just-in-time access Azure Active Directory principals in the managedBy tenant will receive + on the delegated resource in the managed tenant. + :paramtype eligible_authorizations: + list[~azure.mgmt.managedservices.models.EligibleAuthorization] + :keyword registration_definition_name: The name of the registration definition. + :paramtype registration_definition_name: str + :keyword provisioning_state: The current provisioning state of the registration definition. + Possible values include: "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", + "Deleting", "Deleted", "Canceled", "Failed", "Succeeded", "Updating". + :paramtype provisioning_state: str or ~azure.mgmt.managedservices.models.ProvisioningState + :keyword managee_tenant_id: The identifier of the managed tenant. + :paramtype managee_tenant_id: str + :keyword managee_tenant_name: The name of the managed tenant. + :paramtype managee_tenant_name: str + :keyword managed_by_tenant_id: The identifier of the managedBy tenant. + :paramtype managed_by_tenant_id: str + :keyword managed_by_tenant_name: The name of the managedBy tenant. + :paramtype managed_by_tenant_name: str + """ super(RegistrationAssignmentPropertiesRegistrationDefinitionProperties, self).__init__(**kwargs) self.description = description self.authorizations = authorizations @@ -702,26 +909,29 @@ def __init__( class RegistrationDefinition(msrest.serialization.Model): - """Registration definition. + """The registration definition. Variables are only populated by the server, and will be ignored when sending a request. - :param properties: Properties of a registration definition. - :type properties: ~azure.mgmt.managedservices.models.RegistrationDefinitionProperties - :param plan: Plan details for the managed services. - :type plan: ~azure.mgmt.managedservices.models.Plan - :ivar id: Fully qualified path of the registration definition. + :ivar properties: The properties of a registration definition. + :vartype properties: ~azure.mgmt.managedservices.models.RegistrationDefinitionProperties + :ivar plan: The details for the Managed Services offer’s plan in Azure Marketplace. + :vartype plan: ~azure.mgmt.managedservices.models.Plan + :ivar id: The fully qualified path of the registration definition. :vartype id: str - :ivar type: Type of the resource. + :ivar type: The type of the Azure resource (Microsoft.ManagedServices/registrationDefinitions). :vartype type: str - :ivar name: Name of the registration definition. + :ivar name: The name of the registration definition. :vartype name: str + :ivar system_data: The metadata for the registration assignment resource. + :vartype system_data: ~azure.mgmt.managedservices.models.SystemData """ _validation = { 'id': {'readonly': True}, 'type': {'readonly': True}, 'name': {'readonly': True}, + 'system_data': {'readonly': True}, } _attribute_map = { @@ -730,6 +940,7 @@ class RegistrationDefinition(msrest.serialization.Model): 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( @@ -739,22 +950,29 @@ def __init__( plan: Optional["Plan"] = None, **kwargs ): + """ + :keyword properties: The properties of a registration definition. + :paramtype properties: ~azure.mgmt.managedservices.models.RegistrationDefinitionProperties + :keyword plan: The details for the Managed Services offer’s plan in Azure Marketplace. + :paramtype plan: ~azure.mgmt.managedservices.models.Plan + """ super(RegistrationDefinition, self).__init__(**kwargs) self.properties = properties self.plan = plan self.id = None self.type = None self.name = None + self.system_data = None class RegistrationDefinitionList(msrest.serialization.Model): - """List of registration definitions. + """The list of registration definitions. Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: List of registration definitions. + :ivar value: The list of registration definitions. :vartype value: list[~azure.mgmt.managedservices.models.RegistrationDefinition] - :ivar next_link: Link to next page of registration definitions. + :ivar next_link: The link to the next page of registration definitions. :vartype next_link: str """ @@ -772,36 +990,44 @@ def __init__( self, **kwargs ): + """ + """ super(RegistrationDefinitionList, self).__init__(**kwargs) self.value = None self.next_link = None class RegistrationDefinitionProperties(msrest.serialization.Model): - """Properties of a registration definition. + """The properties of a registration definition. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param description: Description of the registration definition. - :type description: str - :param authorizations: Required. Authorization tuple containing principal id of the - user/security group or service principal and id of the build-in role. - :type authorizations: list[~azure.mgmt.managedservices.models.Authorization] - :param eligible_authorizations: Eligible PIM authorization tuple containing principal id of the - user/security group or service principal, id of the built-in role, and just-in-time access - policy setting. - :type eligible_authorizations: list[~azure.mgmt.managedservices.models.EligibleAuthorization] - :param registration_definition_name: Name of the registration definition. - :type registration_definition_name: str - :param managed_by_tenant_id: Required. Id of the managedBy tenant. - :type managed_by_tenant_id: str - :ivar provisioning_state: Current state of the registration definition. Possible values - include: "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", "Deleting", - "Deleted", "Canceled", "Failed", "Succeeded", "Updating". + :ivar description: The description of the registration definition. + :vartype description: str + :ivar authorizations: Required. The collection of authorization objects describing the access + Azure Active Directory principals in the managedBy tenant will receive on the delegated + resource in the managed tenant. + :vartype authorizations: list[~azure.mgmt.managedservices.models.Authorization] + :ivar eligible_authorizations: The collection of eligible authorization objects describing the + just-in-time access Azure Active Directory principals in the managedBy tenant will receive on + the delegated resource in the managed tenant. + :vartype eligible_authorizations: + list[~azure.mgmt.managedservices.models.EligibleAuthorization] + :ivar registration_definition_name: The name of the registration definition. + :vartype registration_definition_name: str + :ivar managed_by_tenant_id: Required. The identifier of the managedBy tenant. + :vartype managed_by_tenant_id: str + :ivar provisioning_state: The current provisioning state of the registration definition. + Possible values include: "NotSpecified", "Accepted", "Running", "Ready", "Creating", "Created", + "Deleting", "Deleted", "Canceled", "Failed", "Succeeded", "Updating". :vartype provisioning_state: str or ~azure.mgmt.managedservices.models.ProvisioningState - :ivar managed_by_tenant_name: Name of the managedBy tenant. + :ivar managee_tenant_id: The identifier of the managed tenant. + :vartype managee_tenant_id: str + :ivar managee_tenant_name: The name of the managed tenant. + :vartype managee_tenant_name: str + :ivar managed_by_tenant_name: The name of the managedBy tenant. :vartype managed_by_tenant_name: str """ @@ -809,6 +1035,8 @@ class RegistrationDefinitionProperties(msrest.serialization.Model): 'authorizations': {'required': True}, 'managed_by_tenant_id': {'required': True}, 'provisioning_state': {'readonly': True}, + 'managee_tenant_id': {'readonly': True}, + 'managee_tenant_name': {'readonly': True}, 'managed_by_tenant_name': {'readonly': True}, } @@ -819,6 +1047,8 @@ class RegistrationDefinitionProperties(msrest.serialization.Model): 'registration_definition_name': {'key': 'registrationDefinitionName', 'type': 'str'}, 'managed_by_tenant_id': {'key': 'managedByTenantId', 'type': 'str'}, 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'managee_tenant_id': {'key': 'manageeTenantId', 'type': 'str'}, + 'managee_tenant_name': {'key': 'manageeTenantName', 'type': 'str'}, 'managed_by_tenant_name': {'key': 'managedByTenantName', 'type': 'str'}, } @@ -832,6 +1062,23 @@ def __init__( registration_definition_name: Optional[str] = None, **kwargs ): + """ + :keyword description: The description of the registration definition. + :paramtype description: str + :keyword authorizations: Required. The collection of authorization objects describing the + access Azure Active Directory principals in the managedBy tenant will receive on the delegated + resource in the managed tenant. + :paramtype authorizations: list[~azure.mgmt.managedservices.models.Authorization] + :keyword eligible_authorizations: The collection of eligible authorization objects describing + the just-in-time access Azure Active Directory principals in the managedBy tenant will receive + on the delegated resource in the managed tenant. + :paramtype eligible_authorizations: + list[~azure.mgmt.managedservices.models.EligibleAuthorization] + :keyword registration_definition_name: The name of the registration definition. + :paramtype registration_definition_name: str + :keyword managed_by_tenant_id: Required. The identifier of the managedBy tenant. + :paramtype managed_by_tenant_id: str + """ super(RegistrationDefinitionProperties, self).__init__(**kwargs) self.description = description self.authorizations = authorizations @@ -839,4 +1086,71 @@ def __init__( self.registration_definition_name = registration_definition_name self.managed_by_tenant_id = managed_by_tenant_id self.provisioning_state = None + self.managee_tenant_id = None + self.managee_tenant_name = None self.managed_by_tenant_name = None + + +class SystemData(msrest.serialization.Model): + """The metadata associated with an Azure resource. + + :ivar created_by: A string identifier for the identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource: user, application, + managedIdentity. + :vartype created_by_type: str + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: A string identifier for the identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource: user, + application, managedIdentity. + :vartype last_modified_by_type: str + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[str] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[str] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: A string identifier for the identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource: user, application, + managedIdentity. + :paramtype created_by_type: str + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: A string identifier for the identity that last modified the + resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource: user, + application, managedIdentity. + :paramtype last_modified_by_type: str + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at diff --git a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/__init__.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/__init__.py index e52c6c86461f..7fe69ff48a7c 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/__init__.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/__init__.py @@ -11,6 +11,7 @@ from ._marketplace_registration_definitions_operations import MarketplaceRegistrationDefinitionsOperations from ._marketplace_registration_definitions_without_scope_operations import MarketplaceRegistrationDefinitionsWithoutScopeOperations from ._operations import Operations +from ._operations_with_scope_operations import OperationsWithScopeOperations __all__ = [ 'RegistrationDefinitionsOperations', @@ -18,4 +19,5 @@ 'MarketplaceRegistrationDefinitionsOperations', 'MarketplaceRegistrationDefinitionsWithoutScopeOperations', 'Operations', + 'OperationsWithScopeOperations', ] diff --git a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_marketplace_registration_definitions_operations.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_marketplace_registration_definitions_operations.py index 870efd9901ce..1b19fb634247 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_marketplace_registration_definitions_operations.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_marketplace_registration_definitions_operations.py @@ -5,23 +5,93 @@ # 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_list_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.ManagedServices/marketplaceRegistrationDefinitions') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + 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( + scope: str, + marketplace_identifier: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.ManagedServices/marketplaceRegistrationDefinitions/{marketplaceIdentifier}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "marketplaceIdentifier": _SERIALIZER.url("marketplace_identifier", marketplace_identifier, '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 + ) class MarketplaceRegistrationDefinitionsOperations(object): """MarketplaceRegistrationDefinitionsOperations operations. @@ -45,23 +115,24 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MarketplaceRegistrationDefinitionList"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.MarketplaceRegistrationDefinitionList"]: """Gets a list of the marketplace registration definitions for the marketplace identifier. - :param scope: Scope of the resource. + :param scope: The scope of the resource. :type scope: str - :param filter: The filter query parameter. Might be used to filter marketplace registration - definition by plan identifier, publisher, version etc. + :param filter: The filter query parameter to filter managed services resources by. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MarketplaceRegistrationDefinitionList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.managedservices.models.MarketplaceRegistrationDefinitionList] + :return: An iterator like instance of either MarketplaceRegistrationDefinitionList or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedservices.models.MarketplaceRegistrationDefinitionList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MarketplaceRegistrationDefinitionList"] @@ -69,36 +140,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - 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 - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + filter=filter, + 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( + scope=scope, + filter=filter, + 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('MarketplaceRegistrationDefinitionList', pipeline_response) + deserialized = self._deserialize("MarketplaceRegistrationDefinitionList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,29 +177,30 @@ 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': '/{scope}/providers/Microsoft.ManagedServices/marketplaceRegistrationDefinitions'} # type: ignore + @distributed_trace def get( self, - scope, # type: str - marketplace_identifier, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MarketplaceRegistrationDefinition" + scope: str, + marketplace_identifier: str, + **kwargs: Any + ) -> "_models.MarketplaceRegistrationDefinition": """Get the marketplace registration definition for the marketplace identifier. - :param scope: Scope of the resource. + :param scope: The scope of the resource. :type scope: str - :param marketplace_identifier: Market place identifier. Expected Formats - + :param marketplace_identifier: The Azure Marketplace identifier. Expected formats: {publisher}.{product[-preview]}.{planName}.{version} or {publisher}.{product[-preview]}.{planName} or {publisher}.{product[-preview]} or {publisher}). :type marketplace_identifier: str @@ -147,32 +214,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'marketplaceIdentifier': self._serialize.url("marketplace_identifier", marketplace_identifier, '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( + scope=scope, + marketplace_identifier=marketplace_identifier, + 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 = 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('MarketplaceRegistrationDefinition', pipeline_response) @@ -181,4 +238,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.ManagedServices/marketplaceRegistrationDefinitions/{marketplaceIdentifier}'} # type: ignore + diff --git a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_marketplace_registration_definitions_without_scope_operations.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_marketplace_registration_definitions_without_scope_operations.py index 2ef4e26064c1..10a4c70d43da 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_marketplace_registration_definitions_without_scope_operations.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_marketplace_registration_definitions_without_scope_operations.py @@ -5,23 +5,85 @@ # 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_list_request( + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.ManagedServices/marketplaceRegistrationDefinitions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + 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( + marketplace_identifier: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.ManagedServices/marketplaceRegistrationDefinitions/{marketplaceIdentifier}') + path_format_arguments = { + "marketplaceIdentifier": _SERIALIZER.url("marketplace_identifier", marketplace_identifier, '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 + ) class MarketplaceRegistrationDefinitionsWithoutScopeOperations(object): """MarketplaceRegistrationDefinitionsWithoutScopeOperations operations. @@ -45,20 +107,21 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MarketplaceRegistrationDefinitionList"] + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.MarketplaceRegistrationDefinitionList"]: """Gets a list of the marketplace registration definitions for the marketplace identifier. - :param filter: The filter query parameter. Might be used to filter marketplace registration - definition by plan identifier, publisher, version etc. + :param filter: The filter query parameter to filter managed services resources by. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MarketplaceRegistrationDefinitionList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.managedservices.models.MarketplaceRegistrationDefinitionList] + :return: An iterator like instance of either MarketplaceRegistrationDefinitionList or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedservices.models.MarketplaceRegistrationDefinitionList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MarketplaceRegistrationDefinitionList"] @@ -66,32 +129,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - 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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + filter=filter, + 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( + filter=filter, + 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('MarketplaceRegistrationDefinitionList', pipeline_response) + deserialized = self._deserialize("MarketplaceRegistrationDefinitionList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -104,26 +164,27 @@ 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.ManagedServices/marketplaceRegistrationDefinitions'} # type: ignore + @distributed_trace def get( self, - marketplace_identifier, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MarketplaceRegistrationDefinition" + marketplace_identifier: str, + **kwargs: Any + ) -> "_models.MarketplaceRegistrationDefinition": """Get the marketplace registration definition for the marketplace identifier. - :param marketplace_identifier: Market place identifier. Expected Formats - + :param marketplace_identifier: The Azure Marketplace identifier. Expected formats: {publisher}.{product[-preview]}.{planName}.{version} or {publisher}.{product[-preview]}.{planName} or {publisher}.{product[-preview]} or {publisher}). :type marketplace_identifier: str @@ -137,31 +198,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - accept = "application/json" - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'marketplaceIdentifier': self._serialize.url("marketplace_identifier", marketplace_identifier, '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( + marketplace_identifier=marketplace_identifier, + 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 = 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('MarketplaceRegistrationDefinition', pipeline_response) @@ -170,4 +221,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.ManagedServices/marketplaceRegistrationDefinitions/{marketplaceIdentifier}'} # type: ignore + diff --git a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_operations.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_operations.py index 416060e95be0..7721c7af7105 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_operations.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_operations.py @@ -5,22 +5,49 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import 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') +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 = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.ManagedServices/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. @@ -44,11 +71,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.OperationList" + **kwargs: Any + ) -> "_models.OperationList": """Gets a list of the operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -61,27 +88,20 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - accept = "application/json" - - # 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) - # 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('OperationList', pipeline_response) @@ -90,4 +110,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/providers/Microsoft.ManagedServices/operations'} # type: ignore + diff --git a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_operations_with_scope_operations.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_operations_with_scope_operations.py new file mode 100644 index 000000000000..b9435c810251 --- /dev/null +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_operations_with_scope_operations.py @@ -0,0 +1,125 @@ +# 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. +# -------------------------------------------------------------------------- +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 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 +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_list_request( + scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.ManagedServices/operations') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + 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 + ) + +class OperationsWithScopeOperations(object): + """OperationsWithScopeOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.managedservices.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + scope: str, + **kwargs: Any + ) -> "_models.OperationList": + """Gets a list of the operations with the scope. + + :param scope: The scope of the resource. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationList, or the result of cls(response) + :rtype: ~azure.mgmt.managedservices.models.OperationList + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_list_request( + scope=scope, + template_url=self.list.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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('OperationList', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {'url': '/{scope}/providers/Microsoft.ManagedServices/operations'} # type: ignore + diff --git a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_registration_assignments_operations.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_registration_assignments_operations.py index 2acf9413aeba..b28e4dcf87d7 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_registration_assignments_operations.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_registration_assignments_operations.py @@ -5,25 +5,178 @@ # 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_get_request( + scope: str, + registration_assignment_id: str, + *, + expand_registration_definition: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.ManagedServices/registrationAssignments/{registrationAssignmentId}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "registrationAssignmentId": _SERIALIZER.url("registration_assignment_id", registration_assignment_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand_registration_definition is not None: + query_parameters['$expandRegistrationDefinition'] = _SERIALIZER.query("expand_registration_definition", expand_registration_definition, 'bool') + 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_delete_request_initial( + scope: str, + registration_assignment_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.ManagedServices/registrationAssignments/{registrationAssignmentId}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "registrationAssignmentId": _SERIALIZER.url("registration_assignment_id", registration_assignment_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 + ) + + +def build_create_or_update_request_initial( + scope: str, + registration_assignment_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.ManagedServices/registrationAssignments/{registrationAssignmentId}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "registrationAssignmentId": _SERIALIZER.url("registration_assignment_id", registration_assignment_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_list_request( + scope: str, + *, + expand_registration_definition: Optional[bool] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.ManagedServices/registrationAssignments') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand_registration_definition is not None: + query_parameters['$expandRegistrationDefinition'] = _SERIALIZER.query("expand_registration_definition", expand_registration_definition, 'bool') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, '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 RegistrationAssignmentsOperations(object): """RegistrationAssignmentsOperations operations. @@ -47,22 +200,22 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - scope, # type: str - registration_assignment_id, # type: str - expand_registration_definition=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> "_models.RegistrationAssignment" - """Gets the details of specified registration assignment. - - :param scope: Scope of the resource. + scope: str, + registration_assignment_id: str, + expand_registration_definition: Optional[bool] = None, + **kwargs: Any + ) -> "_models.RegistrationAssignment": + """Gets the details of the specified registration assignment. + + :param scope: The scope of the resource. :type scope: str - :param registration_assignment_id: Guid of the registration assignment. + :param registration_assignment_id: The GUID of the registration assignment. :type registration_assignment_id: str - :param expand_registration_definition: Tells whether to return registration definition details - also along with registration assignment details. + :param expand_registration_definition: The flag indicating whether to return the registration + definition details along with the registration assignment details. :type expand_registration_definition: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: RegistrationAssignment, or the result of cls(response) @@ -74,34 +227,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'registrationAssignmentId': self._serialize.url("registration_assignment_id", registration_assignment_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand_registration_definition is not None: - query_parameters['$expandRegistrationDefinition'] = self._serialize.query("expand_registration_definition", expand_registration_definition, 'bool') - 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( + scope=scope, + registration_assignment_id=registration_assignment_id, + expand_registration_definition=expand_registration_definition, + 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 = 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('RegistrationAssignment', pipeline_response) @@ -110,77 +252,70 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.ManagedServices/registrationAssignments/{registrationAssignmentId}'} # type: ignore + def _delete_initial( self, - scope, # type: str - registration_assignment_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + scope: str, + registration_assignment_id: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'registrationAssignmentId': self._serialize.url("registration_assignment_id", registration_assignment_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_initial( + scope=scope, + registration_assignment_id=registration_assignment_id, + 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 [200, 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) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/{scope}/providers/Microsoft.ManagedServices/registrationAssignments/{registrationAssignmentId}'} # type: ignore + + @distributed_trace def begin_delete( self, - scope, # type: str - registration_assignment_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + scope: str, + registration_assignment_id: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes the specified registration assignment. - :param scope: Scope of the resource. + :param scope: The scope of the resource. :type scope: str - :param registration_assignment_id: Guid of the registration assignment. + :param registration_assignment_id: The GUID of the registration assignment. :type registration_assignment_id: 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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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. + :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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :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[None] lro_delay = kwargs.pop( 'polling_interval', @@ -194,20 +329,14 @@ 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): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'registrationAssignmentId': self._serialize.url("registration_assignment_id", registration_assignment_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -219,53 +348,42 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/{scope}/providers/Microsoft.ManagedServices/registrationAssignments/{registrationAssignmentId}'} # type: ignore def _create_or_update_initial( self, - scope, # type: str - registration_assignment_id, # type: str - request_body, # type: "_models.RegistrationAssignment" - **kwargs # type: Any - ): - # type: (...) -> "_models.RegistrationAssignment" + scope: str, + registration_assignment_id: str, + request_body: "_models.RegistrationAssignment", + **kwargs: Any + ) -> "_models.RegistrationAssignment": cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistrationAssignment"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - 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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'registrationAssignmentId': self._serialize.url("registration_assignment_id", registration_assignment_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(request_body, 'RegistrationAssignment') - # 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_initial( + scope=scope, + registration_assignment_id=registration_assignment_id, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.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(request_body, 'RegistrationAssignment') - 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, 201]: 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) if response.status_code == 200: deserialized = self._deserialize('RegistrationAssignment', pipeline_response) @@ -277,35 +395,42 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/{scope}/providers/Microsoft.ManagedServices/registrationAssignments/{registrationAssignmentId}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - scope, # type: str - registration_assignment_id, # type: str - request_body, # type: "_models.RegistrationAssignment" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.RegistrationAssignment"] + scope: str, + registration_assignment_id: str, + request_body: "_models.RegistrationAssignment", + **kwargs: Any + ) -> LROPoller["_models.RegistrationAssignment"]: """Creates or updates a registration assignment. - :param scope: Scope of the resource. + :param scope: The scope of the resource. :type scope: str - :param registration_assignment_id: Guid of the registration assignment. + :param registration_assignment_id: The GUID of the registration assignment. :type registration_assignment_id: str :param request_body: The parameters required to create new registration assignment. :type request_body: ~azure.mgmt.managedservices.models.RegistrationAssignment :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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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 RegistrationAssignment or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedservices.models.RegistrationAssignment] - :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 RegistrationAssignment or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedservices.models.RegistrationAssignment] + :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["_models.RegistrationAssignment"] lro_delay = kwargs.pop( 'polling_interval', @@ -317,26 +442,21 @@ def begin_create_or_update( scope=scope, registration_assignment_id=registration_assignment_id, request_body=request_body, + 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('RegistrationAssignment', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'registrationAssignmentId': self._serialize.url("registration_assignment_id", registration_assignment_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -348,25 +468,31 @@ 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': '/{scope}/providers/Microsoft.ManagedServices/registrationAssignments/{registrationAssignmentId}'} # type: ignore + @distributed_trace def list( self, - scope, # type: str - expand_registration_definition=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RegistrationAssignmentList"] + scope: str, + expand_registration_definition: Optional[bool] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RegistrationAssignmentList"]: """Gets a list of the registration assignments. - :param scope: Scope of the resource. + :param scope: The scope of the resource. :type scope: str - :param expand_registration_definition: Tells whether to return registration definition details - also along with registration assignment details. + :param expand_registration_definition: The flag indicating whether to return the registration + definition details along with the registration assignment details. :type expand_registration_definition: bool + :param filter: The filter query parameter to filter managed services resources by. + :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistrationAssignmentList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.managedservices.models.RegistrationAssignmentList] + :return: An iterator like instance of either RegistrationAssignmentList or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedservices.models.RegistrationAssignmentList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistrationAssignmentList"] @@ -374,36 +500,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - 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 - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand_registration_definition is not None: - query_parameters['$expandRegistrationDefinition'] = self._serialize.query("expand_registration_definition", expand_registration_definition, 'bool') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + expand_registration_definition=expand_registration_definition, + filter=filter, + 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( + scope=scope, + expand_registration_definition=expand_registration_definition, + filter=filter, + 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('RegistrationAssignmentList', pipeline_response) + deserialized = self._deserialize("RegistrationAssignmentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -416,12 +539,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/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_registration_definitions_operations.py b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_registration_definitions_operations.py index 4b644ac1a0c2..7e3c99be247e 100644 --- a/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_registration_definitions_operations.py +++ b/sdk/managedservices/azure-mgmt-managedservices/azure/mgmt/managedservices/operations/_registration_definitions_operations.py @@ -5,25 +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, 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_get_request( + scope: str, + registration_definition_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.ManagedServices/registrationDefinitions/{registrationDefinitionId}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "registrationDefinitionId": _SERIALIZER.url("registration_definition_id", registration_definition_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_delete_request( + registration_definition_id: str, + scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.ManagedServices/registrationDefinitions/{registrationDefinitionId}') + path_format_arguments = { + "registrationDefinitionId": _SERIALIZER.url("registration_definition_id", registration_definition_id, 'str'), + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + 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 + ) + + +def build_create_or_update_request_initial( + registration_definition_id: str, + scope: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.ManagedServices/registrationDefinitions/{registrationDefinitionId}') + path_format_arguments = { + "registrationDefinitionId": _SERIALIZER.url("registration_definition_id", registration_definition_id, 'str'), + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + 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_list_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.ManagedServices/registrationDefinitions') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + 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 filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, '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 RegistrationDefinitionsOperations(object): """RegistrationDefinitionsOperations operations. @@ -47,18 +193,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - scope, # type: str - registration_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RegistrationDefinition" + scope: str, + registration_definition_id: str, + **kwargs: Any + ) -> "_models.RegistrationDefinition": """Gets the registration definition details. - :param scope: Scope of the resource. + :param scope: The scope of the resource. :type scope: str - :param registration_definition_id: Guid of the registration definition. + :param registration_definition_id: The GUID of the registration definition. :type registration_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RegistrationDefinition, or the result of cls(response) @@ -70,32 +216,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'registrationDefinitionId': self._serialize.url("registration_definition_id", registration_definition_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( + scope=scope, + registration_definition_id=registration_definition_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 = 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('RegistrationDefinition', pipeline_response) @@ -104,20 +240,22 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.ManagedServices/registrationDefinitions/{registrationDefinitionId}'} # type: ignore + + @distributed_trace def delete( self, - registration_definition_id, # type: str - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + registration_definition_id: str, + scope: str, + **kwargs: Any + ) -> None: """Deletes the registration definition. - :param registration_definition_id: Guid of the registration definition. + :param registration_definition_id: The GUID of the registration definition. :type registration_definition_id: str - :param scope: Scope of the resource. + :param scope: The scope of the resource. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) @@ -129,32 +267,22 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'registrationDefinitionId': self._serialize.url("registration_definition_id", registration_definition_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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( + registration_definition_id=registration_definition_id, + scope=scope, + 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: @@ -162,51 +290,40 @@ def delete( delete.metadata = {'url': '/{scope}/providers/Microsoft.ManagedServices/registrationDefinitions/{registrationDefinitionId}'} # type: ignore + def _create_or_update_initial( self, - registration_definition_id, # type: str - scope, # type: str - request_body, # type: "_models.RegistrationDefinition" - **kwargs # type: Any - ): - # type: (...) -> "_models.RegistrationDefinition" + registration_definition_id: str, + scope: str, + request_body: "_models.RegistrationDefinition", + **kwargs: Any + ) -> "_models.RegistrationDefinition": cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistrationDefinition"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - 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 = { - 'registrationDefinitionId': self._serialize.url("registration_definition_id", registration_definition_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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(request_body, 'RegistrationDefinition') - # 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_initial( + registration_definition_id=registration_definition_id, + scope=scope, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.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(request_body, 'RegistrationDefinition') - 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, 201]: 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) if response.status_code == 200: deserialized = self._deserialize('RegistrationDefinition', pipeline_response) @@ -218,35 +335,42 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/{scope}/providers/Microsoft.ManagedServices/registrationDefinitions/{registrationDefinitionId}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - registration_definition_id, # type: str - scope, # type: str - request_body, # type: "_models.RegistrationDefinition" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.RegistrationDefinition"] + registration_definition_id: str, + scope: str, + request_body: "_models.RegistrationDefinition", + **kwargs: Any + ) -> LROPoller["_models.RegistrationDefinition"]: """Creates or updates a registration definition. - :param registration_definition_id: Guid of the registration definition. + :param registration_definition_id: The GUID of the registration definition. :type registration_definition_id: str - :param scope: Scope of the resource. + :param scope: The scope of the resource. :type scope: str - :param request_body: The parameters required to create new registration definition. + :param request_body: The parameters required to create a new registration definition. :type request_body: ~azure.mgmt.managedservices.models.RegistrationDefinition :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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or 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 RegistrationDefinition or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.managedservices.models.RegistrationDefinition] - :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 RegistrationDefinition or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.managedservices.models.RegistrationDefinition] + :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["_models.RegistrationDefinition"] lro_delay = kwargs.pop( 'polling_interval', @@ -258,26 +382,21 @@ def begin_create_or_update( registration_definition_id=registration_definition_id, scope=scope, request_body=request_body, + 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('RegistrationDefinition', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'registrationDefinitionId': self._serialize.url("registration_definition_id", registration_definition_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -289,21 +408,27 @@ 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': '/{scope}/providers/Microsoft.ManagedServices/registrationDefinitions/{registrationDefinitionId}'} # type: ignore + @distributed_trace def list( self, - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RegistrationDefinitionList"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RegistrationDefinitionList"]: """Gets a list of the registration definitions. - :param scope: Scope of the resource. + :param scope: The scope of the resource. :type scope: str + :param filter: The filter query parameter to filter managed services resources by. + :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegistrationDefinitionList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.managedservices.models.RegistrationDefinitionList] + :return: An iterator like instance of either RegistrationDefinitionList or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.managedservices.models.RegistrationDefinitionList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RegistrationDefinitionList"] @@ -311,34 +436,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-02-01-preview" - 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 - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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 = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + filter=filter, + 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( + scope=scope, + filter=filter, + 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('RegistrationDefinitionList', pipeline_response) + deserialized = self._deserialize("RegistrationDefinitionList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -351,12 +473,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 )