From 4a9193a161df4950fb13130fd070497d04d035a4 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 6 Jul 2022 06:06:18 +0000 Subject: [PATCH] CodeGen from PR 19682 in Azure/azure-rest-api-specs Merge 492f46331542f76339473ce20ec49ceffe794fff into f95b40108e41ad35bde8586a409cee6af65808fd --- .../azure-mgmt-deploymentmanager/_meta.json | 10 +- .../azure/mgmt/deploymentmanager/__init__.py | 12 +- .../_azure_deployment_manager.py | 120 +- .../mgmt/deploymentmanager/_configuration.py | 31 +- .../mgmt/deploymentmanager/_metadata.json | 109 - .../azure/mgmt/deploymentmanager/_patch.py | 19 + .../azure/mgmt/deploymentmanager/_vendor.py | 27 + .../azure/mgmt/deploymentmanager/_version.py | 2 +- .../mgmt/deploymentmanager/aio/__init__.py | 10 + .../aio/_azure_deployment_manager.py | 111 +- .../deploymentmanager/aio/_configuration.py | 18 +- .../mgmt/deploymentmanager/aio/_patch.py | 19 + .../aio/operations/__init__.py | 5 + .../_artifact_sources_operations.py | 268 +-- .../aio/operations/_operations.py | 88 +- .../aio/operations/_patch.py | 19 + .../aio/operations/_rollouts_operations.py | 441 ++-- .../_service_topologies_operations.py | 270 +-- .../operations/_service_units_operations.py | 343 +-- .../aio/operations/_services_operations.py | 278 +-- .../aio/operations/_steps_operations.py | 268 +-- .../mgmt/deploymentmanager/models/__init__.py | 159 +- .../models/_azure_deployment_manager_enums.py | 32 +- .../mgmt/deploymentmanager/models/_models.py | 1969 ----------------- .../deploymentmanager/models/_models_py3.py | 1065 ++++++--- .../mgmt/deploymentmanager/models/_patch.py | 19 + .../deploymentmanager/operations/__init__.py | 5 + .../_artifact_sources_operations.py | 465 ++-- .../operations/_operations.py | 125 +- .../deploymentmanager/operations/_patch.py | 19 + .../operations/_rollouts_operations.py | 745 +++++-- .../_service_topologies_operations.py | 467 ++-- .../operations/_service_units_operations.py | 580 +++-- .../operations/_services_operations.py | 491 ++-- .../operations/_steps_operations.py | 465 ++-- 35 files changed, 4439 insertions(+), 4635 deletions(-) delete mode 100644 sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_metadata.json create mode 100644 sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_patch.py create mode 100644 sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_vendor.py create mode 100644 sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/_patch.py create mode 100644 sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_patch.py delete mode 100644 sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/models/_models.py create mode 100644 sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/models/_patch.py create mode 100644 sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_patch.py diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/_meta.json b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/_meta.json index 4c290e0bfeb0..2731b0de9cb5 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/_meta.json +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.2", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.0", - "@autorest/modelerfour@4.19.1" + "@autorest/python@5.16.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "d58622331b5775038608c0cc6dc6d76f1543bf47", + "commit": "1dfca9f2bd6f268822b973d0ccd31c5b315e702d", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/deploymentmanager/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.0 --use=@autorest/modelerfour@4.19.1 --version=3.4.2", + "autorest_command": "autorest specification/deploymentmanager/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/deploymentmanager/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/__init__.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/__init__.py index 96f7cf2fb38e..947d62ea08f3 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/__init__.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/__init__.py @@ -10,10 +10,14 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AzureDeploymentManager'] try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['AzureDeploymentManager'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_azure_deployment_manager.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_azure_deployment_manager.py index e54be67b9b3a..4b52b0861304 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_azure_deployment_manager.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_azure_deployment_manager.py @@ -6,34 +6,30 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import AzureDeploymentManagerConfiguration -from .operations import ServiceTopologiesOperations -from .operations import ServicesOperations -from .operations import ServiceUnitsOperations -from .operations import StepsOperations -from .operations import RolloutsOperations -from .operations import ArtifactSourcesOperations -from .operations import Operations from . import models +from ._configuration import AzureDeploymentManagerConfiguration +from .operations import ArtifactSourcesOperations, Operations, RolloutsOperations, ServiceTopologiesOperations, ServiceUnitsOperations, ServicesOperations, StepsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class AzureDeploymentManager(object): - """REST APIs for orchestrating deployments using the Azure Deployment Manager (ADM). See https://docs.microsoft.com/en-us/azure/azure-resource-manager/deployment-manager-overview for more information. +class AzureDeploymentManager: # pylint: disable=too-many-instance-attributes + """REST APIs for orchestrating deployments using the Azure Deployment Manager (ADM). See + https://docs.microsoft.com/en-us/azure-resource-manager/deployment-manager-overview for more + information. :ivar service_topologies: ServiceTopologiesOperations operations - :vartype service_topologies: azure.mgmt.deploymentmanager.operations.ServiceTopologiesOperations + :vartype service_topologies: + azure.mgmt.deploymentmanager.operations.ServiceTopologiesOperations :ivar services: ServicesOperations operations :vartype services: azure.mgmt.deploymentmanager.operations.ServicesOperations :ivar service_units: ServiceUnitsOperations operations @@ -48,62 +44,80 @@ class AzureDeploymentManager(object): :vartype operations: azure.mgmt.deploymentmanager.operations.Operations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2019-11-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AzureDeploymentManagerConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AzureDeploymentManagerConfiguration(credential=credential, subscription_id=subscription_id, **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.service_topologies = ServiceTopologiesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.services = ServicesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.service_units = ServiceUnitsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.steps = StepsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.rollouts = RolloutsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.artifact_sources = ArtifactSourcesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - 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/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_configuration.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_configuration.py index b76d6075bf67..841bd9a62f45 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_configuration.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AzureDeploymentManagerConfiguration(Configuration): +class AzureDeploymentManagerConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AzureDeploymentManager. Note that all parameters used to create this instance are saved as instance @@ -29,26 +27,31 @@ class AzureDeploymentManagerConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-11-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AzureDeploymentManagerConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-11-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(AzureDeploymentManagerConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-11-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-deploymentmanager/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +71,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/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_metadata.json b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_metadata.json deleted file mode 100644 index 764c958e3dfa..000000000000 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_metadata.json +++ /dev/null @@ -1,109 +0,0 @@ -{ - "chosen_version": "2019-11-01-preview", - "total_api_version_list": ["2019-11-01-preview"], - "client": { - "name": "AzureDeploymentManager", - "filename": "_azure_deployment_manager", - "description": "REST APIs for orchestrating deployments using the Azure Deployment Manager (ADM). See https://docs.microsoft.com/en-us/azure/azure-resource-manager/deployment-manager-overview for more information.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureDeploymentManagerConfiguration\"]}}, \"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\": [\"AzureDeploymentManagerConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=None, # type: Optional[str]", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "service_topologies": "ServiceTopologiesOperations", - "services": "ServicesOperations", - "service_units": "ServiceUnitsOperations", - "steps": "StepsOperations", - "rollouts": "RolloutsOperations", - "artifact_sources": "ArtifactSourcesOperations", - "operations": "Operations" - } -} \ No newline at end of file diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_patch.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_vendor.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_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/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_version.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_version.py index c47f66669f1b..06919be30fe3 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_version.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "0.9.1" diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/__init__.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/__init__.py index 739fcaf517e9..fe24f8ebe69a 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/__init__.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/__init__.py @@ -7,4 +7,14 @@ # -------------------------------------------------------------------------- from ._azure_deployment_manager import AzureDeploymentManager + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['AzureDeploymentManager'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/_azure_deployment_manager.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/_azure_deployment_manager.py index 5f515a3e52af..8d487853953d 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/_azure_deployment_manager.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/_azure_deployment_manager.py @@ -6,32 +6,30 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import AzureDeploymentManagerConfiguration -from .operations import ServiceTopologiesOperations -from .operations import ServicesOperations -from .operations import ServiceUnitsOperations -from .operations import StepsOperations -from .operations import RolloutsOperations -from .operations import ArtifactSourcesOperations -from .operations import Operations from .. import models +from ._configuration import AzureDeploymentManagerConfiguration +from .operations import ArtifactSourcesOperations, Operations, RolloutsOperations, ServiceTopologiesOperations, ServiceUnitsOperations, ServicesOperations, StepsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class AzureDeploymentManager(object): - """REST APIs for orchestrating deployments using the Azure Deployment Manager (ADM). See https://docs.microsoft.com/en-us/azure/azure-resource-manager/deployment-manager-overview for more information. +class AzureDeploymentManager: # pylint: disable=too-many-instance-attributes + """REST APIs for orchestrating deployments using the Azure Deployment Manager (ADM). See + https://docs.microsoft.com/en-us/azure-resource-manager/deployment-manager-overview for more + information. :ivar service_topologies: ServiceTopologiesOperations operations - :vartype service_topologies: azure.mgmt.deploymentmanager.aio.operations.ServiceTopologiesOperations + :vartype service_topologies: + azure.mgmt.deploymentmanager.aio.operations.ServiceTopologiesOperations :ivar services: ServicesOperations operations :vartype services: azure.mgmt.deploymentmanager.aio.operations.ServicesOperations :ivar service_units: ServiceUnitsOperations operations @@ -41,65 +39,86 @@ class AzureDeploymentManager(object): :ivar rollouts: RolloutsOperations operations :vartype rollouts: azure.mgmt.deploymentmanager.aio.operations.RolloutsOperations :ivar artifact_sources: ArtifactSourcesOperations operations - :vartype artifact_sources: azure.mgmt.deploymentmanager.aio.operations.ArtifactSourcesOperations + :vartype artifact_sources: + azure.mgmt.deploymentmanager.aio.operations.ArtifactSourcesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.deploymentmanager.aio.operations.Operations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2019-11-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AzureDeploymentManagerConfiguration(credential, subscription_id, **kwargs) + self._config = AzureDeploymentManagerConfiguration(credential=credential, subscription_id=subscription_id, **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.service_topologies = ServiceTopologiesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.services = ServicesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.service_units = ServiceUnitsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.steps = StepsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.rollouts = RolloutsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.artifact_sources = ArtifactSourcesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) - 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 """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - 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/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/_configuration.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/_configuration.py index 82439a30c2d1..9d814a6fc4f9 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/_configuration.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AzureDeploymentManagerConfiguration(Configuration): +class AzureDeploymentManagerConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AzureDeploymentManager. Note that all parameters used to create this instance are saved as instance @@ -27,8 +27,12 @@ class AzureDeploymentManagerConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-11-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +41,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AzureDeploymentManagerConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-11-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(AzureDeploymentManagerConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-11-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-deploymentmanager/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +70,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/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/_patch.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/__init__.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/__init__.py index 0e9ad57acd5f..fec9e58b75b8 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/__init__.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/__init__.py @@ -14,6 +14,9 @@ from ._artifact_sources_operations import ArtifactSourcesOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ServiceTopologiesOperations', 'ServicesOperations', @@ -23,3 +26,5 @@ 'ArtifactSourcesOperations', 'Operations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_artifact_sources_operations.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_artifact_sources_operations.py index e254d9d7203d..56b75ff87928 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_artifact_sources_operations.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_artifact_sources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, List, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._artifact_sources_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ArtifactSourcesOperations: - """ArtifactSourcesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.deploymentmanager.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.deploymentmanager.aio.AzureDeploymentManager`'s + :attr:`artifact_sources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, artifact_source_name: str, - artifact_source_info: Optional["_models.ArtifactSource"] = None, + artifact_source_info: Optional[_models.ArtifactSource] = None, **kwargs: Any - ) -> "_models.ArtifactSource": + ) -> _models.ArtifactSource: """Creates or updates an artifact source. Synchronously creates a new artifact source or updates an existing artifact source. @@ -55,48 +58,49 @@ async def create_or_update( :type resource_group_name: str :param artifact_source_name: The name of the artifact source. :type artifact_source_name: str - :param artifact_source_info: Source object that defines the resource. + :param artifact_source_info: Source object that defines the resource. Default value is None. :type artifact_source_info: ~azure.mgmt.deploymentmanager.models.ArtifactSource :keyword callable cls: A custom type or function that will be passed the direct response :return: ArtifactSource, or the result of cls(response) :rtype: ~azure.mgmt.deploymentmanager.models.ArtifactSource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ArtifactSource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'artifactSourceName': self._serialize.url("artifact_source_name", artifact_source_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # 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') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ArtifactSource] - body_content_kwargs = {} # type: Dict[str, Any] if artifact_source_info is not None: - body_content = self._serialize.body(artifact_source_info, 'ArtifactSource') + _json = self._serialize.body(artifact_source_info, 'ArtifactSource') else: - body_content = None - 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) + _json = None + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + artifact_source_name=artifact_source_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -109,14 +113,17 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/artifactSources/{artifactSourceName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/artifactSources/{artifactSourceName}"} # type: ignore + + + @distributed_trace_async async def get( self, resource_group_name: str, artifact_source_name: str, **kwargs: Any - ) -> "_models.ArtifactSource": + ) -> _models.ArtifactSource: """Gets an artifact source. Gets an artifact source. @@ -130,33 +137,35 @@ async def get( :rtype: ~azure.mgmt.deploymentmanager.models.ArtifactSource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ArtifactSource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'artifactSourceName': self._serialize.url("artifact_source_name", artifact_source_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ArtifactSource] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + artifact_source_name=artifact_source_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,9 +178,12 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/artifactSources/{artifactSourceName}'} # type: ignore - async def delete( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/artifactSources/{artifactSourceName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, artifact_source_name: str, @@ -190,33 +202,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'artifactSourceName': self._serialize.url("artifact_source_name", artifact_source_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + artifact_source_name=artifact_source_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -226,13 +240,15 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/artifactSources/{artifactSourceName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/artifactSources/{artifactSourceName}"} # type: ignore + + @distributed_trace_async async def list( self, resource_group_name: str, **kwargs: Any - ) -> List["_models.ArtifactSource"]: + ) -> List[_models.ArtifactSource]: """Lists the artifact sources in a resource group. Lists the artifact sources in a resource group. @@ -244,32 +260,34 @@ async def list( :rtype: list[~azure.mgmt.deploymentmanager.models.ArtifactSource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ArtifactSource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.ArtifactSource]] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -282,4 +300,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/artifactSources'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/artifactSources"} # type: ignore + diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_operations.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_operations.py index d70227b9208f..feeed22a6dab 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_operations.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,45 +6,47 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.deploymentmanager.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.deploymentmanager.aio.AzureDeploymentManager`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def list( self, **kwargs: Any - ) -> "_models.OperationsList": + ) -> _models.OperationsList: """Lists the supported operations. Lists the supported operations. @@ -53,27 +56,32 @@ async def list( :rtype: ~azure.mgmt.deploymentmanager.models.OperationsList :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationsList] + + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -86,4 +94,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/providers/Microsoft.DeploymentManager/operations'} # type: ignore + + list.metadata = {'url': "/providers/Microsoft.DeploymentManager/operations"} # type: ignore + diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_patch.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_rollouts_operations.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_rollouts_operations.py index 3e790f1835a9..2135ee2ffcfb 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_rollouts_operations.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_rollouts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,85 +6,87 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, List, Optional, TypeVar, Union, cast 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_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._rollouts_operations import build_cancel_request, build_create_or_update_request_initial, build_delete_request, build_get_request, build_list_request, build_restart_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RolloutsOperations: - """RolloutsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.deploymentmanager.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.deploymentmanager.aio.AzureDeploymentManager`'s + :attr:`rollouts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, rollout_name: str, - rollout_request: Optional["_models.RolloutRequest"] = None, + rollout_request: Optional[_models.RolloutRequest] = None, **kwargs: Any - ) -> "_models.RolloutRequest": - cls = kwargs.pop('cls', None) # type: ClsType["_models.RolloutRequest"] + ) -> _models.RolloutRequest: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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 = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'rolloutName': self._serialize.url("rollout_name", rollout_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # 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') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RolloutRequest] - body_content_kwargs = {} # type: Dict[str, Any] if rollout_request is not None: - body_content = self._serialize.body(rollout_request, 'RolloutRequest') + _json = self._serialize.body(rollout_request, 'RolloutRequest') else: - body_content = None - 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) + _json = None + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rollout_name=rollout_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -92,21 +95,25 @@ async def _create_or_update_initial( response_headers = {} response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + deserialized = self._deserialize('RolloutRequest', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}"} # type: ignore + + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, rollout_name: str, - rollout_request: Optional["_models.RolloutRequest"] = None, + rollout_request: Optional[_models.RolloutRequest] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.RolloutRequest"]: + ) -> AsyncLROPoller[_models.RolloutRequest]: """Creates or updates a rollout. This is an asynchronous operation and can be polled to completion using the location header @@ -116,55 +123,67 @@ async def begin_create_or_update( :type resource_group_name: str :param rollout_name: The rollout name. :type rollout_name: str - :param rollout_request: Source rollout request object that defines the rollout. + :param rollout_request: Source rollout request object that defines the rollout. Default value + is None. :type rollout_request: ~azure.mgmt.deploymentmanager.models.RolloutRequest :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either RolloutRequest or the result of cls(response) + :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 RolloutRequest or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.deploymentmanager.models.RolloutRequest] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RolloutRequest] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RolloutRequest"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, rollout_name=rollout_name, rollout_request=rollout_request, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + deserialized = self._deserialize('RolloutRequest', pipeline_response) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'rolloutName': self._serialize.url("rollout_name", rollout_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -173,17 +192,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, rollout_name: str, retry_attempt: Optional[int] = None, **kwargs: Any - ) -> "_models.Rollout": + ) -> _models.Rollout: """Gets detailed information of a rollout. Gets detailed information of a rollout. @@ -193,42 +213,43 @@ async def get( :param rollout_name: The rollout name. :type rollout_name: str :param retry_attempt: Rollout retry attempt ordinal to get the result of. If not specified, - result of the latest attempt will be returned. + result of the latest attempt will be returned. Default value is None. :type retry_attempt: int :keyword callable cls: A custom type or function that will be passed the direct response :return: Rollout, or the result of cls(response) :rtype: ~azure.mgmt.deploymentmanager.models.Rollout :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Rollout"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'rolloutName': self._serialize.url("rollout_name", rollout_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if retry_attempt is not None: - query_parameters['retryAttempt'] = self._serialize.query("retry_attempt", retry_attempt, 'int') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Rollout] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rollout_name=rollout_name, + api_version=api_version, + retry_attempt=retry_attempt, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -241,9 +262,12 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}'} # type: ignore - async def delete( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, rollout_name: str, @@ -262,33 +286,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'rolloutName': self._serialize.url("rollout_name", rollout_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rollout_name=rollout_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -298,14 +324,16 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}"} # type: ignore + + @distributed_trace_async async def cancel( self, resource_group_name: str, rollout_name: str, **kwargs: Any - ) -> "_models.Rollout": + ) -> _models.Rollout: """Stops a running rollout. Only running rollouts can be canceled. @@ -319,33 +347,35 @@ async def cancel( :rtype: ~azure.mgmt.deploymentmanager.models.Rollout :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Rollout"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'rolloutName': self._serialize.url("rollout_name", rollout_name, '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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Rollout] + + + request = build_cancel_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rollout_name=rollout_name, + api_version=api_version, + template_url=self.cancel.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -358,15 +388,18 @@ async def cancel( return cls(pipeline_response, deserialized, {}) return deserialized - cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}/cancel'} # type: ignore + cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}/cancel"} # type: ignore + + + @distributed_trace_async async def restart( self, resource_group_name: str, rollout_name: str, skip_succeeded: Optional[bool] = None, **kwargs: Any - ) -> "_models.Rollout": + ) -> _models.Rollout: """Restarts a failed rollout and optionally skips all succeeded steps. Only failed rollouts can be restarted. @@ -377,42 +410,43 @@ async def restart( :type rollout_name: str :param skip_succeeded: If true, will skip all succeeded steps so far in the rollout. If false, will execute the entire rollout again regardless of the current state of individual resources. - Defaults to false if not specified. + Defaults to false if not specified. Default value is None. :type skip_succeeded: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: Rollout, or the result of cls(response) :rtype: ~azure.mgmt.deploymentmanager.models.Rollout :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Rollout"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.restart.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'rolloutName': self._serialize.url("rollout_name", rollout_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if skip_succeeded is not None: - query_parameters['skipSucceeded'] = self._serialize.query("skip_succeeded", skip_succeeded, '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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Rollout] + + + request = build_restart_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rollout_name=rollout_name, + api_version=api_version, + skip_succeeded=skip_succeeded, + template_url=self.restart.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -425,13 +459,16 @@ async def restart( return cls(pipeline_response, deserialized, {}) return deserialized - restart.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}/restart'} # type: ignore + restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}/restart"} # type: ignore + + + @distributed_trace_async async def list( self, resource_group_name: str, **kwargs: Any - ) -> List["_models.Rollout"]: + ) -> List[_models.Rollout]: """Lists the rollouts in a resource group. Lists the rollouts in a resource group. @@ -443,32 +480,34 @@ async def list( :rtype: list[~azure.mgmt.deploymentmanager.models.Rollout] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.Rollout"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.Rollout]] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -481,4 +520,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts"} # type: ignore + diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_service_topologies_operations.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_service_topologies_operations.py index 3077d154d8f4..1f68de1b7547 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_service_topologies_operations.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_service_topologies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, List, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._service_topologies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ServiceTopologiesOperations: - """ServiceTopologiesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.deploymentmanager.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.deploymentmanager.aio.AzureDeploymentManager`'s + :attr:`service_topologies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, service_topology_name: str, - service_topology_info: "_models.ServiceTopologyResource", + service_topology_info: _models.ServiceTopologyResource, **kwargs: Any - ) -> "_models.ServiceTopologyResource": + ) -> _models.ServiceTopologyResource: """Creates or updates a service topology. Synchronously creates a new service topology or updates an existing service topology. @@ -62,38 +65,39 @@ async def create_or_update( :rtype: ~azure.mgmt.deploymentmanager.models.ServiceTopologyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceTopologyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(service_topology_info, 'ServiceTopologyResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceTopologyResource] + + _json = self._serialize.body(service_topology_info, 'ServiceTopologyResource') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -106,14 +110,17 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}"} # type: ignore + + + @distributed_trace_async async def get( self, resource_group_name: str, service_topology_name: str, **kwargs: Any - ) -> "_models.ServiceTopologyResource": + ) -> _models.ServiceTopologyResource: """Gets the service topology. Gets the service topology. @@ -127,33 +134,35 @@ async def get( :rtype: ~azure.mgmt.deploymentmanager.models.ServiceTopologyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceTopologyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceTopologyResource] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -166,9 +175,12 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}'} # type: ignore - async def delete( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_topology_name: str, @@ -187,33 +199,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -223,13 +237,15 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}"} # type: ignore + + @distributed_trace_async async def list( self, resource_group_name: str, **kwargs: Any - ) -> List["_models.ServiceTopologyResource"]: + ) -> List[_models.ServiceTopologyResource]: """Lists the service topologies in the resource group. Lists the service topologies in the resource group. @@ -241,32 +257,34 @@ async def list( :rtype: list[~azure.mgmt.deploymentmanager.models.ServiceTopologyResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ServiceTopologyResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.ServiceTopologyResource]] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -279,4 +297,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies"} # type: ignore + diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_service_units_operations.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_service_units_operations.py index 7f69f4c20f8a..26a69466568d 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_service_units_operations.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_service_units_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,42 +6,43 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, List, Optional, TypeVar, Union, cast 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_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._service_units_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]] class ServiceUnitsOperations: - """ServiceUnitsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.deploymentmanager.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.deploymentmanager.aio.AzureDeploymentManager`'s + :attr:`service_units` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -48,43 +50,44 @@ async def _create_or_update_initial( service_topology_name: str, service_name: str, service_unit_name: str, - service_unit_info: "_models.ServiceUnitResource", + service_unit_info: _models.ServiceUnitResource, **kwargs: Any - ) -> "_models.ServiceUnitResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceUnitResource"] + ) -> _models.ServiceUnitResource: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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 = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - 'serviceName': self._serialize.url("service_name", service_name, 'str'), - 'serviceUnitName': self._serialize.url("service_unit_name", service_unit_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(service_unit_info, 'ServiceUnitResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceUnitResource] + + _json = self._serialize.body(service_unit_info, 'ServiceUnitResource') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + service_name=service_name, + service_unit_name=service_unit_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -93,23 +96,27 @@ async def _create_or_update_initial( response_headers = {} response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + deserialized = self._deserialize('ServiceUnitResource', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}"} # type: ignore + + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, service_topology_name: str, service_name: str, service_unit_name: str, - service_unit_info: "_models.ServiceUnitResource", + service_unit_info: _models.ServiceUnitResource, **kwargs: Any - ) -> AsyncLROPoller["_models.ServiceUnitResource"]: + ) -> AsyncLROPoller[_models.ServiceUnitResource]: """Creates or updates a service unit under the service in the service topology. This is an asynchronous operation and can be polled to completion using the operation resource @@ -127,55 +134,65 @@ async def begin_create_or_update( :type service_unit_info: ~azure.mgmt.deploymentmanager.models.ServiceUnitResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ServiceUnitResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.deploymentmanager.models.ServiceUnitResource] - :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 ServiceUnitResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.deploymentmanager.models.ServiceUnitResource] + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceUnitResource] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceUnitResource"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, service_topology_name=service_topology_name, service_name=service_name, service_unit_name=service_unit_name, service_unit_info=service_unit_info, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + deserialized = self._deserialize('ServiceUnitResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - 'serviceName': self._serialize.url("service_name", service_name, 'str'), - 'serviceUnitName': self._serialize.url("service_unit_name", service_unit_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -184,10 +201,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}"} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -195,7 +213,7 @@ async def get( service_name: str, service_unit_name: str, **kwargs: Any - ) -> "_models.ServiceUnitResource": + ) -> _models.ServiceUnitResource: """Gets the service unit. Gets the service unit. @@ -213,35 +231,37 @@ async def get( :rtype: ~azure.mgmt.deploymentmanager.models.ServiceUnitResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceUnitResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - 'serviceName': self._serialize.url("service_name", service_name, 'str'), - 'serviceUnitName': self._serialize.url("service_unit_name", service_unit_name, '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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceUnitResource] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + service_name=service_name, + service_unit_name=service_unit_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -254,9 +274,12 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}'} # type: ignore - async def delete( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_topology_name: str, @@ -281,35 +304,37 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - 'serviceName': self._serialize.url("service_name", service_name, 'str'), - 'serviceUnitName': self._serialize.url("service_unit_name", service_unit_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + service_name=service_name, + service_unit_name=service_unit_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -319,15 +344,17 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}"} # type: ignore + + @distributed_trace_async async def list( self, resource_group_name: str, service_topology_name: str, service_name: str, **kwargs: Any - ) -> List["_models.ServiceUnitResource"]: + ) -> List[_models.ServiceUnitResource]: """Lists the service units under a service in the service topology. Lists the service units under a service in the service topology. @@ -343,34 +370,36 @@ async def list( :rtype: list[~azure.mgmt.deploymentmanager.models.ServiceUnitResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ServiceUnitResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - 'serviceName': self._serialize.url("service_name", service_name, '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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.ServiceUnitResource]] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + service_name=service_name, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -383,4 +412,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits"} # type: ignore + diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_services_operations.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_services_operations.py index acea1bacf974..370a067803f5 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_services_operations.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,49 +6,51 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, List, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._services_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ServicesOperations: - """ServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.deploymentmanager.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.deploymentmanager.aio.AzureDeploymentManager`'s + :attr:`services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, service_topology_name: str, service_name: str, - service_info: "_models.ServiceResource", + service_info: _models.ServiceResource, **kwargs: Any - ) -> "_models.ServiceResource": + ) -> _models.ServiceResource: """Creates or updates a service in the service topology. Synchronously creates a new service or updates an existing service. @@ -65,39 +68,40 @@ async def create_or_update( :rtype: ~azure.mgmt.deploymentmanager.models.ServiceResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - 'serviceName': self._serialize.url("service_name", service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(service_info, 'ServiceResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceResource] + + _json = self._serialize.body(service_info, 'ServiceResource') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + service_name=service_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -110,15 +114,18 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}"} # type: ignore + + + @distributed_trace_async async def get( self, resource_group_name: str, service_topology_name: str, service_name: str, **kwargs: Any - ) -> "_models.ServiceResource": + ) -> _models.ServiceResource: """Gets the service. Gets the service. @@ -134,34 +141,36 @@ async def get( :rtype: ~azure.mgmt.deploymentmanager.models.ServiceResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - 'serviceName': self._serialize.url("service_name", service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceResource] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + service_name=service_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -174,9 +183,12 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}'} # type: ignore - async def delete( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, service_topology_name: str, @@ -198,34 +210,36 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - 'serviceName': self._serialize.url("service_name", service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + service_name=service_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -235,14 +249,16 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}"} # type: ignore + + @distributed_trace_async async def list( self, resource_group_name: str, service_topology_name: str, **kwargs: Any - ) -> List["_models.ServiceResource"]: + ) -> List[_models.ServiceResource]: """Lists the services in the service topology. Lists the services in the service topology. @@ -256,33 +272,35 @@ async def list( :rtype: list[~azure.mgmt.deploymentmanager.models.ServiceResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ServiceResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.ServiceResource]] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -295,4 +313,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services"} # type: ignore + diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_steps_operations.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_steps_operations.py index dd00f347d768..2f6ac53fb1a5 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_steps_operations.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/aio/operations/_steps_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, List, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._steps_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class StepsOperations: - """StepsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.deploymentmanager.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.deploymentmanager.aio.AzureDeploymentManager`'s + :attr:`steps` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, step_name: str, - step_info: Optional["_models.StepResource"] = None, + step_info: Optional[_models.StepResource] = None, **kwargs: Any - ) -> "_models.StepResource": + ) -> _models.StepResource: """Creates or updates a rollout step with the given step properties. Synchronously creates a new step or updates an existing step. @@ -55,48 +58,49 @@ async def create_or_update( :type resource_group_name: str :param step_name: The name of the deployment step. :type step_name: str - :param step_info: The step object. + :param step_info: The step object. Default value is None. :type step_info: ~azure.mgmt.deploymentmanager.models.StepResource :keyword callable cls: A custom type or function that will be passed the direct response :return: StepResource, or the result of cls(response) :rtype: ~azure.mgmt.deploymentmanager.models.StepResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StepResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'stepName': self._serialize.url("step_name", step_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # 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') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.StepResource] - body_content_kwargs = {} # type: Dict[str, Any] if step_info is not None: - body_content = self._serialize.body(step_info, 'StepResource') + _json = self._serialize.body(step_info, 'StepResource') else: - body_content = None - 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) + _json = None + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + step_name=step_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -109,14 +113,17 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/steps/{stepName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/steps/{stepName}"} # type: ignore + + + @distributed_trace_async async def get( self, resource_group_name: str, step_name: str, **kwargs: Any - ) -> "_models.StepResource": + ) -> _models.StepResource: """Gets the step. Gets the step. @@ -130,33 +137,35 @@ async def get( :rtype: ~azure.mgmt.deploymentmanager.models.StepResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StepResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'stepName': self._serialize.url("step_name", step_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StepResource] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + step_name=step_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,9 +178,12 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/steps/{stepName}'} # type: ignore - async def delete( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/steps/{stepName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, step_name: str, @@ -190,33 +202,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'stepName': self._serialize.url("step_name", step_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + step_name=step_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -226,13 +240,15 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/steps/{stepName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/steps/{stepName}"} # type: ignore + + @distributed_trace_async async def list( self, resource_group_name: str, **kwargs: Any - ) -> List["_models.StepResource"]: + ) -> List[_models.StepResource]: """Lists the steps in a resource group. Lists the steps in a resource group. @@ -244,32 +260,34 @@ async def list( :rtype: list[~azure.mgmt.deploymentmanager.models.StepResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.StepResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.StepResource]] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -282,4 +300,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/steps'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/steps"} # type: ignore + diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/models/__init__.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/models/__init__.py index cc8ac258fd67..4858a95d96a0 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/models/__init__.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/models/__init__.py @@ -6,108 +6,57 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ApiKeyAuthentication - from ._models_py3 import ArtifactSource - from ._models_py3 import ArtifactSourceProperties - from ._models_py3 import ArtifactSourcePropertiesAutoGenerated - from ._models_py3 import Authentication - from ._models_py3 import CloudErrorBody - from ._models_py3 import HealthCheckStepAttributes - from ._models_py3 import HealthCheckStepProperties - from ._models_py3 import Identity - from ._models_py3 import Message - from ._models_py3 import Operation - from ._models_py3 import OperationDetail - from ._models_py3 import OperationsList - from ._models_py3 import PrePostStep - from ._models_py3 import Resource - from ._models_py3 import ResourceOperation - from ._models_py3 import RestHealthCheck - from ._models_py3 import RestHealthCheckStepAttributes - from ._models_py3 import RestRequest - from ._models_py3 import RestRequestAuthentication - from ._models_py3 import RestResponse - from ._models_py3 import RestResponseRegex - from ._models_py3 import Rollout - from ._models_py3 import RolloutIdentityAuthentication - from ._models_py3 import RolloutOperationInfo - from ._models_py3 import RolloutProperties - from ._models_py3 import RolloutPropertiesAutoGenerated - from ._models_py3 import RolloutRequest - from ._models_py3 import RolloutRequestProperties - from ._models_py3 import RolloutStep - from ._models_py3 import SasAuthentication - from ._models_py3 import Service - from ._models_py3 import ServiceProperties - from ._models_py3 import ServiceResource - from ._models_py3 import ServiceResourceProperties - from ._models_py3 import ServiceTopologyProperties - from ._models_py3 import ServiceTopologyResource - from ._models_py3 import ServiceTopologyResourceProperties - from ._models_py3 import ServiceUnit - from ._models_py3 import ServiceUnitArtifacts - from ._models_py3 import ServiceUnitProperties - from ._models_py3 import ServiceUnitResource - from ._models_py3 import ServiceUnitResourceProperties - from ._models_py3 import StepGroup - from ._models_py3 import StepOperationInfo - from ._models_py3 import StepProperties - from ._models_py3 import StepResource - from ._models_py3 import TrackedResource - from ._models_py3 import WaitStepAttributes - from ._models_py3 import WaitStepProperties -except (SyntaxError, ImportError): - from ._models import ApiKeyAuthentication # type: ignore - from ._models import ArtifactSource # type: ignore - from ._models import ArtifactSourceProperties # type: ignore - from ._models import ArtifactSourcePropertiesAutoGenerated # type: ignore - from ._models import Authentication # type: ignore - from ._models import CloudErrorBody # type: ignore - from ._models import HealthCheckStepAttributes # type: ignore - from ._models import HealthCheckStepProperties # type: ignore - from ._models import Identity # type: ignore - from ._models import Message # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDetail # type: ignore - from ._models import OperationsList # type: ignore - from ._models import PrePostStep # type: ignore - from ._models import Resource # type: ignore - from ._models import ResourceOperation # type: ignore - from ._models import RestHealthCheck # type: ignore - from ._models import RestHealthCheckStepAttributes # type: ignore - from ._models import RestRequest # type: ignore - from ._models import RestRequestAuthentication # type: ignore - from ._models import RestResponse # type: ignore - from ._models import RestResponseRegex # type: ignore - from ._models import Rollout # type: ignore - from ._models import RolloutIdentityAuthentication # type: ignore - from ._models import RolloutOperationInfo # type: ignore - from ._models import RolloutProperties # type: ignore - from ._models import RolloutPropertiesAutoGenerated # type: ignore - from ._models import RolloutRequest # type: ignore - from ._models import RolloutRequestProperties # type: ignore - from ._models import RolloutStep # type: ignore - from ._models import SasAuthentication # type: ignore - from ._models import Service # type: ignore - from ._models import ServiceProperties # type: ignore - from ._models import ServiceResource # type: ignore - from ._models import ServiceResourceProperties # type: ignore - from ._models import ServiceTopologyProperties # type: ignore - from ._models import ServiceTopologyResource # type: ignore - from ._models import ServiceTopologyResourceProperties # type: ignore - from ._models import ServiceUnit # type: ignore - from ._models import ServiceUnitArtifacts # type: ignore - from ._models import ServiceUnitProperties # type: ignore - from ._models import ServiceUnitResource # type: ignore - from ._models import ServiceUnitResourceProperties # type: ignore - from ._models import StepGroup # type: ignore - from ._models import StepOperationInfo # type: ignore - from ._models import StepProperties # type: ignore - from ._models import StepResource # type: ignore - from ._models import TrackedResource # type: ignore - from ._models import WaitStepAttributes # type: ignore - from ._models import WaitStepProperties # type: ignore +from ._models_py3 import ApiKeyAuthentication +from ._models_py3 import ArtifactSource +from ._models_py3 import ArtifactSourceProperties +from ._models_py3 import ArtifactSourcePropertiesAutoGenerated +from ._models_py3 import Authentication +from ._models_py3 import CloudErrorBody +from ._models_py3 import HealthCheckStepAttributes +from ._models_py3 import HealthCheckStepProperties +from ._models_py3 import Identity +from ._models_py3 import Message +from ._models_py3 import Operation +from ._models_py3 import OperationDetail +from ._models_py3 import OperationsList +from ._models_py3 import PrePostStep +from ._models_py3 import Resource +from ._models_py3 import ResourceOperation +from ._models_py3 import RestHealthCheck +from ._models_py3 import RestHealthCheckStepAttributes +from ._models_py3 import RestRequest +from ._models_py3 import RestRequestAuthentication +from ._models_py3 import RestResponse +from ._models_py3 import RestResponseRegex +from ._models_py3 import Rollout +from ._models_py3 import RolloutIdentityAuthentication +from ._models_py3 import RolloutOperationInfo +from ._models_py3 import RolloutProperties +from ._models_py3 import RolloutPropertiesAutoGenerated +from ._models_py3 import RolloutRequest +from ._models_py3 import RolloutRequestProperties +from ._models_py3 import RolloutStep +from ._models_py3 import SasAuthentication +from ._models_py3 import Service +from ._models_py3 import ServiceProperties +from ._models_py3 import ServiceResource +from ._models_py3 import ServiceResourceProperties +from ._models_py3 import ServiceTopologyProperties +from ._models_py3 import ServiceTopologyResource +from ._models_py3 import ServiceTopologyResourceProperties +from ._models_py3 import ServiceUnit +from ._models_py3 import ServiceUnitArtifacts +from ._models_py3 import ServiceUnitProperties +from ._models_py3 import ServiceUnitResource +from ._models_py3 import ServiceUnitResourceProperties +from ._models_py3 import StepGroup +from ._models_py3 import StepOperationInfo +from ._models_py3 import StepProperties +from ._models_py3 import StepResource +from ._models_py3 import TrackedResource +from ._models_py3 import WaitStepAttributes +from ._models_py3 import WaitStepProperties + from ._azure_deployment_manager_enums import ( DeploymentMode, @@ -117,7 +66,9 @@ RestRequestMethod, StepType, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ApiKeyAuthentication', 'ArtifactSource', @@ -176,3 +127,5 @@ 'RestRequestMethod', 'StepType', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/models/_azure_deployment_manager_enums.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/models/_azure_deployment_manager_enums.py index 0d443b76af0b..db0801a77120 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/models/_azure_deployment_manager_enums.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/models/_azure_deployment_manager_enums.py @@ -6,62 +6,46 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class DeploymentMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes the type of ARM deployment to be performed on the resource. """ INCREMENTAL = "Incremental" COMPLETE = "Complete" -class RestAuthLocation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RestAuthLocation(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The location of the authentication key/value pair in the request. """ QUERY = "Query" HEADER = "Header" -class RestAuthType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RestAuthType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication type. """ API_KEY = "ApiKey" ROLLOUT_IDENTITY = "RolloutIdentity" -class RestMatchQuantifier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RestMatchQuantifier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates whether any or all of the expressions should match with the response content. """ ALL = "All" ANY = "Any" -class RestRequestMethod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RestRequestMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The HTTP method to use for the request. """ GET = "GET" POST = "POST" -class StepType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class StepType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of step. """ diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/models/_models.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/models/_models.py deleted file mode 100644 index 835f1ee92ccd..000000000000 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/models/_models.py +++ /dev/null @@ -1,1969 +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. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class RestRequestAuthentication(msrest.serialization.Model): - """The authentication information required in the REST health check request to the health provider. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ApiKeyAuthentication, RolloutIdentityAuthentication. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. The authentication type.Constant filled by server. Possible values - include: "ApiKey", "RolloutIdentity". - :type type: str or ~azure.mgmt.deploymentmanager.models.RestAuthType - """ - - _validation = { - 'type': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - } - - _subtype_map = { - 'type': {'ApiKey': 'ApiKeyAuthentication', 'RolloutIdentity': 'RolloutIdentityAuthentication'} - } - - def __init__( - self, - **kwargs - ): - super(RestRequestAuthentication, self).__init__(**kwargs) - self.type = None # type: Optional[str] - - -class ApiKeyAuthentication(RestRequestAuthentication): - """ApiKey authentication gives a name and a value that can be included in either the request header or query parameters. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. The authentication type.Constant filled by server. Possible values - include: "ApiKey", "RolloutIdentity". - :type type: str or ~azure.mgmt.deploymentmanager.models.RestAuthType - :param name: Required. The key name of the authentication key/value pair. - :type name: str - :param in_property: Required. The location of the authentication key/value pair in the request. - Possible values include: "Query", "Header". - :type in_property: str or ~azure.mgmt.deploymentmanager.models.RestAuthLocation - :param value: Required. The value of the authentication key/value pair. - :type value: str - """ - - _validation = { - 'type': {'required': True}, - 'name': {'required': True}, - 'in_property': {'required': True}, - 'value': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'in_property': {'key': 'in', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApiKeyAuthentication, self).__init__(**kwargs) - self.type = 'ApiKey' # type: str - self.name = kwargs['name'] - self.in_property = kwargs['in_property'] - self.value = kwargs['value'] - - -class Resource(msrest.serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. - - 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. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.location = kwargs['location'] - - -class ArtifactSource(TrackedResource): - """The resource that defines the source location where the artifacts are located. - - 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. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param source_type: The type of artifact source used. - :type source_type: str - :param artifact_root: The path from the location that the 'authentication' property [say, a SAS - URI to the blob container] refers to, to the location of the artifacts. This can be used to - differentiate different versions of the artifacts. Or, different types of artifacts like - binaries or templates. The location referenced by the authentication property concatenated with - this optional artifactRoot path forms the artifact source location where the artifacts are - expected to be found. - :type artifact_root: str - :param authentication: The authentication method to use to access the artifact source. - :type authentication: ~azure.mgmt.deploymentmanager.models.Authentication - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'source_type': {'key': 'properties.sourceType', 'type': 'str'}, - 'artifact_root': {'key': 'properties.artifactRoot', 'type': 'str'}, - 'authentication': {'key': 'properties.authentication', 'type': 'Authentication'}, - } - - def __init__( - self, - **kwargs - ): - super(ArtifactSource, self).__init__(**kwargs) - self.source_type = kwargs.get('source_type', None) - self.artifact_root = kwargs.get('artifact_root', None) - self.authentication = kwargs.get('authentication', None) - - -class ArtifactSourceProperties(msrest.serialization.Model): - """The properties that define the source location where the artifacts are located. - - All required parameters must be populated in order to send to Azure. - - :param source_type: Required. The type of artifact source used. - :type source_type: str - :param artifact_root: The path from the location that the 'authentication' property [say, a SAS - URI to the blob container] refers to, to the location of the artifacts. This can be used to - differentiate different versions of the artifacts. Or, different types of artifacts like - binaries or templates. The location referenced by the authentication property concatenated with - this optional artifactRoot path forms the artifact source location where the artifacts are - expected to be found. - :type artifact_root: str - :param authentication: Required. The authentication method to use to access the artifact - source. - :type authentication: ~azure.mgmt.deploymentmanager.models.Authentication - """ - - _validation = { - 'source_type': {'required': True}, - 'authentication': {'required': True}, - } - - _attribute_map = { - 'source_type': {'key': 'sourceType', 'type': 'str'}, - 'artifact_root': {'key': 'artifactRoot', 'type': 'str'}, - 'authentication': {'key': 'authentication', 'type': 'Authentication'}, - } - - def __init__( - self, - **kwargs - ): - super(ArtifactSourceProperties, self).__init__(**kwargs) - self.source_type = kwargs['source_type'] - self.artifact_root = kwargs.get('artifact_root', None) - self.authentication = kwargs['authentication'] - - -class ArtifactSourcePropertiesAutoGenerated(ArtifactSourceProperties): - """The properties that define the artifact source. - - All required parameters must be populated in order to send to Azure. - - :param source_type: Required. The type of artifact source used. - :type source_type: str - :param artifact_root: The path from the location that the 'authentication' property [say, a SAS - URI to the blob container] refers to, to the location of the artifacts. This can be used to - differentiate different versions of the artifacts. Or, different types of artifacts like - binaries or templates. The location referenced by the authentication property concatenated with - this optional artifactRoot path forms the artifact source location where the artifacts are - expected to be found. - :type artifact_root: str - :param authentication: Required. The authentication method to use to access the artifact - source. - :type authentication: ~azure.mgmt.deploymentmanager.models.Authentication - """ - - _validation = { - 'source_type': {'required': True}, - 'authentication': {'required': True}, - } - - _attribute_map = { - 'source_type': {'key': 'sourceType', 'type': 'str'}, - 'artifact_root': {'key': 'artifactRoot', 'type': 'str'}, - 'authentication': {'key': 'authentication', 'type': 'Authentication'}, - } - - def __init__( - self, - **kwargs - ): - super(ArtifactSourcePropertiesAutoGenerated, self).__init__(**kwargs) - - -class Authentication(msrest.serialization.Model): - """Defines the authentication method and properties to access the artifacts. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: SasAuthentication. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. The authentication type.Constant filled by server. - :type type: str - """ - - _validation = { - 'type': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - } - - _subtype_map = { - 'type': {'Sas': 'SasAuthentication'} - } - - def __init__( - self, - **kwargs - ): - super(Authentication, self).__init__(**kwargs) - self.type = None # type: Optional[str] - - -class CloudErrorBody(msrest.serialization.Model): - """Detailed error information of any failure. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Error code string. - :vartype code: str - :ivar message: Descriptive error information. - :vartype message: str - :param target: Error target. - :type target: str - :param details: More detailed error information. - :type details: list[~azure.mgmt.deploymentmanager.models.CloudErrorBody] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = kwargs.get('target', None) - self.details = kwargs.get('details', None) - - -class HealthCheckStepAttributes(msrest.serialization.Model): - """The attributes for the health check step. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: RestHealthCheckStepAttributes. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. The type of health check.Constant filled by server. - :type type: str - :param wait_duration: The duration in ISO 8601 format for which health check waits idly without - any checks. - :type wait_duration: str - :param max_elastic_duration: The duration in ISO 8601 format for which the health check waits - for the resource to become healthy. Health check fails if it doesn't. Health check starts to - enforce healthyStateDuration once resource becomes healthy. - :type max_elastic_duration: str - :param healthy_state_duration: Required. The duration in ISO 8601 format for which the resource - is expected to be continuously healthy. If maxElasticDuration is specified, healthy state - duration is enforced after the detection of first healthy signal. - :type healthy_state_duration: str - """ - - _validation = { - 'type': {'required': True}, - 'healthy_state_duration': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'wait_duration': {'key': 'waitDuration', 'type': 'str'}, - 'max_elastic_duration': {'key': 'maxElasticDuration', 'type': 'str'}, - 'healthy_state_duration': {'key': 'healthyStateDuration', 'type': 'str'}, - } - - _subtype_map = { - 'type': {'REST': 'RestHealthCheckStepAttributes'} - } - - def __init__( - self, - **kwargs - ): - super(HealthCheckStepAttributes, self).__init__(**kwargs) - self.type = None # type: Optional[str] - self.wait_duration = kwargs.get('wait_duration', None) - self.max_elastic_duration = kwargs.get('max_elastic_duration', None) - self.healthy_state_duration = kwargs['healthy_state_duration'] - - -class StepProperties(msrest.serialization.Model): - """The properties of a step resource. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: HealthCheckStepProperties, WaitStepProperties. - - All required parameters must be populated in order to send to Azure. - - :param step_type: Required. The type of step.Constant filled by server. Possible values - include: "Wait", "HealthCheck". - :type step_type: str or ~azure.mgmt.deploymentmanager.models.StepType - """ - - _validation = { - 'step_type': {'required': True}, - } - - _attribute_map = { - 'step_type': {'key': 'stepType', 'type': 'str'}, - } - - _subtype_map = { - 'step_type': {'HealthCheck': 'HealthCheckStepProperties', 'Wait': 'WaitStepProperties'} - } - - def __init__( - self, - **kwargs - ): - super(StepProperties, self).__init__(**kwargs) - self.step_type = None # type: Optional[str] - - -class HealthCheckStepProperties(StepProperties): - """Defines the properties of a health check step. - - All required parameters must be populated in order to send to Azure. - - :param step_type: Required. The type of step.Constant filled by server. Possible values - include: "Wait", "HealthCheck". - :type step_type: str or ~azure.mgmt.deploymentmanager.models.StepType - :param attributes: Required. The health check step attributes. - :type attributes: ~azure.mgmt.deploymentmanager.models.HealthCheckStepAttributes - """ - - _validation = { - 'step_type': {'required': True}, - 'attributes': {'required': True}, - } - - _attribute_map = { - 'step_type': {'key': 'stepType', 'type': 'str'}, - 'attributes': {'key': 'attributes', 'type': 'HealthCheckStepAttributes'}, - } - - def __init__( - self, - **kwargs - ): - super(HealthCheckStepProperties, self).__init__(**kwargs) - self.step_type = 'HealthCheck' # type: str - self.attributes = kwargs['attributes'] - - -class Identity(msrest.serialization.Model): - """Identity for the resource. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. The identity type. - :type type: str - :param identity_ids: Required. The list of identities. - :type identity_ids: list[str] - """ - - _validation = { - 'type': {'required': True}, - 'identity_ids': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'identity_ids': {'key': 'identityIds', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(Identity, self).__init__(**kwargs) - self.type = kwargs['type'] - self.identity_ids = kwargs['identity_ids'] - - -class Message(msrest.serialization.Model): - """Supplementary contextual messages during a rollout. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar time_stamp: Time in UTC this message was provided. - :vartype time_stamp: ~datetime.datetime - :ivar message: The actual message text. - :vartype message: str - """ - - _validation = { - 'time_stamp': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'time_stamp': {'key': 'timeStamp', 'type': 'iso-8601'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Message, self).__init__(**kwargs) - self.time_stamp = None - self.message = None - - -class Operation(msrest.serialization.Model): - """Represents an operation that can be performed on the service. - - :param name: The name of the operation. - :type name: str - :param display: The display name of the operation. - :type display: ~azure.mgmt.deploymentmanager.models.OperationDetail - :param origin: The origin of the operation. - :type origin: str - :param properties: The properties of the operation. - :type properties: any - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDetail'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - self.properties = kwargs.get('properties', None) - - -class OperationDetail(msrest.serialization.Model): - """The detail about an operation. - - :param provider: The name of the provider that supports the operation. - :type provider: str - :param resource: The resource type on which this operation can be performed. - :type resource: str - :param operation: The name of the operation. - :type operation: str - :param description: The 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(OperationDetail, 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 OperationsList(msrest.serialization.Model): - """The operations response. - - :param value: The list of supported operations. - :type value: ~azure.mgmt.deploymentmanager.models.Operation - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'Operation'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class PrePostStep(msrest.serialization.Model): - """The properties that define a step. - - All required parameters must be populated in order to send to Azure. - - :param step_id: Required. The resource Id of the step to be run. - :type step_id: str - """ - - _validation = { - 'step_id': {'required': True}, - } - - _attribute_map = { - 'step_id': {'key': 'stepId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrePostStep, self).__init__(**kwargs) - self.step_id = kwargs['step_id'] - - -class ResourceOperation(msrest.serialization.Model): - """Individual resource operation information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param resource_name: Name of the resource as specified in the artifacts. For ARM resources, - this is the name of the resource specified in the template. - :type resource_name: str - :ivar operation_id: Unique identifier of the operation. For ARM resources, this is the - operationId obtained from ARM service. - :vartype operation_id: str - :param resource_type: Type of the resource as specified in the artifacts. For ARM resources, - this is the type of the resource specified in the template. - :type resource_type: str - :ivar provisioning_state: State of the resource deployment. For ARM resources, this is the - current provisioning state of the resource. - :vartype provisioning_state: str - :ivar status_message: Descriptive information of the resource operation. - :vartype status_message: str - :ivar status_code: Http status code of the operation. - :vartype status_code: str - """ - - _validation = { - 'operation_id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status_message': {'readonly': True}, - 'status_code': {'readonly': True}, - } - - _attribute_map = { - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'status_message': {'key': 'statusMessage', 'type': 'str'}, - 'status_code': {'key': 'statusCode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceOperation, self).__init__(**kwargs) - self.resource_name = kwargs.get('resource_name', None) - self.operation_id = None - self.resource_type = kwargs.get('resource_type', None) - self.provisioning_state = None - self.status_message = None - self.status_code = None - - -class RestHealthCheck(msrest.serialization.Model): - """A REST based health check. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. A unique name for this check. - :type name: str - :param request: Required. The request to the health provider. - :type request: ~azure.mgmt.deploymentmanager.models.RestRequest - :param response: The expected response from the health provider. If no expected response is - provided, the default is to expect the received response to have an HTTP status code of 200 OK. - :type response: ~azure.mgmt.deploymentmanager.models.RestResponse - """ - - _validation = { - 'name': {'required': True}, - 'request': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'request': {'key': 'request', 'type': 'RestRequest'}, - 'response': {'key': 'response', 'type': 'RestResponse'}, - } - - def __init__( - self, - **kwargs - ): - super(RestHealthCheck, self).__init__(**kwargs) - self.name = kwargs['name'] - self.request = kwargs['request'] - self.response = kwargs.get('response', None) - - -class RestHealthCheckStepAttributes(HealthCheckStepAttributes): - """Defines the REST health check step properties. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. The type of health check.Constant filled by server. - :type type: str - :param wait_duration: The duration in ISO 8601 format for which health check waits idly without - any checks. - :type wait_duration: str - :param max_elastic_duration: The duration in ISO 8601 format for which the health check waits - for the resource to become healthy. Health check fails if it doesn't. Health check starts to - enforce healthyStateDuration once resource becomes healthy. - :type max_elastic_duration: str - :param healthy_state_duration: Required. The duration in ISO 8601 format for which the resource - is expected to be continuously healthy. If maxElasticDuration is specified, healthy state - duration is enforced after the detection of first healthy signal. - :type healthy_state_duration: str - :param health_checks: The list of checks that form the health check step. - :type health_checks: list[~azure.mgmt.deploymentmanager.models.RestHealthCheck] - """ - - _validation = { - 'type': {'required': True}, - 'healthy_state_duration': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'wait_duration': {'key': 'waitDuration', 'type': 'str'}, - 'max_elastic_duration': {'key': 'maxElasticDuration', 'type': 'str'}, - 'healthy_state_duration': {'key': 'healthyStateDuration', 'type': 'str'}, - 'health_checks': {'key': 'properties.healthChecks', 'type': '[RestHealthCheck]'}, - } - - def __init__( - self, - **kwargs - ): - super(RestHealthCheckStepAttributes, self).__init__(**kwargs) - self.type = 'REST' # type: str - self.health_checks = kwargs.get('health_checks', None) - - -class RestRequest(msrest.serialization.Model): - """The properties that make up a REST request. - - All required parameters must be populated in order to send to Azure. - - :param method: Required. The HTTP method to use for the request. Possible values include: - "GET", "POST". - :type method: str or ~azure.mgmt.deploymentmanager.models.RestRequestMethod - :param uri: Required. The HTTP URI to use for the request. - :type uri: str - :param authentication: Required. The authentication information required in the request to the - health provider. - :type authentication: ~azure.mgmt.deploymentmanager.models.RestRequestAuthentication - """ - - _validation = { - 'method': {'required': True}, - 'uri': {'required': True}, - 'authentication': {'required': True}, - } - - _attribute_map = { - 'method': {'key': 'method', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'authentication': {'key': 'authentication', 'type': 'RestRequestAuthentication'}, - } - - def __init__( - self, - **kwargs - ): - super(RestRequest, self).__init__(**kwargs) - self.method = kwargs['method'] - self.uri = kwargs['uri'] - self.authentication = kwargs['authentication'] - - -class RestResponse(msrest.serialization.Model): - """The properties that make up the expected REST response. - - :param success_status_codes: The HTTP status codes expected in a successful health check - response. The response is expected to match one of the given status codes. If no expected - status codes are provided, default expected status code is 200 OK. - :type success_status_codes: list[str] - :param regex: The regular expressions to match the response content with. - :type regex: ~azure.mgmt.deploymentmanager.models.RestResponseRegex - """ - - _attribute_map = { - 'success_status_codes': {'key': 'successStatusCodes', 'type': '[str]'}, - 'regex': {'key': 'regex', 'type': 'RestResponseRegex'}, - } - - def __init__( - self, - **kwargs - ): - super(RestResponse, self).__init__(**kwargs) - self.success_status_codes = kwargs.get('success_status_codes', None) - self.regex = kwargs.get('regex', None) - - -class RestResponseRegex(msrest.serialization.Model): - """The regular expressions to match the response content with. - - :param matches: The list of regular expressions. - :type matches: list[str] - :param match_quantifier: Indicates whether any or all of the expressions should match with the - response content. Possible values include: "All", "Any". - :type match_quantifier: str or ~azure.mgmt.deploymentmanager.models.RestMatchQuantifier - """ - - _attribute_map = { - 'matches': {'key': 'matches', 'type': '[str]'}, - 'match_quantifier': {'key': 'matchQuantifier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RestResponseRegex, self).__init__(**kwargs) - self.matches = kwargs.get('matches', None) - self.match_quantifier = kwargs.get('match_quantifier', None) - - -class Rollout(TrackedResource): - """Defines the rollout. - - 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. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param identity: Identity for the resource. - :type identity: ~azure.mgmt.deploymentmanager.models.Identity - :param build_version: The version of the build being deployed. - :type build_version: str - :param artifact_source_id: The reference to the artifact source resource Id where the payload - is located. - :type artifact_source_id: str - :param target_service_topology_id: The resource Id of the service topology from which service - units are being referenced in step groups to be deployed. - :type target_service_topology_id: str - :param step_groups: The list of step groups that define the orchestration. - :type step_groups: list[~azure.mgmt.deploymentmanager.models.StepGroup] - :ivar status: The current status of the rollout. - :vartype status: str - :ivar total_retry_attempts: The cardinal count of total number of retries performed on the - rollout at a given time. - :vartype total_retry_attempts: int - :ivar operation_info: Operational information of the rollout. - :vartype operation_info: ~azure.mgmt.deploymentmanager.models.RolloutOperationInfo - :ivar services: The detailed information on the services being deployed. - :vartype services: list[~azure.mgmt.deploymentmanager.models.Service] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'status': {'readonly': True}, - 'total_retry_attempts': {'readonly': True}, - 'operation_info': {'readonly': True}, - 'services': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'build_version': {'key': 'properties.buildVersion', 'type': 'str'}, - 'artifact_source_id': {'key': 'properties.artifactSourceId', 'type': 'str'}, - 'target_service_topology_id': {'key': 'properties.targetServiceTopologyId', 'type': 'str'}, - 'step_groups': {'key': 'properties.stepGroups', 'type': '[StepGroup]'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'total_retry_attempts': {'key': 'properties.totalRetryAttempts', 'type': 'int'}, - 'operation_info': {'key': 'properties.operationInfo', 'type': 'RolloutOperationInfo'}, - 'services': {'key': 'properties.services', 'type': '[Service]'}, - } - - def __init__( - self, - **kwargs - ): - super(Rollout, self).__init__(**kwargs) - self.identity = kwargs.get('identity', None) - self.build_version = kwargs.get('build_version', None) - self.artifact_source_id = kwargs.get('artifact_source_id', None) - self.target_service_topology_id = kwargs.get('target_service_topology_id', None) - self.step_groups = kwargs.get('step_groups', None) - self.status = None - self.total_retry_attempts = None - self.operation_info = None - self.services = None - - -class RolloutIdentityAuthentication(RestRequestAuthentication): - """RolloutIdentity uses the user-assigned managed identity authentication context specified in the Identity property during rollout creation. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. The authentication type.Constant filled by server. Possible values - include: "ApiKey", "RolloutIdentity". - :type type: str or ~azure.mgmt.deploymentmanager.models.RestAuthType - """ - - _validation = { - 'type': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RolloutIdentityAuthentication, self).__init__(**kwargs) - self.type = 'RolloutIdentity' # type: str - - -class RolloutOperationInfo(msrest.serialization.Model): - """Detailed runtime information of the rollout. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar retry_attempt: The ordinal count of the number of retry attempts on a rollout. 0 if no - retries of the rollout have been performed. If the rollout is updated with a PUT, this count is - reset to 0. - :vartype retry_attempt: int - :ivar skip_succeeded_on_retry: True, if all steps that succeeded on the previous run/attempt - were chosen to be skipped in this retry attempt. False, otherwise. - :vartype skip_succeeded_on_retry: bool - :ivar start_time: The start time of the rollout in UTC. - :vartype start_time: ~datetime.datetime - :ivar end_time: The start time of the rollout in UTC. This property will not be set if the - rollout has not completed yet. - :vartype end_time: ~datetime.datetime - :ivar error: The detailed error information for any failure. - :vartype error: ~azure.mgmt.deploymentmanager.models.CloudErrorBody - """ - - _validation = { - 'retry_attempt': {'readonly': True}, - 'skip_succeeded_on_retry': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'error': {'readonly': True}, - } - - _attribute_map = { - 'retry_attempt': {'key': 'retryAttempt', 'type': 'int'}, - 'skip_succeeded_on_retry': {'key': 'skipSucceededOnRetry', 'type': 'bool'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'error': {'key': 'error', 'type': 'CloudErrorBody'}, - } - - def __init__( - self, - **kwargs - ): - super(RolloutOperationInfo, self).__init__(**kwargs) - self.retry_attempt = None - self.skip_succeeded_on_retry = None - self.start_time = None - self.end_time = None - self.error = None - - -class RolloutProperties(msrest.serialization.Model): - """Defines the properties of a rollout. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The current status of the rollout. - :vartype status: str - :ivar total_retry_attempts: The cardinal count of total number of retries performed on the - rollout at a given time. - :vartype total_retry_attempts: int - :ivar operation_info: Operational information of the rollout. - :vartype operation_info: ~azure.mgmt.deploymentmanager.models.RolloutOperationInfo - :ivar services: The detailed information on the services being deployed. - :vartype services: list[~azure.mgmt.deploymentmanager.models.Service] - """ - - _validation = { - 'status': {'readonly': True}, - 'total_retry_attempts': {'readonly': True}, - 'operation_info': {'readonly': True}, - 'services': {'readonly': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'total_retry_attempts': {'key': 'totalRetryAttempts', 'type': 'int'}, - 'operation_info': {'key': 'operationInfo', 'type': 'RolloutOperationInfo'}, - 'services': {'key': 'services', 'type': '[Service]'}, - } - - def __init__( - self, - **kwargs - ): - super(RolloutProperties, self).__init__(**kwargs) - self.status = None - self.total_retry_attempts = None - self.operation_info = None - self.services = None - - -class RolloutRequestProperties(msrest.serialization.Model): - """The properties for defining a rollout. - - All required parameters must be populated in order to send to Azure. - - :param build_version: Required. The version of the build being deployed. - :type build_version: str - :param artifact_source_id: The reference to the artifact source resource Id where the payload - is located. - :type artifact_source_id: str - :param target_service_topology_id: Required. The resource Id of the service topology from which - service units are being referenced in step groups to be deployed. - :type target_service_topology_id: str - :param step_groups: Required. The list of step groups that define the orchestration. - :type step_groups: list[~azure.mgmt.deploymentmanager.models.StepGroup] - """ - - _validation = { - 'build_version': {'required': True}, - 'target_service_topology_id': {'required': True}, - 'step_groups': {'required': True}, - } - - _attribute_map = { - 'build_version': {'key': 'buildVersion', 'type': 'str'}, - 'artifact_source_id': {'key': 'artifactSourceId', 'type': 'str'}, - 'target_service_topology_id': {'key': 'targetServiceTopologyId', 'type': 'str'}, - 'step_groups': {'key': 'stepGroups', 'type': '[StepGroup]'}, - } - - def __init__( - self, - **kwargs - ): - super(RolloutRequestProperties, self).__init__(**kwargs) - self.build_version = kwargs['build_version'] - self.artifact_source_id = kwargs.get('artifact_source_id', None) - self.target_service_topology_id = kwargs['target_service_topology_id'] - self.step_groups = kwargs['step_groups'] - - -class RolloutPropertiesAutoGenerated(RolloutRequestProperties, RolloutProperties): - """The properties that define a rollout. - - 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. - - :ivar status: The current status of the rollout. - :vartype status: str - :ivar total_retry_attempts: The cardinal count of total number of retries performed on the - rollout at a given time. - :vartype total_retry_attempts: int - :ivar operation_info: Operational information of the rollout. - :vartype operation_info: ~azure.mgmt.deploymentmanager.models.RolloutOperationInfo - :ivar services: The detailed information on the services being deployed. - :vartype services: list[~azure.mgmt.deploymentmanager.models.Service] - :param build_version: Required. The version of the build being deployed. - :type build_version: str - :param artifact_source_id: The reference to the artifact source resource Id where the payload - is located. - :type artifact_source_id: str - :param target_service_topology_id: Required. The resource Id of the service topology from which - service units are being referenced in step groups to be deployed. - :type target_service_topology_id: str - :param step_groups: Required. The list of step groups that define the orchestration. - :type step_groups: list[~azure.mgmt.deploymentmanager.models.StepGroup] - """ - - _validation = { - 'status': {'readonly': True}, - 'total_retry_attempts': {'readonly': True}, - 'operation_info': {'readonly': True}, - 'services': {'readonly': True}, - 'build_version': {'required': True}, - 'target_service_topology_id': {'required': True}, - 'step_groups': {'required': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'total_retry_attempts': {'key': 'totalRetryAttempts', 'type': 'int'}, - 'operation_info': {'key': 'operationInfo', 'type': 'RolloutOperationInfo'}, - 'services': {'key': 'services', 'type': '[Service]'}, - 'build_version': {'key': 'buildVersion', 'type': 'str'}, - 'artifact_source_id': {'key': 'artifactSourceId', 'type': 'str'}, - 'target_service_topology_id': {'key': 'targetServiceTopologyId', 'type': 'str'}, - 'step_groups': {'key': 'stepGroups', 'type': '[StepGroup]'}, - } - - def __init__( - self, - **kwargs - ): - super(RolloutPropertiesAutoGenerated, self).__init__(**kwargs) - self.status = None - self.total_retry_attempts = None - self.operation_info = None - self.services = None - self.build_version = kwargs['build_version'] - self.artifact_source_id = kwargs.get('artifact_source_id', None) - self.target_service_topology_id = kwargs['target_service_topology_id'] - self.step_groups = kwargs['step_groups'] - - -class RolloutRequest(TrackedResource): - """Defines the PUT rollout request body. - - 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. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param identity: Required. Identity for the resource. - :type identity: ~azure.mgmt.deploymentmanager.models.Identity - :param build_version: Required. The version of the build being deployed. - :type build_version: str - :param artifact_source_id: The reference to the artifact source resource Id where the payload - is located. - :type artifact_source_id: str - :param target_service_topology_id: Required. The resource Id of the service topology from which - service units are being referenced in step groups to be deployed. - :type target_service_topology_id: str - :param step_groups: Required. The list of step groups that define the orchestration. - :type step_groups: list[~azure.mgmt.deploymentmanager.models.StepGroup] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'identity': {'required': True}, - 'build_version': {'required': True}, - 'target_service_topology_id': {'required': True}, - 'step_groups': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'build_version': {'key': 'properties.buildVersion', 'type': 'str'}, - 'artifact_source_id': {'key': 'properties.artifactSourceId', 'type': 'str'}, - 'target_service_topology_id': {'key': 'properties.targetServiceTopologyId', 'type': 'str'}, - 'step_groups': {'key': 'properties.stepGroups', 'type': '[StepGroup]'}, - } - - def __init__( - self, - **kwargs - ): - super(RolloutRequest, self).__init__(**kwargs) - self.identity = kwargs['identity'] - self.build_version = kwargs['build_version'] - self.artifact_source_id = kwargs.get('artifact_source_id', None) - self.target_service_topology_id = kwargs['target_service_topology_id'] - self.step_groups = kwargs['step_groups'] - - -class RolloutStep(msrest.serialization.Model): - """Defines a specific step on a target service unit. - - 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 name: Required. Name of the step. - :type name: str - :ivar status: Current state of the step. - :vartype status: str - :param step_group: The step group the current step is part of. - :type step_group: str - :ivar operation_info: Detailed information of specific action execution. - :vartype operation_info: ~azure.mgmt.deploymentmanager.models.StepOperationInfo - :ivar resource_operations: Set of resource operations that were performed, if any, on an Azure - resource. - :vartype resource_operations: list[~azure.mgmt.deploymentmanager.models.ResourceOperation] - :ivar messages: Supplementary informative messages during rollout. - :vartype messages: list[~azure.mgmt.deploymentmanager.models.Message] - """ - - _validation = { - 'name': {'required': True}, - 'status': {'readonly': True}, - 'operation_info': {'readonly': True}, - 'resource_operations': {'readonly': True}, - 'messages': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'step_group': {'key': 'stepGroup', 'type': 'str'}, - 'operation_info': {'key': 'operationInfo', 'type': 'StepOperationInfo'}, - 'resource_operations': {'key': 'resourceOperations', 'type': '[ResourceOperation]'}, - 'messages': {'key': 'messages', 'type': '[Message]'}, - } - - def __init__( - self, - **kwargs - ): - super(RolloutStep, self).__init__(**kwargs) - self.name = kwargs['name'] - self.status = None - self.step_group = kwargs.get('step_group', None) - self.operation_info = None - self.resource_operations = None - self.messages = None - - -class SasAuthentication(Authentication): - """Defines the properties to access the artifacts using an Azure Storage SAS URI. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. The authentication type.Constant filled by server. - :type type: str - :param sas_uri: The SAS URI to the Azure Storage blob container. Any offset from the root of - the container to where the artifacts are located can be defined in the artifactRoot. - :type sas_uri: str - """ - - _validation = { - 'type': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'sas_uri': {'key': 'properties.sasUri', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SasAuthentication, self).__init__(**kwargs) - self.type = 'Sas' # type: str - self.sas_uri = kwargs.get('sas_uri', None) - - -class ServiceProperties(msrest.serialization.Model): - """The properties of a service. - - All required parameters must be populated in order to send to Azure. - - :param target_location: Required. The Azure location to which the resources in the service - belong to or should be deployed to. - :type target_location: str - :param target_subscription_id: Required. The subscription to which the resources in the service - belong to or should be deployed to. - :type target_subscription_id: str - """ - - _validation = { - 'target_location': {'required': True}, - 'target_subscription_id': {'required': True}, - } - - _attribute_map = { - 'target_location': {'key': 'targetLocation', 'type': 'str'}, - 'target_subscription_id': {'key': 'targetSubscriptionId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceProperties, self).__init__(**kwargs) - self.target_location = kwargs['target_location'] - self.target_subscription_id = kwargs['target_subscription_id'] - - -class Service(ServiceProperties): - """Defines a service. - - All required parameters must be populated in order to send to Azure. - - :param target_location: Required. The Azure location to which the resources in the service - belong to or should be deployed to. - :type target_location: str - :param target_subscription_id: Required. The subscription to which the resources in the service - belong to or should be deployed to. - :type target_subscription_id: str - :param name: Name of the service. - :type name: str - :param service_units: The detailed information about the units that make up the service. - :type service_units: list[~azure.mgmt.deploymentmanager.models.ServiceUnit] - """ - - _validation = { - 'target_location': {'required': True}, - 'target_subscription_id': {'required': True}, - } - - _attribute_map = { - 'target_location': {'key': 'targetLocation', 'type': 'str'}, - 'target_subscription_id': {'key': 'targetSubscriptionId', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'service_units': {'key': 'serviceUnits', 'type': '[ServiceUnit]'}, - } - - def __init__( - self, - **kwargs - ): - super(Service, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.service_units = kwargs.get('service_units', None) - - -class ServiceResource(TrackedResource): - """The resource representation of a service in a service topology. - - 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. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param target_location: Required. The Azure location to which the resources in the service - belong to or should be deployed to. - :type target_location: str - :param target_subscription_id: Required. The subscription to which the resources in the service - belong to or should be deployed to. - :type target_subscription_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'target_location': {'required': True}, - 'target_subscription_id': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'target_location': {'key': 'properties.targetLocation', 'type': 'str'}, - 'target_subscription_id': {'key': 'properties.targetSubscriptionId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceResource, self).__init__(**kwargs) - self.target_location = kwargs['target_location'] - self.target_subscription_id = kwargs['target_subscription_id'] - - -class ServiceResourceProperties(ServiceProperties): - """The properties that define a service in a service topology. - - All required parameters must be populated in order to send to Azure. - - :param target_location: Required. The Azure location to which the resources in the service - belong to or should be deployed to. - :type target_location: str - :param target_subscription_id: Required. The subscription to which the resources in the service - belong to or should be deployed to. - :type target_subscription_id: str - """ - - _validation = { - 'target_location': {'required': True}, - 'target_subscription_id': {'required': True}, - } - - _attribute_map = { - 'target_location': {'key': 'targetLocation', 'type': 'str'}, - 'target_subscription_id': {'key': 'targetSubscriptionId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceResourceProperties, self).__init__(**kwargs) - - -class ServiceTopologyProperties(msrest.serialization.Model): - """The properties of a service topology. - - :param artifact_source_id: The resource Id of the artifact source that contains the artifacts - that can be referenced in the service units. - :type artifact_source_id: str - """ - - _attribute_map = { - 'artifact_source_id': {'key': 'artifactSourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceTopologyProperties, self).__init__(**kwargs) - self.artifact_source_id = kwargs.get('artifact_source_id', None) - - -class ServiceTopologyResource(TrackedResource): - """The resource representation of a service topology. - - 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. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param artifact_source_id: The resource Id of the artifact source that contains the artifacts - that can be referenced in the service units. - :type artifact_source_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'artifact_source_id': {'key': 'properties.artifactSourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceTopologyResource, self).__init__(**kwargs) - self.artifact_source_id = kwargs.get('artifact_source_id', None) - - -class ServiceTopologyResourceProperties(ServiceTopologyProperties): - """The properties that define the service topology. - - :param artifact_source_id: The resource Id of the artifact source that contains the artifacts - that can be referenced in the service units. - :type artifact_source_id: str - """ - - _attribute_map = { - 'artifact_source_id': {'key': 'artifactSourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceTopologyResourceProperties, self).__init__(**kwargs) - - -class ServiceUnitProperties(msrest.serialization.Model): - """Defines the properties of a service unit. - - All required parameters must be populated in order to send to Azure. - - :param target_resource_group: Required. The Azure Resource Group to which the resources in the - service unit belong to or should be deployed to. - :type target_resource_group: str - :param deployment_mode: Required. Describes the type of ARM deployment to be performed on the - resource. Possible values include: "Incremental", "Complete". - :type deployment_mode: str or ~azure.mgmt.deploymentmanager.models.DeploymentMode - :param artifacts: The artifacts for the service unit. - :type artifacts: ~azure.mgmt.deploymentmanager.models.ServiceUnitArtifacts - """ - - _validation = { - 'target_resource_group': {'required': True}, - 'deployment_mode': {'required': True}, - } - - _attribute_map = { - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, - 'deployment_mode': {'key': 'deploymentMode', 'type': 'str'}, - 'artifacts': {'key': 'artifacts', 'type': 'ServiceUnitArtifacts'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceUnitProperties, self).__init__(**kwargs) - self.target_resource_group = kwargs['target_resource_group'] - self.deployment_mode = kwargs['deployment_mode'] - self.artifacts = kwargs.get('artifacts', None) - - -class ServiceUnit(ServiceUnitProperties): - """Defines a service unit. - - All required parameters must be populated in order to send to Azure. - - :param target_resource_group: Required. The Azure Resource Group to which the resources in the - service unit belong to or should be deployed to. - :type target_resource_group: str - :param deployment_mode: Required. Describes the type of ARM deployment to be performed on the - resource. Possible values include: "Incremental", "Complete". - :type deployment_mode: str or ~azure.mgmt.deploymentmanager.models.DeploymentMode - :param artifacts: The artifacts for the service unit. - :type artifacts: ~azure.mgmt.deploymentmanager.models.ServiceUnitArtifacts - :param name: Name of the service unit. - :type name: str - :param steps: Detailed step information, if present. - :type steps: list[~azure.mgmt.deploymentmanager.models.RolloutStep] - """ - - _validation = { - 'target_resource_group': {'required': True}, - 'deployment_mode': {'required': True}, - } - - _attribute_map = { - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, - 'deployment_mode': {'key': 'deploymentMode', 'type': 'str'}, - 'artifacts': {'key': 'artifacts', 'type': 'ServiceUnitArtifacts'}, - 'name': {'key': 'name', 'type': 'str'}, - 'steps': {'key': 'steps', 'type': '[RolloutStep]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceUnit, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.steps = kwargs.get('steps', None) - - -class ServiceUnitArtifacts(msrest.serialization.Model): - """Defines the artifacts of a service unit. - - :param template_uri: The full URI of the ARM template file with the SAS token. - :type template_uri: str - :param parameters_uri: The full URI of the ARM parameters file with the SAS token. - :type parameters_uri: str - :param template_artifact_source_relative_path: The path to the ARM template file relative to - the artifact source. - :type template_artifact_source_relative_path: str - :param parameters_artifact_source_relative_path: The path to the ARM parameters file relative - to the artifact source. - :type parameters_artifact_source_relative_path: str - """ - - _attribute_map = { - 'template_uri': {'key': 'templateUri', 'type': 'str'}, - 'parameters_uri': {'key': 'parametersUri', 'type': 'str'}, - 'template_artifact_source_relative_path': {'key': 'templateArtifactSourceRelativePath', 'type': 'str'}, - 'parameters_artifact_source_relative_path': {'key': 'parametersArtifactSourceRelativePath', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceUnitArtifacts, self).__init__(**kwargs) - self.template_uri = kwargs.get('template_uri', None) - self.parameters_uri = kwargs.get('parameters_uri', None) - self.template_artifact_source_relative_path = kwargs.get('template_artifact_source_relative_path', None) - self.parameters_artifact_source_relative_path = kwargs.get('parameters_artifact_source_relative_path', None) - - -class ServiceUnitResource(TrackedResource): - """Represents the response of a service unit resource. - - 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. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param target_resource_group: Required. The Azure Resource Group to which the resources in the - service unit belong to or should be deployed to. - :type target_resource_group: str - :param deployment_mode: Required. Describes the type of ARM deployment to be performed on the - resource. Possible values include: "Incremental", "Complete". - :type deployment_mode: str or ~azure.mgmt.deploymentmanager.models.DeploymentMode - :param artifacts: The artifacts for the service unit. - :type artifacts: ~azure.mgmt.deploymentmanager.models.ServiceUnitArtifacts - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'target_resource_group': {'required': True}, - 'deployment_mode': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'target_resource_group': {'key': 'properties.targetResourceGroup', 'type': 'str'}, - 'deployment_mode': {'key': 'properties.deploymentMode', 'type': 'str'}, - 'artifacts': {'key': 'properties.artifacts', 'type': 'ServiceUnitArtifacts'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceUnitResource, self).__init__(**kwargs) - self.target_resource_group = kwargs['target_resource_group'] - self.deployment_mode = kwargs['deployment_mode'] - self.artifacts = kwargs.get('artifacts', None) - - -class ServiceUnitResourceProperties(ServiceUnitProperties): - """The properties that define the service unit. - - All required parameters must be populated in order to send to Azure. - - :param target_resource_group: Required. The Azure Resource Group to which the resources in the - service unit belong to or should be deployed to. - :type target_resource_group: str - :param deployment_mode: Required. Describes the type of ARM deployment to be performed on the - resource. Possible values include: "Incremental", "Complete". - :type deployment_mode: str or ~azure.mgmt.deploymentmanager.models.DeploymentMode - :param artifacts: The artifacts for the service unit. - :type artifacts: ~azure.mgmt.deploymentmanager.models.ServiceUnitArtifacts - """ - - _validation = { - 'target_resource_group': {'required': True}, - 'deployment_mode': {'required': True}, - } - - _attribute_map = { - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, - 'deployment_mode': {'key': 'deploymentMode', 'type': 'str'}, - 'artifacts': {'key': 'artifacts', 'type': 'ServiceUnitArtifacts'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceUnitResourceProperties, self).__init__(**kwargs) - - -class StepGroup(msrest.serialization.Model): - """The properties that define a Step group in a rollout. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the step group. - :type name: str - :param depends_on_step_groups: The list of step group names on which this step group depends - on. - :type depends_on_step_groups: list[str] - :param pre_deployment_steps: The list of steps to be run before deploying the target. - :type pre_deployment_steps: list[~azure.mgmt.deploymentmanager.models.PrePostStep] - :param deployment_target_id: Required. The resource Id of service unit to be deployed. The - service unit should be from the service topology referenced in targetServiceTopologyId. - :type deployment_target_id: str - :param post_deployment_steps: The list of steps to be run after deploying the target. - :type post_deployment_steps: list[~azure.mgmt.deploymentmanager.models.PrePostStep] - """ - - _validation = { - 'name': {'required': True}, - 'deployment_target_id': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'depends_on_step_groups': {'key': 'dependsOnStepGroups', 'type': '[str]'}, - 'pre_deployment_steps': {'key': 'preDeploymentSteps', 'type': '[PrePostStep]'}, - 'deployment_target_id': {'key': 'deploymentTargetId', 'type': 'str'}, - 'post_deployment_steps': {'key': 'postDeploymentSteps', 'type': '[PrePostStep]'}, - } - - def __init__( - self, - **kwargs - ): - super(StepGroup, self).__init__(**kwargs) - self.name = kwargs['name'] - self.depends_on_step_groups = kwargs.get('depends_on_step_groups', None) - self.pre_deployment_steps = kwargs.get('pre_deployment_steps', None) - self.deployment_target_id = kwargs['deployment_target_id'] - self.post_deployment_steps = kwargs.get('post_deployment_steps', None) - - -class StepOperationInfo(msrest.serialization.Model): - """Detailed information of a specific step run. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar deployment_name: The name of the ARM deployment initiated as part of the step. - :vartype deployment_name: str - :ivar correlation_id: Unique identifier to track the request for ARM-based resources. - :vartype correlation_id: str - :ivar start_time: Start time of the action in UTC. - :vartype start_time: ~datetime.datetime - :ivar end_time: End time of the action in UTC. - :vartype end_time: ~datetime.datetime - :ivar last_updated_time: Last time in UTC this operation was updated. - :vartype last_updated_time: ~datetime.datetime - :param error: The errors, if any, for the action. - :type error: ~azure.mgmt.deploymentmanager.models.CloudErrorBody - """ - - _validation = { - 'deployment_name': {'readonly': True}, - 'correlation_id': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'last_updated_time': {'readonly': True}, - } - - _attribute_map = { - 'deployment_name': {'key': 'deploymentName', 'type': 'str'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'last_updated_time': {'key': 'lastUpdatedTime', 'type': 'iso-8601'}, - 'error': {'key': 'error', 'type': 'CloudErrorBody'}, - } - - def __init__( - self, - **kwargs - ): - super(StepOperationInfo, self).__init__(**kwargs) - self.deployment_name = None - self.correlation_id = None - self.start_time = None - self.end_time = None - self.last_updated_time = None - self.error = kwargs.get('error', None) - - -class StepResource(TrackedResource): - """The resource representation of a rollout step. - - 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. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param properties: Required. The properties that define the step. - :type properties: ~azure.mgmt.deploymentmanager.models.StepProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'properties': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'StepProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(StepResource, self).__init__(**kwargs) - self.properties = kwargs['properties'] - - -class WaitStepAttributes(msrest.serialization.Model): - """The parameters for the wait step. - - All required parameters must be populated in order to send to Azure. - - :param duration: Required. The duration in ISO 8601 format of how long the wait should be. - :type duration: str - """ - - _validation = { - 'duration': {'required': True}, - } - - _attribute_map = { - 'duration': {'key': 'duration', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WaitStepAttributes, self).__init__(**kwargs) - self.duration = kwargs['duration'] - - -class WaitStepProperties(StepProperties): - """Defines the properties of a Wait step. - - All required parameters must be populated in order to send to Azure. - - :param step_type: Required. The type of step.Constant filled by server. Possible values - include: "Wait", "HealthCheck". - :type step_type: str or ~azure.mgmt.deploymentmanager.models.StepType - :param attributes: Required. The Wait attributes. - :type attributes: ~azure.mgmt.deploymentmanager.models.WaitStepAttributes - """ - - _validation = { - 'step_type': {'required': True}, - 'attributes': {'required': True}, - } - - _attribute_map = { - 'step_type': {'key': 'stepType', 'type': 'str'}, - 'attributes': {'key': 'attributes', 'type': 'WaitStepAttributes'}, - } - - def __init__( - self, - **kwargs - ): - super(WaitStepProperties, self).__init__(**kwargs) - self.step_type = 'Wait' # type: str - self.attributes = kwargs['attributes'] diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/models/_models_py3.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/models/_models_py3.py index b8d3dcc3747a..a82064f87a20 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/models/_models_py3.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/models/_models_py3.py @@ -6,11 +6,13 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union import msrest.serialization -from ._azure_deployment_manager_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class RestRequestAuthentication(msrest.serialization.Model): @@ -21,9 +23,9 @@ class RestRequestAuthentication(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. The authentication type.Constant filled by server. Possible values - include: "ApiKey", "RolloutIdentity". - :type type: str or ~azure.mgmt.deploymentmanager.models.RestAuthType + :ivar type: Required. The authentication type.Constant filled by server. Known values are: + "ApiKey", "RolloutIdentity". + :vartype type: str or ~azure.mgmt.deploymentmanager.models.RestAuthType """ _validation = { @@ -42,6 +44,8 @@ def __init__( self, **kwargs ): + """ + """ super(RestRequestAuthentication, self).__init__(**kwargs) self.type = None # type: Optional[str] @@ -51,16 +55,16 @@ class ApiKeyAuthentication(RestRequestAuthentication): All required parameters must be populated in order to send to Azure. - :param type: Required. The authentication type.Constant filled by server. Possible values - include: "ApiKey", "RolloutIdentity". - :type type: str or ~azure.mgmt.deploymentmanager.models.RestAuthType - :param name: Required. The key name of the authentication key/value pair. - :type name: str - :param in_property: Required. The location of the authentication key/value pair in the request. - Possible values include: "Query", "Header". - :type in_property: str or ~azure.mgmt.deploymentmanager.models.RestAuthLocation - :param value: Required. The value of the authentication key/value pair. - :type value: str + :ivar type: Required. The authentication type.Constant filled by server. Known values are: + "ApiKey", "RolloutIdentity". + :vartype type: str or ~azure.mgmt.deploymentmanager.models.RestAuthType + :ivar name: Required. The key name of the authentication key/value pair. + :vartype name: str + :ivar in_property: Required. The location of the authentication key/value pair in the request. + Known values are: "Query", "Header". + :vartype in_property: str or ~azure.mgmt.deploymentmanager.models.RestAuthLocation + :ivar value: Required. The value of the authentication key/value pair. + :vartype value: str """ _validation = { @@ -81,10 +85,19 @@ def __init__( self, *, name: str, - in_property: Union[str, "RestAuthLocation"], + in_property: Union[str, "_models.RestAuthLocation"], value: str, **kwargs ): + """ + :keyword name: Required. The key name of the authentication key/value pair. + :paramtype name: str + :keyword in_property: Required. The location of the authentication key/value pair in the + request. Known values are: "Query", "Header". + :paramtype in_property: str or ~azure.mgmt.deploymentmanager.models.RestAuthLocation + :keyword value: Required. The value of the authentication key/value pair. + :paramtype value: str + """ super(ApiKeyAuthentication, self).__init__(**kwargs) self.type = 'ApiKey' # type: str self.name = name @@ -123,6 +136,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -144,10 +159,10 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str """ _validation = { @@ -172,6 +187,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + """ super(TrackedResource, self).__init__(**kwargs) self.tags = tags self.location = location @@ -192,21 +213,21 @@ class ArtifactSource(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param source_type: The type of artifact source used. - :type source_type: str - :param artifact_root: The path from the location that the 'authentication' property [say, a SAS + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar source_type: The type of artifact source used. + :vartype source_type: str + :ivar artifact_root: The path from the location that the 'authentication' property [say, a SAS URI to the blob container] refers to, to the location of the artifacts. This can be used to differentiate different versions of the artifacts. Or, different types of artifacts like binaries or templates. The location referenced by the authentication property concatenated with this optional artifactRoot path forms the artifact source location where the artifacts are expected to be found. - :type artifact_root: str - :param authentication: The authentication method to use to access the artifact source. - :type authentication: ~azure.mgmt.deploymentmanager.models.Authentication + :vartype artifact_root: str + :ivar authentication: The authentication method to use to access the artifact source. + :vartype authentication: ~azure.mgmt.deploymentmanager.models.Authentication """ _validation = { @@ -234,9 +255,26 @@ def __init__( tags: Optional[Dict[str, str]] = None, source_type: Optional[str] = None, artifact_root: Optional[str] = None, - authentication: Optional["Authentication"] = None, + authentication: Optional["_models.Authentication"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword source_type: The type of artifact source used. + :paramtype source_type: str + :keyword artifact_root: The path from the location that the 'authentication' property [say, a + SAS URI to the blob container] refers to, to the location of the artifacts. This can be used to + differentiate different versions of the artifacts. Or, different types of artifacts like + binaries or templates. The location referenced by the authentication property concatenated with + this optional artifactRoot path forms the artifact source location where the artifacts are + expected to be found. + :paramtype artifact_root: str + :keyword authentication: The authentication method to use to access the artifact source. + :paramtype authentication: ~azure.mgmt.deploymentmanager.models.Authentication + """ super(ArtifactSource, self).__init__(tags=tags, location=location, **kwargs) self.source_type = source_type self.artifact_root = artifact_root @@ -248,18 +286,17 @@ class ArtifactSourceProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param source_type: Required. The type of artifact source used. - :type source_type: str - :param artifact_root: The path from the location that the 'authentication' property [say, a SAS + :ivar source_type: Required. The type of artifact source used. + :vartype source_type: str + :ivar artifact_root: The path from the location that the 'authentication' property [say, a SAS URI to the blob container] refers to, to the location of the artifacts. This can be used to differentiate different versions of the artifacts. Or, different types of artifacts like binaries or templates. The location referenced by the authentication property concatenated with this optional artifactRoot path forms the artifact source location where the artifacts are expected to be found. - :type artifact_root: str - :param authentication: Required. The authentication method to use to access the artifact - source. - :type authentication: ~azure.mgmt.deploymentmanager.models.Authentication + :vartype artifact_root: str + :ivar authentication: Required. The authentication method to use to access the artifact source. + :vartype authentication: ~azure.mgmt.deploymentmanager.models.Authentication """ _validation = { @@ -277,10 +314,24 @@ def __init__( self, *, source_type: str, - authentication: "Authentication", + authentication: "_models.Authentication", artifact_root: Optional[str] = None, **kwargs ): + """ + :keyword source_type: Required. The type of artifact source used. + :paramtype source_type: str + :keyword artifact_root: The path from the location that the 'authentication' property [say, a + SAS URI to the blob container] refers to, to the location of the artifacts. This can be used to + differentiate different versions of the artifacts. Or, different types of artifacts like + binaries or templates. The location referenced by the authentication property concatenated with + this optional artifactRoot path forms the artifact source location where the artifacts are + expected to be found. + :paramtype artifact_root: str + :keyword authentication: Required. The authentication method to use to access the artifact + source. + :paramtype authentication: ~azure.mgmt.deploymentmanager.models.Authentication + """ super(ArtifactSourceProperties, self).__init__(**kwargs) self.source_type = source_type self.artifact_root = artifact_root @@ -292,18 +343,17 @@ class ArtifactSourcePropertiesAutoGenerated(ArtifactSourceProperties): All required parameters must be populated in order to send to Azure. - :param source_type: Required. The type of artifact source used. - :type source_type: str - :param artifact_root: The path from the location that the 'authentication' property [say, a SAS + :ivar source_type: Required. The type of artifact source used. + :vartype source_type: str + :ivar artifact_root: The path from the location that the 'authentication' property [say, a SAS URI to the blob container] refers to, to the location of the artifacts. This can be used to differentiate different versions of the artifacts. Or, different types of artifacts like binaries or templates. The location referenced by the authentication property concatenated with this optional artifactRoot path forms the artifact source location where the artifacts are expected to be found. - :type artifact_root: str - :param authentication: Required. The authentication method to use to access the artifact - source. - :type authentication: ~azure.mgmt.deploymentmanager.models.Authentication + :vartype artifact_root: str + :ivar authentication: Required. The authentication method to use to access the artifact source. + :vartype authentication: ~azure.mgmt.deploymentmanager.models.Authentication """ _validation = { @@ -321,10 +371,24 @@ def __init__( self, *, source_type: str, - authentication: "Authentication", + authentication: "_models.Authentication", artifact_root: Optional[str] = None, **kwargs ): + """ + :keyword source_type: Required. The type of artifact source used. + :paramtype source_type: str + :keyword artifact_root: The path from the location that the 'authentication' property [say, a + SAS URI to the blob container] refers to, to the location of the artifacts. This can be used to + differentiate different versions of the artifacts. Or, different types of artifacts like + binaries or templates. The location referenced by the authentication property concatenated with + this optional artifactRoot path forms the artifact source location where the artifacts are + expected to be found. + :paramtype artifact_root: str + :keyword authentication: Required. The authentication method to use to access the artifact + source. + :paramtype authentication: ~azure.mgmt.deploymentmanager.models.Authentication + """ super(ArtifactSourcePropertiesAutoGenerated, self).__init__(source_type=source_type, artifact_root=artifact_root, authentication=authentication, **kwargs) @@ -336,8 +400,8 @@ class Authentication(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. The authentication type.Constant filled by server. - :type type: str + :ivar type: Required. The authentication type.Constant filled by server. + :vartype type: str """ _validation = { @@ -356,6 +420,8 @@ def __init__( self, **kwargs ): + """ + """ super(Authentication, self).__init__(**kwargs) self.type = None # type: Optional[str] @@ -369,10 +435,10 @@ class CloudErrorBody(msrest.serialization.Model): :vartype code: str :ivar message: Descriptive error information. :vartype message: str - :param target: Error target. - :type target: str - :param details: More detailed error information. - :type details: list[~azure.mgmt.deploymentmanager.models.CloudErrorBody] + :ivar target: Error target. + :vartype target: str + :ivar details: More detailed error information. + :vartype details: list[~azure.mgmt.deploymentmanager.models.CloudErrorBody] """ _validation = { @@ -391,9 +457,15 @@ def __init__( self, *, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): + """ + :keyword target: Error target. + :paramtype target: str + :keyword details: More detailed error information. + :paramtype details: list[~azure.mgmt.deploymentmanager.models.CloudErrorBody] + """ super(CloudErrorBody, self).__init__(**kwargs) self.code = None self.message = None @@ -409,19 +481,19 @@ class HealthCheckStepAttributes(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. The type of health check.Constant filled by server. - :type type: str - :param wait_duration: The duration in ISO 8601 format for which health check waits idly without + :ivar type: Required. The type of health check.Constant filled by server. + :vartype type: str + :ivar wait_duration: The duration in ISO 8601 format for which health check waits idly without any checks. - :type wait_duration: str - :param max_elastic_duration: The duration in ISO 8601 format for which the health check waits + :vartype wait_duration: str + :ivar max_elastic_duration: The duration in ISO 8601 format for which the health check waits for the resource to become healthy. Health check fails if it doesn't. Health check starts to enforce healthyStateDuration once resource becomes healthy. - :type max_elastic_duration: str - :param healthy_state_duration: Required. The duration in ISO 8601 format for which the resource + :vartype max_elastic_duration: str + :ivar healthy_state_duration: Required. The duration in ISO 8601 format for which the resource is expected to be continuously healthy. If maxElasticDuration is specified, healthy state duration is enforced after the detection of first healthy signal. - :type healthy_state_duration: str + :vartype healthy_state_duration: str """ _validation = { @@ -448,6 +520,19 @@ def __init__( max_elastic_duration: Optional[str] = None, **kwargs ): + """ + :keyword wait_duration: The duration in ISO 8601 format for which health check waits idly + without any checks. + :paramtype wait_duration: str + :keyword max_elastic_duration: The duration in ISO 8601 format for which the health check waits + for the resource to become healthy. Health check fails if it doesn't. Health check starts to + enforce healthyStateDuration once resource becomes healthy. + :paramtype max_elastic_duration: str + :keyword healthy_state_duration: Required. The duration in ISO 8601 format for which the + resource is expected to be continuously healthy. If maxElasticDuration is specified, healthy + state duration is enforced after the detection of first healthy signal. + :paramtype healthy_state_duration: str + """ super(HealthCheckStepAttributes, self).__init__(**kwargs) self.type = None # type: Optional[str] self.wait_duration = wait_duration @@ -463,9 +548,9 @@ class StepProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param step_type: Required. The type of step.Constant filled by server. Possible values - include: "Wait", "HealthCheck". - :type step_type: str or ~azure.mgmt.deploymentmanager.models.StepType + :ivar step_type: Required. The type of step.Constant filled by server. Known values are: + "Wait", "HealthCheck". + :vartype step_type: str or ~azure.mgmt.deploymentmanager.models.StepType """ _validation = { @@ -484,6 +569,8 @@ def __init__( self, **kwargs ): + """ + """ super(StepProperties, self).__init__(**kwargs) self.step_type = None # type: Optional[str] @@ -493,11 +580,11 @@ class HealthCheckStepProperties(StepProperties): All required parameters must be populated in order to send to Azure. - :param step_type: Required. The type of step.Constant filled by server. Possible values - include: "Wait", "HealthCheck". - :type step_type: str or ~azure.mgmt.deploymentmanager.models.StepType - :param attributes: Required. The health check step attributes. - :type attributes: ~azure.mgmt.deploymentmanager.models.HealthCheckStepAttributes + :ivar step_type: Required. The type of step.Constant filled by server. Known values are: + "Wait", "HealthCheck". + :vartype step_type: str or ~azure.mgmt.deploymentmanager.models.StepType + :ivar attributes: Required. The health check step attributes. + :vartype attributes: ~azure.mgmt.deploymentmanager.models.HealthCheckStepAttributes """ _validation = { @@ -513,9 +600,13 @@ class HealthCheckStepProperties(StepProperties): def __init__( self, *, - attributes: "HealthCheckStepAttributes", + attributes: "_models.HealthCheckStepAttributes", **kwargs ): + """ + :keyword attributes: Required. The health check step attributes. + :paramtype attributes: ~azure.mgmt.deploymentmanager.models.HealthCheckStepAttributes + """ super(HealthCheckStepProperties, self).__init__(**kwargs) self.step_type = 'HealthCheck' # type: str self.attributes = attributes @@ -526,10 +617,10 @@ class Identity(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. The identity type. - :type type: str - :param identity_ids: Required. The list of identities. - :type identity_ids: list[str] + :ivar type: Required. The identity type. + :vartype type: str + :ivar identity_ids: Required. The list of identities. + :vartype identity_ids: list[str] """ _validation = { @@ -549,6 +640,12 @@ def __init__( identity_ids: List[str], **kwargs ): + """ + :keyword type: Required. The identity type. + :paramtype type: str + :keyword identity_ids: Required. The list of identities. + :paramtype identity_ids: list[str] + """ super(Identity, self).__init__(**kwargs) self.type = type self.identity_ids = identity_ids @@ -579,6 +676,8 @@ def __init__( self, **kwargs ): + """ + """ super(Message, self).__init__(**kwargs) self.time_stamp = None self.message = None @@ -587,14 +686,14 @@ def __init__( class Operation(msrest.serialization.Model): """Represents an operation that can be performed on the service. - :param name: The name of the operation. - :type name: str - :param display: The display name of the operation. - :type display: ~azure.mgmt.deploymentmanager.models.OperationDetail - :param origin: The origin of the operation. - :type origin: str - :param properties: The properties of the operation. - :type properties: any + :ivar name: The name of the operation. + :vartype name: str + :ivar display: The display name of the operation. + :vartype display: ~azure.mgmt.deploymentmanager.models.OperationDetail + :ivar origin: The origin of the operation. + :vartype origin: str + :ivar properties: The properties of the operation. + :vartype properties: any """ _attribute_map = { @@ -608,11 +707,21 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDetail"] = None, + display: Optional["_models.OperationDetail"] = None, origin: Optional[str] = None, properties: Optional[Any] = None, **kwargs ): + """ + :keyword name: The name of the operation. + :paramtype name: str + :keyword display: The display name of the operation. + :paramtype display: ~azure.mgmt.deploymentmanager.models.OperationDetail + :keyword origin: The origin of the operation. + :paramtype origin: str + :keyword properties: The properties of the operation. + :paramtype properties: any + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -623,14 +732,14 @@ def __init__( class OperationDetail(msrest.serialization.Model): """The detail about an operation. - :param provider: The name of the provider that supports the operation. - :type provider: str - :param resource: The resource type on which this operation can be performed. - :type resource: str - :param operation: The name of the operation. - :type operation: str - :param description: The description of the operation. - :type description: str + :ivar provider: The name of the provider that supports the operation. + :vartype provider: str + :ivar resource: The resource type on which this operation can be performed. + :vartype resource: str + :ivar operation: The name of the operation. + :vartype operation: str + :ivar description: The description of the operation. + :vartype description: str """ _attribute_map = { @@ -649,6 +758,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: The name of the provider that supports the operation. + :paramtype provider: str + :keyword resource: The resource type on which this operation can be performed. + :paramtype resource: str + :keyword operation: The name of the operation. + :paramtype operation: str + :keyword description: The description of the operation. + :paramtype description: str + """ super(OperationDetail, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -659,8 +778,8 @@ def __init__( class OperationsList(msrest.serialization.Model): """The operations response. - :param value: The list of supported operations. - :type value: ~azure.mgmt.deploymentmanager.models.Operation + :ivar value: The list of supported operations. + :vartype value: ~azure.mgmt.deploymentmanager.models.Operation """ _attribute_map = { @@ -670,9 +789,13 @@ class OperationsList(msrest.serialization.Model): def __init__( self, *, - value: Optional["Operation"] = None, + value: Optional["_models.Operation"] = None, **kwargs ): + """ + :keyword value: The list of supported operations. + :paramtype value: ~azure.mgmt.deploymentmanager.models.Operation + """ super(OperationsList, self).__init__(**kwargs) self.value = value @@ -682,8 +805,8 @@ class PrePostStep(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param step_id: Required. The resource Id of the step to be run. - :type step_id: str + :ivar step_id: Required. The resource Id of the step to be run. + :vartype step_id: str """ _validation = { @@ -700,6 +823,10 @@ def __init__( step_id: str, **kwargs ): + """ + :keyword step_id: Required. The resource Id of the step to be run. + :paramtype step_id: str + """ super(PrePostStep, self).__init__(**kwargs) self.step_id = step_id @@ -709,15 +836,15 @@ class ResourceOperation(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param resource_name: Name of the resource as specified in the artifacts. For ARM resources, + :ivar resource_name: Name of the resource as specified in the artifacts. For ARM resources, this is the name of the resource specified in the template. - :type resource_name: str + :vartype resource_name: str :ivar operation_id: Unique identifier of the operation. For ARM resources, this is the operationId obtained from ARM service. :vartype operation_id: str - :param resource_type: Type of the resource as specified in the artifacts. For ARM resources, + :ivar resource_type: Type of the resource as specified in the artifacts. For ARM resources, this is the type of the resource specified in the template. - :type resource_type: str + :vartype resource_type: str :ivar provisioning_state: State of the resource deployment. For ARM resources, this is the current provisioning state of the resource. :vartype provisioning_state: str @@ -750,6 +877,14 @@ def __init__( resource_type: Optional[str] = None, **kwargs ): + """ + :keyword resource_name: Name of the resource as specified in the artifacts. For ARM resources, + this is the name of the resource specified in the template. + :paramtype resource_name: str + :keyword resource_type: Type of the resource as specified in the artifacts. For ARM resources, + this is the type of the resource specified in the template. + :paramtype resource_type: str + """ super(ResourceOperation, self).__init__(**kwargs) self.resource_name = resource_name self.operation_id = None @@ -764,13 +899,13 @@ class RestHealthCheck(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. A unique name for this check. - :type name: str - :param request: Required. The request to the health provider. - :type request: ~azure.mgmt.deploymentmanager.models.RestRequest - :param response: The expected response from the health provider. If no expected response is + :ivar name: Required. A unique name for this check. + :vartype name: str + :ivar request: Required. The request to the health provider. + :vartype request: ~azure.mgmt.deploymentmanager.models.RestRequest + :ivar response: The expected response from the health provider. If no expected response is provided, the default is to expect the received response to have an HTTP status code of 200 OK. - :type response: ~azure.mgmt.deploymentmanager.models.RestResponse + :vartype response: ~azure.mgmt.deploymentmanager.models.RestResponse """ _validation = { @@ -788,10 +923,19 @@ def __init__( self, *, name: str, - request: "RestRequest", - response: Optional["RestResponse"] = None, + request: "_models.RestRequest", + response: Optional["_models.RestResponse"] = None, **kwargs ): + """ + :keyword name: Required. A unique name for this check. + :paramtype name: str + :keyword request: Required. The request to the health provider. + :paramtype request: ~azure.mgmt.deploymentmanager.models.RestRequest + :keyword response: The expected response from the health provider. If no expected response is + provided, the default is to expect the received response to have an HTTP status code of 200 OK. + :paramtype response: ~azure.mgmt.deploymentmanager.models.RestResponse + """ super(RestHealthCheck, self).__init__(**kwargs) self.name = name self.request = request @@ -803,21 +947,21 @@ class RestHealthCheckStepAttributes(HealthCheckStepAttributes): All required parameters must be populated in order to send to Azure. - :param type: Required. The type of health check.Constant filled by server. - :type type: str - :param wait_duration: The duration in ISO 8601 format for which health check waits idly without + :ivar type: Required. The type of health check.Constant filled by server. + :vartype type: str + :ivar wait_duration: The duration in ISO 8601 format for which health check waits idly without any checks. - :type wait_duration: str - :param max_elastic_duration: The duration in ISO 8601 format for which the health check waits + :vartype wait_duration: str + :ivar max_elastic_duration: The duration in ISO 8601 format for which the health check waits for the resource to become healthy. Health check fails if it doesn't. Health check starts to enforce healthyStateDuration once resource becomes healthy. - :type max_elastic_duration: str - :param healthy_state_duration: Required. The duration in ISO 8601 format for which the resource + :vartype max_elastic_duration: str + :ivar healthy_state_duration: Required. The duration in ISO 8601 format for which the resource is expected to be continuously healthy. If maxElasticDuration is specified, healthy state duration is enforced after the detection of first healthy signal. - :type healthy_state_duration: str - :param health_checks: The list of checks that form the health check step. - :type health_checks: list[~azure.mgmt.deploymentmanager.models.RestHealthCheck] + :vartype healthy_state_duration: str + :ivar health_checks: The list of checks that form the health check step. + :vartype health_checks: list[~azure.mgmt.deploymentmanager.models.RestHealthCheck] """ _validation = { @@ -839,9 +983,24 @@ def __init__( healthy_state_duration: str, wait_duration: Optional[str] = None, max_elastic_duration: Optional[str] = None, - health_checks: Optional[List["RestHealthCheck"]] = None, + health_checks: Optional[List["_models.RestHealthCheck"]] = None, **kwargs ): + """ + :keyword wait_duration: The duration in ISO 8601 format for which health check waits idly + without any checks. + :paramtype wait_duration: str + :keyword max_elastic_duration: The duration in ISO 8601 format for which the health check waits + for the resource to become healthy. Health check fails if it doesn't. Health check starts to + enforce healthyStateDuration once resource becomes healthy. + :paramtype max_elastic_duration: str + :keyword healthy_state_duration: Required. The duration in ISO 8601 format for which the + resource is expected to be continuously healthy. If maxElasticDuration is specified, healthy + state duration is enforced after the detection of first healthy signal. + :paramtype healthy_state_duration: str + :keyword health_checks: The list of checks that form the health check step. + :paramtype health_checks: list[~azure.mgmt.deploymentmanager.models.RestHealthCheck] + """ super(RestHealthCheckStepAttributes, self).__init__(wait_duration=wait_duration, max_elastic_duration=max_elastic_duration, healthy_state_duration=healthy_state_duration, **kwargs) self.type = 'REST' # type: str self.health_checks = health_checks @@ -852,14 +1011,14 @@ class RestRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param method: Required. The HTTP method to use for the request. Possible values include: - "GET", "POST". - :type method: str or ~azure.mgmt.deploymentmanager.models.RestRequestMethod - :param uri: Required. The HTTP URI to use for the request. - :type uri: str - :param authentication: Required. The authentication information required in the request to the + :ivar method: Required. The HTTP method to use for the request. Known values are: "GET", + "POST". + :vartype method: str or ~azure.mgmt.deploymentmanager.models.RestRequestMethod + :ivar uri: Required. The HTTP URI to use for the request. + :vartype uri: str + :ivar authentication: Required. The authentication information required in the request to the health provider. - :type authentication: ~azure.mgmt.deploymentmanager.models.RestRequestAuthentication + :vartype authentication: ~azure.mgmt.deploymentmanager.models.RestRequestAuthentication """ _validation = { @@ -877,11 +1036,21 @@ class RestRequest(msrest.serialization.Model): def __init__( self, *, - method: Union[str, "RestRequestMethod"], + method: Union[str, "_models.RestRequestMethod"], uri: str, - authentication: "RestRequestAuthentication", + authentication: "_models.RestRequestAuthentication", **kwargs ): + """ + :keyword method: Required. The HTTP method to use for the request. Known values are: "GET", + "POST". + :paramtype method: str or ~azure.mgmt.deploymentmanager.models.RestRequestMethod + :keyword uri: Required. The HTTP URI to use for the request. + :paramtype uri: str + :keyword authentication: Required. The authentication information required in the request to + the health provider. + :paramtype authentication: ~azure.mgmt.deploymentmanager.models.RestRequestAuthentication + """ super(RestRequest, self).__init__(**kwargs) self.method = method self.uri = uri @@ -891,12 +1060,12 @@ def __init__( class RestResponse(msrest.serialization.Model): """The properties that make up the expected REST response. - :param success_status_codes: The HTTP status codes expected in a successful health check + :ivar success_status_codes: The HTTP status codes expected in a successful health check response. The response is expected to match one of the given status codes. If no expected status codes are provided, default expected status code is 200 OK. - :type success_status_codes: list[str] - :param regex: The regular expressions to match the response content with. - :type regex: ~azure.mgmt.deploymentmanager.models.RestResponseRegex + :vartype success_status_codes: list[str] + :ivar regex: The regular expressions to match the response content with. + :vartype regex: ~azure.mgmt.deploymentmanager.models.RestResponseRegex """ _attribute_map = { @@ -908,9 +1077,17 @@ def __init__( self, *, success_status_codes: Optional[List[str]] = None, - regex: Optional["RestResponseRegex"] = None, + regex: Optional["_models.RestResponseRegex"] = None, **kwargs ): + """ + :keyword success_status_codes: The HTTP status codes expected in a successful health check + response. The response is expected to match one of the given status codes. If no expected + status codes are provided, default expected status code is 200 OK. + :paramtype success_status_codes: list[str] + :keyword regex: The regular expressions to match the response content with. + :paramtype regex: ~azure.mgmt.deploymentmanager.models.RestResponseRegex + """ super(RestResponse, self).__init__(**kwargs) self.success_status_codes = success_status_codes self.regex = regex @@ -919,11 +1096,11 @@ def __init__( class RestResponseRegex(msrest.serialization.Model): """The regular expressions to match the response content with. - :param matches: The list of regular expressions. - :type matches: list[str] - :param match_quantifier: Indicates whether any or all of the expressions should match with the - response content. Possible values include: "All", "Any". - :type match_quantifier: str or ~azure.mgmt.deploymentmanager.models.RestMatchQuantifier + :ivar matches: The list of regular expressions. + :vartype matches: list[str] + :ivar match_quantifier: Indicates whether any or all of the expressions should match with the + response content. Known values are: "All", "Any". + :vartype match_quantifier: str or ~azure.mgmt.deploymentmanager.models.RestMatchQuantifier """ _attribute_map = { @@ -935,9 +1112,16 @@ def __init__( self, *, matches: Optional[List[str]] = None, - match_quantifier: Optional[Union[str, "RestMatchQuantifier"]] = None, + match_quantifier: Optional[Union[str, "_models.RestMatchQuantifier"]] = None, **kwargs ): + """ + :keyword matches: The list of regular expressions. + :paramtype matches: list[str] + :keyword match_quantifier: Indicates whether any or all of the expressions should match with + the response content. Known values are: "All", "Any". + :paramtype match_quantifier: str or ~azure.mgmt.deploymentmanager.models.RestMatchQuantifier + """ super(RestResponseRegex, self).__init__(**kwargs) self.matches = matches self.match_quantifier = match_quantifier @@ -958,22 +1142,22 @@ class Rollout(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param identity: Identity for the resource. - :type identity: ~azure.mgmt.deploymentmanager.models.Identity - :param build_version: The version of the build being deployed. - :type build_version: str - :param artifact_source_id: The reference to the artifact source resource Id where the payload - is located. - :type artifact_source_id: str - :param target_service_topology_id: The resource Id of the service topology from which service + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar identity: Identity for the resource. + :vartype identity: ~azure.mgmt.deploymentmanager.models.Identity + :ivar build_version: The version of the build being deployed. + :vartype build_version: str + :ivar artifact_source_id: The reference to the artifact source resource Id where the payload is + located. + :vartype artifact_source_id: str + :ivar target_service_topology_id: The resource Id of the service topology from which service units are being referenced in step groups to be deployed. - :type target_service_topology_id: str - :param step_groups: The list of step groups that define the orchestration. - :type step_groups: list[~azure.mgmt.deploymentmanager.models.StepGroup] + :vartype target_service_topology_id: str + :ivar step_groups: The list of step groups that define the orchestration. + :vartype step_groups: list[~azure.mgmt.deploymentmanager.models.StepGroup] :ivar status: The current status of the rollout. :vartype status: str :ivar total_retry_attempts: The cardinal count of total number of retries performed on the @@ -1018,13 +1202,31 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, + identity: Optional["_models.Identity"] = None, build_version: Optional[str] = None, artifact_source_id: Optional[str] = None, target_service_topology_id: Optional[str] = None, - step_groups: Optional[List["StepGroup"]] = None, + step_groups: Optional[List["_models.StepGroup"]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword identity: Identity for the resource. + :paramtype identity: ~azure.mgmt.deploymentmanager.models.Identity + :keyword build_version: The version of the build being deployed. + :paramtype build_version: str + :keyword artifact_source_id: The reference to the artifact source resource Id where the payload + is located. + :paramtype artifact_source_id: str + :keyword target_service_topology_id: The resource Id of the service topology from which service + units are being referenced in step groups to be deployed. + :paramtype target_service_topology_id: str + :keyword step_groups: The list of step groups that define the orchestration. + :paramtype step_groups: list[~azure.mgmt.deploymentmanager.models.StepGroup] + """ super(Rollout, self).__init__(tags=tags, location=location, **kwargs) self.identity = identity self.build_version = build_version @@ -1042,9 +1244,9 @@ class RolloutIdentityAuthentication(RestRequestAuthentication): All required parameters must be populated in order to send to Azure. - :param type: Required. The authentication type.Constant filled by server. Possible values - include: "ApiKey", "RolloutIdentity". - :type type: str or ~azure.mgmt.deploymentmanager.models.RestAuthType + :ivar type: Required. The authentication type.Constant filled by server. Known values are: + "ApiKey", "RolloutIdentity". + :vartype type: str or ~azure.mgmt.deploymentmanager.models.RestAuthType """ _validation = { @@ -1059,6 +1261,8 @@ def __init__( self, **kwargs ): + """ + """ super(RolloutIdentityAuthentication, self).__init__(**kwargs) self.type = 'RolloutIdentity' # type: str @@ -1104,6 +1308,8 @@ def __init__( self, **kwargs ): + """ + """ super(RolloutOperationInfo, self).__init__(**kwargs) self.retry_attempt = None self.skip_succeeded_on_retry = None @@ -1146,6 +1352,8 @@ def __init__( self, **kwargs ): + """ + """ super(RolloutProperties, self).__init__(**kwargs) self.status = None self.total_retry_attempts = None @@ -1158,16 +1366,16 @@ class RolloutRequestProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param build_version: Required. The version of the build being deployed. - :type build_version: str - :param artifact_source_id: The reference to the artifact source resource Id where the payload - is located. - :type artifact_source_id: str - :param target_service_topology_id: Required. The resource Id of the service topology from which + :ivar build_version: Required. The version of the build being deployed. + :vartype build_version: str + :ivar artifact_source_id: The reference to the artifact source resource Id where the payload is + located. + :vartype artifact_source_id: str + :ivar target_service_topology_id: Required. The resource Id of the service topology from which service units are being referenced in step groups to be deployed. - :type target_service_topology_id: str - :param step_groups: Required. The list of step groups that define the orchestration. - :type step_groups: list[~azure.mgmt.deploymentmanager.models.StepGroup] + :vartype target_service_topology_id: str + :ivar step_groups: Required. The list of step groups that define the orchestration. + :vartype step_groups: list[~azure.mgmt.deploymentmanager.models.StepGroup] """ _validation = { @@ -1188,10 +1396,22 @@ def __init__( *, build_version: str, target_service_topology_id: str, - step_groups: List["StepGroup"], + step_groups: List["_models.StepGroup"], artifact_source_id: Optional[str] = None, **kwargs ): + """ + :keyword build_version: Required. The version of the build being deployed. + :paramtype build_version: str + :keyword artifact_source_id: The reference to the artifact source resource Id where the payload + is located. + :paramtype artifact_source_id: str + :keyword target_service_topology_id: Required. The resource Id of the service topology from + which service units are being referenced in step groups to be deployed. + :paramtype target_service_topology_id: str + :keyword step_groups: Required. The list of step groups that define the orchestration. + :paramtype step_groups: list[~azure.mgmt.deploymentmanager.models.StepGroup] + """ super(RolloutRequestProperties, self).__init__(**kwargs) self.build_version = build_version self.artifact_source_id = artifact_source_id @@ -1215,16 +1435,16 @@ class RolloutPropertiesAutoGenerated(RolloutRequestProperties, RolloutProperties :vartype operation_info: ~azure.mgmt.deploymentmanager.models.RolloutOperationInfo :ivar services: The detailed information on the services being deployed. :vartype services: list[~azure.mgmt.deploymentmanager.models.Service] - :param build_version: Required. The version of the build being deployed. - :type build_version: str - :param artifact_source_id: The reference to the artifact source resource Id where the payload - is located. - :type artifact_source_id: str - :param target_service_topology_id: Required. The resource Id of the service topology from which + :ivar build_version: Required. The version of the build being deployed. + :vartype build_version: str + :ivar artifact_source_id: The reference to the artifact source resource Id where the payload is + located. + :vartype artifact_source_id: str + :ivar target_service_topology_id: Required. The resource Id of the service topology from which service units are being referenced in step groups to be deployed. - :type target_service_topology_id: str - :param step_groups: Required. The list of step groups that define the orchestration. - :type step_groups: list[~azure.mgmt.deploymentmanager.models.StepGroup] + :vartype target_service_topology_id: str + :ivar step_groups: Required. The list of step groups that define the orchestration. + :vartype step_groups: list[~azure.mgmt.deploymentmanager.models.StepGroup] """ _validation = { @@ -1253,10 +1473,22 @@ def __init__( *, build_version: str, target_service_topology_id: str, - step_groups: List["StepGroup"], + step_groups: List["_models.StepGroup"], artifact_source_id: Optional[str] = None, **kwargs ): + """ + :keyword build_version: Required. The version of the build being deployed. + :paramtype build_version: str + :keyword artifact_source_id: The reference to the artifact source resource Id where the payload + is located. + :paramtype artifact_source_id: str + :keyword target_service_topology_id: Required. The resource Id of the service topology from + which service units are being referenced in step groups to be deployed. + :paramtype target_service_topology_id: str + :keyword step_groups: Required. The list of step groups that define the orchestration. + :paramtype step_groups: list[~azure.mgmt.deploymentmanager.models.StepGroup] + """ super(RolloutPropertiesAutoGenerated, self).__init__(build_version=build_version, artifact_source_id=artifact_source_id, target_service_topology_id=target_service_topology_id, step_groups=step_groups, **kwargs) self.status = None self.total_retry_attempts = None @@ -1283,22 +1515,22 @@ class RolloutRequest(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param identity: Required. Identity for the resource. - :type identity: ~azure.mgmt.deploymentmanager.models.Identity - :param build_version: Required. The version of the build being deployed. - :type build_version: str - :param artifact_source_id: The reference to the artifact source resource Id where the payload - is located. - :type artifact_source_id: str - :param target_service_topology_id: Required. The resource Id of the service topology from which + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar identity: Required. Identity for the resource. + :vartype identity: ~azure.mgmt.deploymentmanager.models.Identity + :ivar build_version: Required. The version of the build being deployed. + :vartype build_version: str + :ivar artifact_source_id: The reference to the artifact source resource Id where the payload is + located. + :vartype artifact_source_id: str + :ivar target_service_topology_id: Required. The resource Id of the service topology from which service units are being referenced in step groups to be deployed. - :type target_service_topology_id: str - :param step_groups: Required. The list of step groups that define the orchestration. - :type step_groups: list[~azure.mgmt.deploymentmanager.models.StepGroup] + :vartype target_service_topology_id: str + :ivar step_groups: Required. The list of step groups that define the orchestration. + :vartype step_groups: list[~azure.mgmt.deploymentmanager.models.StepGroup] """ _validation = { @@ -1329,14 +1561,32 @@ def __init__( self, *, location: str, - identity: "Identity", + identity: "_models.Identity", build_version: str, target_service_topology_id: str, - step_groups: List["StepGroup"], + step_groups: List["_models.StepGroup"], tags: Optional[Dict[str, str]] = None, artifact_source_id: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword identity: Required. Identity for the resource. + :paramtype identity: ~azure.mgmt.deploymentmanager.models.Identity + :keyword build_version: Required. The version of the build being deployed. + :paramtype build_version: str + :keyword artifact_source_id: The reference to the artifact source resource Id where the payload + is located. + :paramtype artifact_source_id: str + :keyword target_service_topology_id: Required. The resource Id of the service topology from + which service units are being referenced in step groups to be deployed. + :paramtype target_service_topology_id: str + :keyword step_groups: Required. The list of step groups that define the orchestration. + :paramtype step_groups: list[~azure.mgmt.deploymentmanager.models.StepGroup] + """ super(RolloutRequest, self).__init__(tags=tags, location=location, **kwargs) self.identity = identity self.build_version = build_version @@ -1352,12 +1602,12 @@ class RolloutStep(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the step. - :type name: str + :ivar name: Required. Name of the step. + :vartype name: str :ivar status: Current state of the step. :vartype status: str - :param step_group: The step group the current step is part of. - :type step_group: str + :ivar step_group: The step group the current step is part of. + :vartype step_group: str :ivar operation_info: Detailed information of specific action execution. :vartype operation_info: ~azure.mgmt.deploymentmanager.models.StepOperationInfo :ivar resource_operations: Set of resource operations that were performed, if any, on an Azure @@ -1391,6 +1641,12 @@ def __init__( step_group: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. Name of the step. + :paramtype name: str + :keyword step_group: The step group the current step is part of. + :paramtype step_group: str + """ super(RolloutStep, self).__init__(**kwargs) self.name = name self.status = None @@ -1405,11 +1661,11 @@ class SasAuthentication(Authentication): All required parameters must be populated in order to send to Azure. - :param type: Required. The authentication type.Constant filled by server. - :type type: str - :param sas_uri: The SAS URI to the Azure Storage blob container. Any offset from the root of - the container to where the artifacts are located can be defined in the artifactRoot. - :type sas_uri: str + :ivar type: Required. The authentication type.Constant filled by server. + :vartype type: str + :ivar sas_uri: The SAS URI to the Azure Storage blob container. Any offset from the root of the + container to where the artifacts are located can be defined in the artifactRoot. + :vartype sas_uri: str """ _validation = { @@ -1427,6 +1683,11 @@ def __init__( sas_uri: Optional[str] = None, **kwargs ): + """ + :keyword sas_uri: The SAS URI to the Azure Storage blob container. Any offset from the root of + the container to where the artifacts are located can be defined in the artifactRoot. + :paramtype sas_uri: str + """ super(SasAuthentication, self).__init__(**kwargs) self.type = 'Sas' # type: str self.sas_uri = sas_uri @@ -1437,12 +1698,12 @@ class ServiceProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param target_location: Required. The Azure location to which the resources in the service + :ivar target_location: Required. The Azure location to which the resources in the service belong to or should be deployed to. - :type target_location: str - :param target_subscription_id: Required. The subscription to which the resources in the service + :vartype target_location: str + :ivar target_subscription_id: Required. The subscription to which the resources in the service belong to or should be deployed to. - :type target_subscription_id: str + :vartype target_subscription_id: str """ _validation = { @@ -1462,6 +1723,14 @@ def __init__( target_subscription_id: str, **kwargs ): + """ + :keyword target_location: Required. The Azure location to which the resources in the service + belong to or should be deployed to. + :paramtype target_location: str + :keyword target_subscription_id: Required. The subscription to which the resources in the + service belong to or should be deployed to. + :paramtype target_subscription_id: str + """ super(ServiceProperties, self).__init__(**kwargs) self.target_location = target_location self.target_subscription_id = target_subscription_id @@ -1472,16 +1741,16 @@ class Service(ServiceProperties): All required parameters must be populated in order to send to Azure. - :param target_location: Required. The Azure location to which the resources in the service + :ivar target_location: Required. The Azure location to which the resources in the service belong to or should be deployed to. - :type target_location: str - :param target_subscription_id: Required. The subscription to which the resources in the service + :vartype target_location: str + :ivar target_subscription_id: Required. The subscription to which the resources in the service belong to or should be deployed to. - :type target_subscription_id: str - :param name: Name of the service. - :type name: str - :param service_units: The detailed information about the units that make up the service. - :type service_units: list[~azure.mgmt.deploymentmanager.models.ServiceUnit] + :vartype target_subscription_id: str + :ivar name: Name of the service. + :vartype name: str + :ivar service_units: The detailed information about the units that make up the service. + :vartype service_units: list[~azure.mgmt.deploymentmanager.models.ServiceUnit] """ _validation = { @@ -1502,9 +1771,21 @@ def __init__( target_location: str, target_subscription_id: str, name: Optional[str] = None, - service_units: Optional[List["ServiceUnit"]] = None, + service_units: Optional[List["_models.ServiceUnit"]] = None, **kwargs ): + """ + :keyword target_location: Required. The Azure location to which the resources in the service + belong to or should be deployed to. + :paramtype target_location: str + :keyword target_subscription_id: Required. The subscription to which the resources in the + service belong to or should be deployed to. + :paramtype target_subscription_id: str + :keyword name: Name of the service. + :paramtype name: str + :keyword service_units: The detailed information about the units that make up the service. + :paramtype service_units: list[~azure.mgmt.deploymentmanager.models.ServiceUnit] + """ super(Service, self).__init__(target_location=target_location, target_subscription_id=target_subscription_id, **kwargs) self.name = name self.service_units = service_units @@ -1525,16 +1806,16 @@ class ServiceResource(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param target_location: Required. The Azure location to which the resources in the service + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar target_location: Required. The Azure location to which the resources in the service belong to or should be deployed to. - :type target_location: str - :param target_subscription_id: Required. The subscription to which the resources in the service + :vartype target_location: str + :ivar target_subscription_id: Required. The subscription to which the resources in the service belong to or should be deployed to. - :type target_subscription_id: str + :vartype target_subscription_id: str """ _validation = { @@ -1565,6 +1846,18 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword target_location: Required. The Azure location to which the resources in the service + belong to or should be deployed to. + :paramtype target_location: str + :keyword target_subscription_id: Required. The subscription to which the resources in the + service belong to or should be deployed to. + :paramtype target_subscription_id: str + """ super(ServiceResource, self).__init__(tags=tags, location=location, **kwargs) self.target_location = target_location self.target_subscription_id = target_subscription_id @@ -1575,12 +1868,12 @@ class ServiceResourceProperties(ServiceProperties): All required parameters must be populated in order to send to Azure. - :param target_location: Required. The Azure location to which the resources in the service + :ivar target_location: Required. The Azure location to which the resources in the service belong to or should be deployed to. - :type target_location: str - :param target_subscription_id: Required. The subscription to which the resources in the service + :vartype target_location: str + :ivar target_subscription_id: Required. The subscription to which the resources in the service belong to or should be deployed to. - :type target_subscription_id: str + :vartype target_subscription_id: str """ _validation = { @@ -1600,15 +1893,23 @@ def __init__( target_subscription_id: str, **kwargs ): + """ + :keyword target_location: Required. The Azure location to which the resources in the service + belong to or should be deployed to. + :paramtype target_location: str + :keyword target_subscription_id: Required. The subscription to which the resources in the + service belong to or should be deployed to. + :paramtype target_subscription_id: str + """ super(ServiceResourceProperties, self).__init__(target_location=target_location, target_subscription_id=target_subscription_id, **kwargs) class ServiceTopologyProperties(msrest.serialization.Model): """The properties of a service topology. - :param artifact_source_id: The resource Id of the artifact source that contains the artifacts + :ivar artifact_source_id: The resource Id of the artifact source that contains the artifacts that can be referenced in the service units. - :type artifact_source_id: str + :vartype artifact_source_id: str """ _attribute_map = { @@ -1621,6 +1922,11 @@ def __init__( artifact_source_id: Optional[str] = None, **kwargs ): + """ + :keyword artifact_source_id: The resource Id of the artifact source that contains the artifacts + that can be referenced in the service units. + :paramtype artifact_source_id: str + """ super(ServiceTopologyProperties, self).__init__(**kwargs) self.artifact_source_id = artifact_source_id @@ -1640,13 +1946,13 @@ class ServiceTopologyResource(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param artifact_source_id: The resource Id of the artifact source that contains the artifacts + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar artifact_source_id: The resource Id of the artifact source that contains the artifacts that can be referenced in the service units. - :type artifact_source_id: str + :vartype artifact_source_id: str """ _validation = { @@ -1673,6 +1979,15 @@ def __init__( artifact_source_id: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword artifact_source_id: The resource Id of the artifact source that contains the artifacts + that can be referenced in the service units. + :paramtype artifact_source_id: str + """ super(ServiceTopologyResource, self).__init__(tags=tags, location=location, **kwargs) self.artifact_source_id = artifact_source_id @@ -1680,9 +1995,9 @@ def __init__( class ServiceTopologyResourceProperties(ServiceTopologyProperties): """The properties that define the service topology. - :param artifact_source_id: The resource Id of the artifact source that contains the artifacts + :ivar artifact_source_id: The resource Id of the artifact source that contains the artifacts that can be referenced in the service units. - :type artifact_source_id: str + :vartype artifact_source_id: str """ _attribute_map = { @@ -1695,6 +2010,11 @@ def __init__( artifact_source_id: Optional[str] = None, **kwargs ): + """ + :keyword artifact_source_id: The resource Id of the artifact source that contains the artifacts + that can be referenced in the service units. + :paramtype artifact_source_id: str + """ super(ServiceTopologyResourceProperties, self).__init__(artifact_source_id=artifact_source_id, **kwargs) @@ -1703,14 +2023,14 @@ class ServiceUnitProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param target_resource_group: Required. The Azure Resource Group to which the resources in the + :ivar target_resource_group: Required. The Azure Resource Group to which the resources in the service unit belong to or should be deployed to. - :type target_resource_group: str - :param deployment_mode: Required. Describes the type of ARM deployment to be performed on the - resource. Possible values include: "Incremental", "Complete". - :type deployment_mode: str or ~azure.mgmt.deploymentmanager.models.DeploymentMode - :param artifacts: The artifacts for the service unit. - :type artifacts: ~azure.mgmt.deploymentmanager.models.ServiceUnitArtifacts + :vartype target_resource_group: str + :ivar deployment_mode: Required. Describes the type of ARM deployment to be performed on the + resource. Known values are: "Incremental", "Complete". + :vartype deployment_mode: str or ~azure.mgmt.deploymentmanager.models.DeploymentMode + :ivar artifacts: The artifacts for the service unit. + :vartype artifacts: ~azure.mgmt.deploymentmanager.models.ServiceUnitArtifacts """ _validation = { @@ -1728,10 +2048,20 @@ def __init__( self, *, target_resource_group: str, - deployment_mode: Union[str, "DeploymentMode"], - artifacts: Optional["ServiceUnitArtifacts"] = None, + deployment_mode: Union[str, "_models.DeploymentMode"], + artifacts: Optional["_models.ServiceUnitArtifacts"] = None, **kwargs ): + """ + :keyword target_resource_group: Required. The Azure Resource Group to which the resources in + the service unit belong to or should be deployed to. + :paramtype target_resource_group: str + :keyword deployment_mode: Required. Describes the type of ARM deployment to be performed on the + resource. Known values are: "Incremental", "Complete". + :paramtype deployment_mode: str or ~azure.mgmt.deploymentmanager.models.DeploymentMode + :keyword artifacts: The artifacts for the service unit. + :paramtype artifacts: ~azure.mgmt.deploymentmanager.models.ServiceUnitArtifacts + """ super(ServiceUnitProperties, self).__init__(**kwargs) self.target_resource_group = target_resource_group self.deployment_mode = deployment_mode @@ -1743,18 +2073,18 @@ class ServiceUnit(ServiceUnitProperties): All required parameters must be populated in order to send to Azure. - :param target_resource_group: Required. The Azure Resource Group to which the resources in the + :ivar target_resource_group: Required. The Azure Resource Group to which the resources in the service unit belong to or should be deployed to. - :type target_resource_group: str - :param deployment_mode: Required. Describes the type of ARM deployment to be performed on the - resource. Possible values include: "Incremental", "Complete". - :type deployment_mode: str or ~azure.mgmt.deploymentmanager.models.DeploymentMode - :param artifacts: The artifacts for the service unit. - :type artifacts: ~azure.mgmt.deploymentmanager.models.ServiceUnitArtifacts - :param name: Name of the service unit. - :type name: str - :param steps: Detailed step information, if present. - :type steps: list[~azure.mgmt.deploymentmanager.models.RolloutStep] + :vartype target_resource_group: str + :ivar deployment_mode: Required. Describes the type of ARM deployment to be performed on the + resource. Known values are: "Incremental", "Complete". + :vartype deployment_mode: str or ~azure.mgmt.deploymentmanager.models.DeploymentMode + :ivar artifacts: The artifacts for the service unit. + :vartype artifacts: ~azure.mgmt.deploymentmanager.models.ServiceUnitArtifacts + :ivar name: Name of the service unit. + :vartype name: str + :ivar steps: Detailed step information, if present. + :vartype steps: list[~azure.mgmt.deploymentmanager.models.RolloutStep] """ _validation = { @@ -1774,12 +2104,26 @@ def __init__( self, *, target_resource_group: str, - deployment_mode: Union[str, "DeploymentMode"], - artifacts: Optional["ServiceUnitArtifacts"] = None, + deployment_mode: Union[str, "_models.DeploymentMode"], + artifacts: Optional["_models.ServiceUnitArtifacts"] = None, name: Optional[str] = None, - steps: Optional[List["RolloutStep"]] = None, + steps: Optional[List["_models.RolloutStep"]] = None, **kwargs ): + """ + :keyword target_resource_group: Required. The Azure Resource Group to which the resources in + the service unit belong to or should be deployed to. + :paramtype target_resource_group: str + :keyword deployment_mode: Required. Describes the type of ARM deployment to be performed on the + resource. Known values are: "Incremental", "Complete". + :paramtype deployment_mode: str or ~azure.mgmt.deploymentmanager.models.DeploymentMode + :keyword artifacts: The artifacts for the service unit. + :paramtype artifacts: ~azure.mgmt.deploymentmanager.models.ServiceUnitArtifacts + :keyword name: Name of the service unit. + :paramtype name: str + :keyword steps: Detailed step information, if present. + :paramtype steps: list[~azure.mgmt.deploymentmanager.models.RolloutStep] + """ super(ServiceUnit, self).__init__(target_resource_group=target_resource_group, deployment_mode=deployment_mode, artifacts=artifacts, **kwargs) self.name = name self.steps = steps @@ -1788,16 +2132,16 @@ def __init__( class ServiceUnitArtifacts(msrest.serialization.Model): """Defines the artifacts of a service unit. - :param template_uri: The full URI of the ARM template file with the SAS token. - :type template_uri: str - :param parameters_uri: The full URI of the ARM parameters file with the SAS token. - :type parameters_uri: str - :param template_artifact_source_relative_path: The path to the ARM template file relative to + :ivar template_uri: The full URI of the ARM template file with the SAS token. + :vartype template_uri: str + :ivar parameters_uri: The full URI of the ARM parameters file with the SAS token. + :vartype parameters_uri: str + :ivar template_artifact_source_relative_path: The path to the ARM template file relative to the + artifact source. + :vartype template_artifact_source_relative_path: str + :ivar parameters_artifact_source_relative_path: The path to the ARM parameters file relative to the artifact source. - :type template_artifact_source_relative_path: str - :param parameters_artifact_source_relative_path: The path to the ARM parameters file relative - to the artifact source. - :type parameters_artifact_source_relative_path: str + :vartype parameters_artifact_source_relative_path: str """ _attribute_map = { @@ -1816,6 +2160,18 @@ def __init__( parameters_artifact_source_relative_path: Optional[str] = None, **kwargs ): + """ + :keyword template_uri: The full URI of the ARM template file with the SAS token. + :paramtype template_uri: str + :keyword parameters_uri: The full URI of the ARM parameters file with the SAS token. + :paramtype parameters_uri: str + :keyword template_artifact_source_relative_path: The path to the ARM template file relative to + the artifact source. + :paramtype template_artifact_source_relative_path: str + :keyword parameters_artifact_source_relative_path: The path to the ARM parameters file relative + to the artifact source. + :paramtype parameters_artifact_source_relative_path: str + """ super(ServiceUnitArtifacts, self).__init__(**kwargs) self.template_uri = template_uri self.parameters_uri = parameters_uri @@ -1838,18 +2194,18 @@ class ServiceUnitResource(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param target_resource_group: Required. The Azure Resource Group to which the resources in the + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar target_resource_group: Required. The Azure Resource Group to which the resources in the service unit belong to or should be deployed to. - :type target_resource_group: str - :param deployment_mode: Required. Describes the type of ARM deployment to be performed on the - resource. Possible values include: "Incremental", "Complete". - :type deployment_mode: str or ~azure.mgmt.deploymentmanager.models.DeploymentMode - :param artifacts: The artifacts for the service unit. - :type artifacts: ~azure.mgmt.deploymentmanager.models.ServiceUnitArtifacts + :vartype target_resource_group: str + :ivar deployment_mode: Required. Describes the type of ARM deployment to be performed on the + resource. Known values are: "Incremental", "Complete". + :vartype deployment_mode: str or ~azure.mgmt.deploymentmanager.models.DeploymentMode + :ivar artifacts: The artifacts for the service unit. + :vartype artifacts: ~azure.mgmt.deploymentmanager.models.ServiceUnitArtifacts """ _validation = { @@ -1877,11 +2233,25 @@ def __init__( *, location: str, target_resource_group: str, - deployment_mode: Union[str, "DeploymentMode"], + deployment_mode: Union[str, "_models.DeploymentMode"], tags: Optional[Dict[str, str]] = None, - artifacts: Optional["ServiceUnitArtifacts"] = None, + artifacts: Optional["_models.ServiceUnitArtifacts"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword target_resource_group: Required. The Azure Resource Group to which the resources in + the service unit belong to or should be deployed to. + :paramtype target_resource_group: str + :keyword deployment_mode: Required. Describes the type of ARM deployment to be performed on the + resource. Known values are: "Incremental", "Complete". + :paramtype deployment_mode: str or ~azure.mgmt.deploymentmanager.models.DeploymentMode + :keyword artifacts: The artifacts for the service unit. + :paramtype artifacts: ~azure.mgmt.deploymentmanager.models.ServiceUnitArtifacts + """ super(ServiceUnitResource, self).__init__(tags=tags, location=location, **kwargs) self.target_resource_group = target_resource_group self.deployment_mode = deployment_mode @@ -1893,14 +2263,14 @@ class ServiceUnitResourceProperties(ServiceUnitProperties): All required parameters must be populated in order to send to Azure. - :param target_resource_group: Required. The Azure Resource Group to which the resources in the + :ivar target_resource_group: Required. The Azure Resource Group to which the resources in the service unit belong to or should be deployed to. - :type target_resource_group: str - :param deployment_mode: Required. Describes the type of ARM deployment to be performed on the - resource. Possible values include: "Incremental", "Complete". - :type deployment_mode: str or ~azure.mgmt.deploymentmanager.models.DeploymentMode - :param artifacts: The artifacts for the service unit. - :type artifacts: ~azure.mgmt.deploymentmanager.models.ServiceUnitArtifacts + :vartype target_resource_group: str + :ivar deployment_mode: Required. Describes the type of ARM deployment to be performed on the + resource. Known values are: "Incremental", "Complete". + :vartype deployment_mode: str or ~azure.mgmt.deploymentmanager.models.DeploymentMode + :ivar artifacts: The artifacts for the service unit. + :vartype artifacts: ~azure.mgmt.deploymentmanager.models.ServiceUnitArtifacts """ _validation = { @@ -1918,10 +2288,20 @@ def __init__( self, *, target_resource_group: str, - deployment_mode: Union[str, "DeploymentMode"], - artifacts: Optional["ServiceUnitArtifacts"] = None, + deployment_mode: Union[str, "_models.DeploymentMode"], + artifacts: Optional["_models.ServiceUnitArtifacts"] = None, **kwargs ): + """ + :keyword target_resource_group: Required. The Azure Resource Group to which the resources in + the service unit belong to or should be deployed to. + :paramtype target_resource_group: str + :keyword deployment_mode: Required. Describes the type of ARM deployment to be performed on the + resource. Known values are: "Incremental", "Complete". + :paramtype deployment_mode: str or ~azure.mgmt.deploymentmanager.models.DeploymentMode + :keyword artifacts: The artifacts for the service unit. + :paramtype artifacts: ~azure.mgmt.deploymentmanager.models.ServiceUnitArtifacts + """ super(ServiceUnitResourceProperties, self).__init__(target_resource_group=target_resource_group, deployment_mode=deployment_mode, artifacts=artifacts, **kwargs) @@ -1930,18 +2310,17 @@ class StepGroup(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the step group. - :type name: str - :param depends_on_step_groups: The list of step group names on which this step group depends - on. - :type depends_on_step_groups: list[str] - :param pre_deployment_steps: The list of steps to be run before deploying the target. - :type pre_deployment_steps: list[~azure.mgmt.deploymentmanager.models.PrePostStep] - :param deployment_target_id: Required. The resource Id of service unit to be deployed. The + :ivar name: Required. The name of the step group. + :vartype name: str + :ivar depends_on_step_groups: The list of step group names on which this step group depends on. + :vartype depends_on_step_groups: list[str] + :ivar pre_deployment_steps: The list of steps to be run before deploying the target. + :vartype pre_deployment_steps: list[~azure.mgmt.deploymentmanager.models.PrePostStep] + :ivar deployment_target_id: Required. The resource Id of service unit to be deployed. The service unit should be from the service topology referenced in targetServiceTopologyId. - :type deployment_target_id: str - :param post_deployment_steps: The list of steps to be run after deploying the target. - :type post_deployment_steps: list[~azure.mgmt.deploymentmanager.models.PrePostStep] + :vartype deployment_target_id: str + :ivar post_deployment_steps: The list of steps to be run after deploying the target. + :vartype post_deployment_steps: list[~azure.mgmt.deploymentmanager.models.PrePostStep] """ _validation = { @@ -1963,10 +2342,24 @@ def __init__( name: str, deployment_target_id: str, depends_on_step_groups: Optional[List[str]] = None, - pre_deployment_steps: Optional[List["PrePostStep"]] = None, - post_deployment_steps: Optional[List["PrePostStep"]] = None, + pre_deployment_steps: Optional[List["_models.PrePostStep"]] = None, + post_deployment_steps: Optional[List["_models.PrePostStep"]] = None, **kwargs ): + """ + :keyword name: Required. The name of the step group. + :paramtype name: str + :keyword depends_on_step_groups: The list of step group names on which this step group depends + on. + :paramtype depends_on_step_groups: list[str] + :keyword pre_deployment_steps: The list of steps to be run before deploying the target. + :paramtype pre_deployment_steps: list[~azure.mgmt.deploymentmanager.models.PrePostStep] + :keyword deployment_target_id: Required. The resource Id of service unit to be deployed. The + service unit should be from the service topology referenced in targetServiceTopologyId. + :paramtype deployment_target_id: str + :keyword post_deployment_steps: The list of steps to be run after deploying the target. + :paramtype post_deployment_steps: list[~azure.mgmt.deploymentmanager.models.PrePostStep] + """ super(StepGroup, self).__init__(**kwargs) self.name = name self.depends_on_step_groups = depends_on_step_groups @@ -1990,8 +2383,8 @@ class StepOperationInfo(msrest.serialization.Model): :vartype end_time: ~datetime.datetime :ivar last_updated_time: Last time in UTC this operation was updated. :vartype last_updated_time: ~datetime.datetime - :param error: The errors, if any, for the action. - :type error: ~azure.mgmt.deploymentmanager.models.CloudErrorBody + :ivar error: The errors, if any, for the action. + :vartype error: ~azure.mgmt.deploymentmanager.models.CloudErrorBody """ _validation = { @@ -2014,9 +2407,13 @@ class StepOperationInfo(msrest.serialization.Model): def __init__( self, *, - error: Optional["CloudErrorBody"] = None, + error: Optional["_models.CloudErrorBody"] = None, **kwargs ): + """ + :keyword error: The errors, if any, for the action. + :paramtype error: ~azure.mgmt.deploymentmanager.models.CloudErrorBody + """ super(StepOperationInfo, self).__init__(**kwargs) self.deployment_name = None self.correlation_id = None @@ -2041,12 +2438,12 @@ class StepResource(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param properties: Required. The properties that define the step. - :type properties: ~azure.mgmt.deploymentmanager.models.StepProperties + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar properties: Required. The properties that define the step. + :vartype properties: ~azure.mgmt.deploymentmanager.models.StepProperties """ _validation = { @@ -2070,10 +2467,18 @@ def __init__( self, *, location: str, - properties: "StepProperties", + properties: "_models.StepProperties", tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword properties: Required. The properties that define the step. + :paramtype properties: ~azure.mgmt.deploymentmanager.models.StepProperties + """ super(StepResource, self).__init__(tags=tags, location=location, **kwargs) self.properties = properties @@ -2083,8 +2488,8 @@ class WaitStepAttributes(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param duration: Required. The duration in ISO 8601 format of how long the wait should be. - :type duration: str + :ivar duration: Required. The duration in ISO 8601 format of how long the wait should be. + :vartype duration: str """ _validation = { @@ -2101,6 +2506,10 @@ def __init__( duration: str, **kwargs ): + """ + :keyword duration: Required. The duration in ISO 8601 format of how long the wait should be. + :paramtype duration: str + """ super(WaitStepAttributes, self).__init__(**kwargs) self.duration = duration @@ -2110,11 +2519,11 @@ class WaitStepProperties(StepProperties): All required parameters must be populated in order to send to Azure. - :param step_type: Required. The type of step.Constant filled by server. Possible values - include: "Wait", "HealthCheck". - :type step_type: str or ~azure.mgmt.deploymentmanager.models.StepType - :param attributes: Required. The Wait attributes. - :type attributes: ~azure.mgmt.deploymentmanager.models.WaitStepAttributes + :ivar step_type: Required. The type of step.Constant filled by server. Known values are: + "Wait", "HealthCheck". + :vartype step_type: str or ~azure.mgmt.deploymentmanager.models.StepType + :ivar attributes: Required. The Wait attributes. + :vartype attributes: ~azure.mgmt.deploymentmanager.models.WaitStepAttributes """ _validation = { @@ -2130,9 +2539,13 @@ class WaitStepProperties(StepProperties): def __init__( self, *, - attributes: "WaitStepAttributes", + attributes: "_models.WaitStepAttributes", **kwargs ): + """ + :keyword attributes: Required. The Wait attributes. + :paramtype attributes: ~azure.mgmt.deploymentmanager.models.WaitStepAttributes + """ super(WaitStepProperties, self).__init__(**kwargs) self.step_type = 'Wait' # type: str self.attributes = attributes diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/models/_patch.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/__init__.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/__init__.py index 0e9ad57acd5f..fec9e58b75b8 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/__init__.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/__init__.py @@ -14,6 +14,9 @@ from ._artifact_sources_operations import ArtifactSourcesOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ServiceTopologiesOperations', 'ServicesOperations', @@ -23,3 +26,5 @@ 'ArtifactSourcesOperations', 'Operations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_artifact_sources_operations.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_artifact_sources_operations.py index 93b9e4b0b1c6..84cc091e5320 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_artifact_sources_operations.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_artifact_sources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,207 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, List, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + artifact_source_name: str, + *, + json: Optional[_models.ArtifactSource] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/artifactSources/{artifactSourceName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "artifactSourceName": _SERIALIZER.url("artifact_source_name", artifact_source_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + artifact_source_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/artifactSources/{artifactSourceName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "artifactSourceName": _SERIALIZER.url("artifact_source_name", artifact_source_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + artifact_source_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/artifactSources/{artifactSourceName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "artifactSourceName": _SERIALIZER.url("artifact_source_name", artifact_source_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/artifactSources") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ArtifactSourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ArtifactSourcesOperations(object): - """ArtifactSourcesOperations 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.deploymentmanager.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.deploymentmanager.AzureDeploymentManager`'s + :attr:`artifact_sources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - artifact_source_name, # type: str - artifact_source_info=None, # type: Optional["_models.ArtifactSource"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ArtifactSource" + resource_group_name: str, + artifact_source_name: str, + artifact_source_info: Optional[_models.ArtifactSource] = None, + **kwargs: Any + ) -> _models.ArtifactSource: """Creates or updates an artifact source. Synchronously creates a new artifact source or updates an existing artifact source. @@ -60,48 +215,49 @@ def create_or_update( :type resource_group_name: str :param artifact_source_name: The name of the artifact source. :type artifact_source_name: str - :param artifact_source_info: Source object that defines the resource. + :param artifact_source_info: Source object that defines the resource. Default value is None. :type artifact_source_info: ~azure.mgmt.deploymentmanager.models.ArtifactSource :keyword callable cls: A custom type or function that will be passed the direct response :return: ArtifactSource, or the result of cls(response) :rtype: ~azure.mgmt.deploymentmanager.models.ArtifactSource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ArtifactSource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'artifactSourceName': self._serialize.url("artifact_source_name", artifact_source_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # 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') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ArtifactSource] - body_content_kwargs = {} # type: Dict[str, Any] if artifact_source_info is not None: - body_content = self._serialize.body(artifact_source_info, 'ArtifactSource') + _json = self._serialize.body(artifact_source_info, 'ArtifactSource') else: - body_content = None - 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) + _json = None + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + artifact_source_name=artifact_source_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -114,15 +270,17 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/artifactSources/{artifactSourceName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/artifactSources/{artifactSourceName}"} # type: ignore + + + @distributed_trace def get( self, - resource_group_name, # type: str - artifact_source_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ArtifactSource" + resource_group_name: str, + artifact_source_name: str, + **kwargs: Any + ) -> _models.ArtifactSource: """Gets an artifact source. Gets an artifact source. @@ -136,33 +294,35 @@ def get( :rtype: ~azure.mgmt.deploymentmanager.models.ArtifactSource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ArtifactSource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'artifactSourceName': self._serialize.url("artifact_source_name", artifact_source_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ArtifactSource] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + artifact_source_name=artifact_source_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -175,15 +335,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/artifactSources/{artifactSourceName}'} # type: ignore - def delete( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/artifactSources/{artifactSourceName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - artifact_source_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + artifact_source_name: str, + **kwargs: Any + ) -> None: """Deletes an artifact source. Deletes an artifact source. @@ -197,33 +359,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'artifactSourceName': self._serialize.url("artifact_source_name", artifact_source_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + artifact_source_name=artifact_source_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -233,14 +397,15 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/artifactSources/{artifactSourceName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/artifactSources/{artifactSourceName}"} # type: ignore + + @distributed_trace def list( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> List["_models.ArtifactSource"] + resource_group_name: str, + **kwargs: Any + ) -> List[_models.ArtifactSource]: """Lists the artifact sources in a resource group. Lists the artifact sources in a resource group. @@ -252,32 +417,34 @@ def list( :rtype: list[~azure.mgmt.deploymentmanager.models.ArtifactSource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ArtifactSource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.ArtifactSource]] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -290,4 +457,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/artifactSources'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/artifactSources"} # type: ignore + diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_operations.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_operations.py index 7ef0d1a4c847..c3cbe8a66b9d 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_operations.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,77 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.DeploymentManager/operations") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') -class Operations(object): - """Operations operations. + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.deploymentmanager.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. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.deploymentmanager.AzureDeploymentManager`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.OperationsList" + **kwargs: Any + ) -> _models.OperationsList: """Lists the supported operations. Lists the supported operations. @@ -58,27 +86,32 @@ def list( :rtype: ~azure.mgmt.deploymentmanager.models.OperationsList :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationsList] + + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -91,4 +124,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/providers/Microsoft.DeploymentManager/operations'} # type: ignore + + list.metadata = {'url': "/providers/Microsoft.DeploymentManager/operations"} # type: ignore + diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_patch.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_rollouts_operations.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_rollouts_operations.py index a3dde6622ea5..1f0540145d0f 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_rollouts_operations.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_rollouts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,90 +6,326 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, List, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + rollout_name: str, + *, + json: Optional[_models.RolloutRequest] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "rolloutName": _SERIALIZER.url("rollout_name", rollout_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + rollout_name: str, + *, + retry_attempt: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "rolloutName": _SERIALIZER.url("rollout_name", rollout_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if retry_attempt is not None: + _params['retryAttempt'] = _SERIALIZER.query("retry_attempt", retry_attempt, 'int') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + rollout_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "rolloutName": _SERIALIZER.url("rollout_name", rollout_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_cancel_request( + subscription_id: str, + resource_group_name: str, + rollout_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}/cancel") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "rolloutName": _SERIALIZER.url("rollout_name", rollout_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_restart_request( + subscription_id: str, + resource_group_name: str, + rollout_name: str, + *, + skip_succeeded: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}/restart") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "rolloutName": _SERIALIZER.url("rollout_name", rollout_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + if skip_succeeded is not None: + _params['skipSucceeded'] = _SERIALIZER.query("skip_succeeded", skip_succeeded, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class RolloutsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RolloutsOperations(object): - """RolloutsOperations 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.deploymentmanager.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.deploymentmanager.AzureDeploymentManager`'s + :attr:`rollouts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, - resource_group_name, # type: str - rollout_name, # type: str - rollout_request=None, # type: Optional["_models.RolloutRequest"] - **kwargs # type: Any - ): - # type: (...) -> "_models.RolloutRequest" - cls = kwargs.pop('cls', None) # type: ClsType["_models.RolloutRequest"] + resource_group_name: str, + rollout_name: str, + rollout_request: Optional[_models.RolloutRequest] = None, + **kwargs: Any + ) -> _models.RolloutRequest: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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 = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'rolloutName': self._serialize.url("rollout_name", rollout_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # 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') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RolloutRequest] - body_content_kwargs = {} # type: Dict[str, Any] if rollout_request is not None: - body_content = self._serialize.body(rollout_request, 'RolloutRequest') + _json = self._serialize.body(rollout_request, 'RolloutRequest') else: - body_content = None - 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) + _json = None + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rollout_name=rollout_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -97,22 +334,25 @@ def _create_or_update_initial( response_headers = {} response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + deserialized = self._deserialize('RolloutRequest', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}"} # type: ignore + + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - rollout_name, # type: str - rollout_request=None, # type: Optional["_models.RolloutRequest"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.RolloutRequest"] + resource_group_name: str, + rollout_name: str, + rollout_request: Optional[_models.RolloutRequest] = None, + **kwargs: Any + ) -> LROPoller[_models.RolloutRequest]: """Creates or updates a rollout. This is an asynchronous operation and can be polled to completion using the location header @@ -122,55 +362,67 @@ def begin_create_or_update( :type resource_group_name: str :param rollout_name: The rollout name. :type rollout_name: str - :param rollout_request: Source rollout request object that defines the rollout. + :param rollout_request: Source rollout request object that defines the rollout. Default value + is None. :type rollout_request: ~azure.mgmt.deploymentmanager.models.RolloutRequest :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either RolloutRequest or the result of cls(response) + :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 RolloutRequest or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.deploymentmanager.models.RolloutRequest] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RolloutRequest] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RolloutRequest"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, rollout_name=rollout_name, rollout_request=rollout_request, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + deserialized = self._deserialize('RolloutRequest', pipeline_response) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'rolloutName': self._serialize.url("rollout_name", rollout_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -179,18 +431,18 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}"} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - rollout_name, # type: str - retry_attempt=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> "_models.Rollout" + resource_group_name: str, + rollout_name: str, + retry_attempt: Optional[int] = None, + **kwargs: Any + ) -> _models.Rollout: """Gets detailed information of a rollout. Gets detailed information of a rollout. @@ -200,42 +452,43 @@ def get( :param rollout_name: The rollout name. :type rollout_name: str :param retry_attempt: Rollout retry attempt ordinal to get the result of. If not specified, - result of the latest attempt will be returned. + result of the latest attempt will be returned. Default value is None. :type retry_attempt: int :keyword callable cls: A custom type or function that will be passed the direct response :return: Rollout, or the result of cls(response) :rtype: ~azure.mgmt.deploymentmanager.models.Rollout :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Rollout"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'rolloutName': self._serialize.url("rollout_name", rollout_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if retry_attempt is not None: - query_parameters['retryAttempt'] = self._serialize.query("retry_attempt", retry_attempt, 'int') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Rollout] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rollout_name=rollout_name, + api_version=api_version, + retry_attempt=retry_attempt, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -248,15 +501,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}'} # type: ignore - def delete( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - rollout_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + rollout_name: str, + **kwargs: Any + ) -> None: """Deletes a rollout resource. Only rollouts in terminal state can be deleted. @@ -270,33 +525,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'rolloutName': self._serialize.url("rollout_name", rollout_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rollout_name=rollout_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -306,15 +563,16 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}"} # type: ignore + + @distributed_trace def cancel( self, - resource_group_name, # type: str - rollout_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Rollout" + resource_group_name: str, + rollout_name: str, + **kwargs: Any + ) -> _models.Rollout: """Stops a running rollout. Only running rollouts can be canceled. @@ -328,33 +586,35 @@ def cancel( :rtype: ~azure.mgmt.deploymentmanager.models.Rollout :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Rollout"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'rolloutName': self._serialize.url("rollout_name", rollout_name, '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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Rollout] + + + request = build_cancel_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rollout_name=rollout_name, + api_version=api_version, + template_url=self.cancel.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -367,16 +627,18 @@ def cancel( return cls(pipeline_response, deserialized, {}) return deserialized - cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}/cancel'} # type: ignore + cancel.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}/cancel"} # type: ignore + + + @distributed_trace def restart( self, - resource_group_name, # type: str - rollout_name, # type: str - skip_succeeded=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> "_models.Rollout" + resource_group_name: str, + rollout_name: str, + skip_succeeded: Optional[bool] = None, + **kwargs: Any + ) -> _models.Rollout: """Restarts a failed rollout and optionally skips all succeeded steps. Only failed rollouts can be restarted. @@ -387,42 +649,43 @@ def restart( :type rollout_name: str :param skip_succeeded: If true, will skip all succeeded steps so far in the rollout. If false, will execute the entire rollout again regardless of the current state of individual resources. - Defaults to false if not specified. + Defaults to false if not specified. Default value is None. :type skip_succeeded: bool :keyword callable cls: A custom type or function that will be passed the direct response :return: Rollout, or the result of cls(response) :rtype: ~azure.mgmt.deploymentmanager.models.Rollout :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Rollout"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.restart.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'rolloutName': self._serialize.url("rollout_name", rollout_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if skip_succeeded is not None: - query_parameters['skipSucceeded'] = self._serialize.query("skip_succeeded", skip_succeeded, '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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Rollout] + + + request = build_restart_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rollout_name=rollout_name, + api_version=api_version, + skip_succeeded=skip_succeeded, + template_url=self.restart.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -435,14 +698,16 @@ def restart( return cls(pipeline_response, deserialized, {}) return deserialized - restart.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}/restart'} # type: ignore + restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts/{rolloutName}/restart"} # type: ignore + + + @distributed_trace def list( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> List["_models.Rollout"] + resource_group_name: str, + **kwargs: Any + ) -> List[_models.Rollout]: """Lists the rollouts in a resource group. Lists the rollouts in a resource group. @@ -454,32 +719,34 @@ def list( :rtype: list[~azure.mgmt.deploymentmanager.models.Rollout] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.Rollout"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.Rollout]] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -492,4 +759,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/rollouts"} # type: ignore + diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_service_topologies_operations.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_service_topologies_operations.py index 6074a252adf0..c716e6d43bbc 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_service_topologies_operations.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_service_topologies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,207 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, List, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + service_topology_name: str, + *, + json: Optional[_models.ServiceTopologyResource] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "serviceTopologyName": _SERIALIZER.url("service_topology_name", service_topology_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + service_topology_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "serviceTopologyName": _SERIALIZER.url("service_topology_name", service_topology_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + service_topology_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "serviceTopologyName": _SERIALIZER.url("service_topology_name", service_topology_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ServiceTopologiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ServiceTopologiesOperations(object): - """ServiceTopologiesOperations 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.deploymentmanager.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.deploymentmanager.AzureDeploymentManager`'s + :attr:`service_topologies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_topology_name, # type: str - service_topology_info, # type: "_models.ServiceTopologyResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ServiceTopologyResource" + resource_group_name: str, + service_topology_name: str, + service_topology_info: _models.ServiceTopologyResource, + **kwargs: Any + ) -> _models.ServiceTopologyResource: """Creates or updates a service topology. Synchronously creates a new service topology or updates an existing service topology. @@ -67,38 +222,39 @@ def create_or_update( :rtype: ~azure.mgmt.deploymentmanager.models.ServiceTopologyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceTopologyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(service_topology_info, 'ServiceTopologyResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceTopologyResource] + + _json = self._serialize.body(service_topology_info, 'ServiceTopologyResource') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -111,15 +267,17 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}"} # type: ignore + + + @distributed_trace def get( self, - resource_group_name, # type: str - service_topology_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ServiceTopologyResource" + resource_group_name: str, + service_topology_name: str, + **kwargs: Any + ) -> _models.ServiceTopologyResource: """Gets the service topology. Gets the service topology. @@ -133,33 +291,35 @@ def get( :rtype: ~azure.mgmt.deploymentmanager.models.ServiceTopologyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceTopologyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceTopologyResource] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -172,15 +332,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}'} # type: ignore - def delete( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - service_topology_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_topology_name: str, + **kwargs: Any + ) -> None: """Deletes the service topology. Deletes the service topology. @@ -194,33 +356,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -230,14 +394,15 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}"} # type: ignore + + @distributed_trace def list( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> List["_models.ServiceTopologyResource"] + resource_group_name: str, + **kwargs: Any + ) -> List[_models.ServiceTopologyResource]: """Lists the service topologies in the resource group. Lists the service topologies in the resource group. @@ -249,32 +414,34 @@ def list( :rtype: list[~azure.mgmt.deploymentmanager.models.ServiceTopologyResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ServiceTopologyResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.ServiceTopologyResource]] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -287,4 +454,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies"} # type: ignore + diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_service_units_operations.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_service_units_operations.py index 46cfaa316390..754cc8f88f8e 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_service_units_operations.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_service_units_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,91 +6,261 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, List, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + service_topology_name: str, + service_name: str, + service_unit_name: str, + *, + json: Optional[_models.ServiceUnitResource] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "serviceTopologyName": _SERIALIZER.url("service_topology_name", service_topology_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "serviceUnitName": _SERIALIZER.url("service_unit_name", service_unit_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + service_topology_name: str, + service_name: str, + service_unit_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "serviceTopologyName": _SERIALIZER.url("service_topology_name", service_topology_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "serviceUnitName": _SERIALIZER.url("service_unit_name", service_unit_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + service_topology_name: str, + service_name: str, + service_unit_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "serviceTopologyName": _SERIALIZER.url("service_topology_name", service_topology_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "serviceUnitName": _SERIALIZER.url("service_unit_name", service_unit_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + resource_group_name: str, + service_topology_name: str, + service_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "serviceTopologyName": _SERIALIZER.url("service_topology_name", service_topology_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ServiceUnitsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ServiceUnitsOperations(object): - """ServiceUnitsOperations 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.deploymentmanager.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.deploymentmanager.AzureDeploymentManager`'s + :attr:`service_units` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, - resource_group_name, # type: str - service_topology_name, # type: str - service_name, # type: str - service_unit_name, # type: str - service_unit_info, # type: "_models.ServiceUnitResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ServiceUnitResource" - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceUnitResource"] + resource_group_name: str, + service_topology_name: str, + service_name: str, + service_unit_name: str, + service_unit_info: _models.ServiceUnitResource, + **kwargs: Any + ) -> _models.ServiceUnitResource: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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 = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - 'serviceName': self._serialize.url("service_name", service_name, 'str'), - 'serviceUnitName': self._serialize.url("service_unit_name", service_unit_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(service_unit_info, 'ServiceUnitResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceUnitResource] + + _json = self._serialize.body(service_unit_info, 'ServiceUnitResource') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + service_name=service_name, + service_unit_name=service_unit_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -98,24 +269,27 @@ def _create_or_update_initial( response_headers = {} response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + deserialized = self._deserialize('ServiceUnitResource', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}"} # type: ignore + + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - service_topology_name, # type: str - service_name, # type: str - service_unit_name, # type: str - service_unit_info, # type: "_models.ServiceUnitResource" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ServiceUnitResource"] + resource_group_name: str, + service_topology_name: str, + service_name: str, + service_unit_name: str, + service_unit_info: _models.ServiceUnitResource, + **kwargs: Any + ) -> LROPoller[_models.ServiceUnitResource]: """Creates or updates a service unit under the service in the service topology. This is an asynchronous operation and can be polled to completion using the operation resource @@ -133,55 +307,64 @@ def begin_create_or_update( :type service_unit_info: ~azure.mgmt.deploymentmanager.models.ServiceUnitResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ServiceUnitResource or the result of cls(response) + :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 ServiceUnitResource or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.deploymentmanager.models.ServiceUnitResource] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceUnitResource] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceUnitResource"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, service_topology_name=service_topology_name, service_name=service_name, service_unit_name=service_unit_name, service_unit_info=service_unit_info, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + deserialized = self._deserialize('ServiceUnitResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - 'serviceName': self._serialize.url("service_name", service_name, 'str'), - 'serviceUnitName': self._serialize.url("service_unit_name", service_unit_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -190,19 +373,19 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}"} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - service_topology_name, # type: str - service_name, # type: str - service_unit_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ServiceUnitResource" + resource_group_name: str, + service_topology_name: str, + service_name: str, + service_unit_name: str, + **kwargs: Any + ) -> _models.ServiceUnitResource: """Gets the service unit. Gets the service unit. @@ -220,35 +403,37 @@ def get( :rtype: ~azure.mgmt.deploymentmanager.models.ServiceUnitResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceUnitResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - 'serviceName': self._serialize.url("service_name", service_name, 'str'), - 'serviceUnitName': self._serialize.url("service_unit_name", service_unit_name, '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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceUnitResource] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + service_name=service_name, + service_unit_name=service_unit_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -261,17 +446,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}'} # type: ignore - def delete( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - service_topology_name, # type: str - service_name, # type: str - service_unit_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_topology_name: str, + service_name: str, + service_unit_name: str, + **kwargs: Any + ) -> None: """Deletes the service unit. Deletes the service unit. @@ -289,35 +476,37 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - 'serviceName': self._serialize.url("service_name", service_name, 'str'), - 'serviceUnitName': self._serialize.url("service_unit_name", service_unit_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + service_name=service_name, + service_unit_name=service_unit_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -327,16 +516,17 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits/{serviceUnitName}"} # type: ignore + + @distributed_trace def list( self, - resource_group_name, # type: str - service_topology_name, # type: str - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> List["_models.ServiceUnitResource"] + resource_group_name: str, + service_topology_name: str, + service_name: str, + **kwargs: Any + ) -> List[_models.ServiceUnitResource]: """Lists the service units under a service in the service topology. Lists the service units under a service in the service topology. @@ -352,34 +542,36 @@ def list( :rtype: list[~azure.mgmt.deploymentmanager.models.ServiceUnitResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ServiceUnitResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - 'serviceName': self._serialize.url("service_name", service_name, '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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.ServiceUnitResource]] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + service_name=service_name, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -392,4 +584,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}/serviceUnits"} # type: ignore + diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_services_operations.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_services_operations.py index 16744352b738..61a52bf4734b 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_services_operations.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,54 +6,216 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, List, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + service_topology_name: str, + service_name: str, + *, + json: Optional[_models.ServiceResource] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "serviceTopologyName": _SERIALIZER.url("service_topology_name", service_topology_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + service_topology_name: str, + service_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "serviceTopologyName": _SERIALIZER.url("service_topology_name", service_topology_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + service_topology_name: str, + service_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "serviceTopologyName": _SERIALIZER.url("service_topology_name", service_topology_name, 'str'), + "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + resource_group_name: str, + service_topology_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "serviceTopologyName": _SERIALIZER.url("service_topology_name", service_topology_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ServicesOperations(object): - """ServicesOperations 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.deploymentmanager.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.deploymentmanager.AzureDeploymentManager`'s + :attr:`services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - service_topology_name, # type: str - service_name, # type: str - service_info, # type: "_models.ServiceResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ServiceResource" + resource_group_name: str, + service_topology_name: str, + service_name: str, + service_info: _models.ServiceResource, + **kwargs: Any + ) -> _models.ServiceResource: """Creates or updates a service in the service topology. Synchronously creates a new service or updates an existing service. @@ -70,39 +233,40 @@ def create_or_update( :rtype: ~azure.mgmt.deploymentmanager.models.ServiceResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - 'serviceName': self._serialize.url("service_name", service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(service_info, 'ServiceResource') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceResource] + + _json = self._serialize.body(service_info, 'ServiceResource') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + service_name=service_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -115,16 +279,18 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}"} # type: ignore + + + @distributed_trace def get( self, - resource_group_name, # type: str - service_topology_name, # type: str - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ServiceResource" + resource_group_name: str, + service_topology_name: str, + service_name: str, + **kwargs: Any + ) -> _models.ServiceResource: """Gets the service. Gets the service. @@ -140,34 +306,36 @@ def get( :rtype: ~azure.mgmt.deploymentmanager.models.ServiceResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServiceResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - 'serviceName': self._serialize.url("service_name", service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServiceResource] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + service_name=service_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -180,16 +348,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}'} # type: ignore - def delete( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - service_topology_name, # type: str - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + service_topology_name: str, + service_name: str, + **kwargs: Any + ) -> None: """Deletes the service. Deletes the service. @@ -205,34 +375,36 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - 'serviceName': self._serialize.url("service_name", service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + service_name=service_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -242,15 +414,16 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services/{serviceName}"} # type: ignore + + @distributed_trace def list( self, - resource_group_name, # type: str - service_topology_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> List["_models.ServiceResource"] + resource_group_name: str, + service_topology_name: str, + **kwargs: Any + ) -> List[_models.ServiceResource]: """Lists the services in the service topology. Lists the services in the service topology. @@ -264,33 +437,35 @@ def list( :rtype: list[~azure.mgmt.deploymentmanager.models.ServiceResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ServiceResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'serviceTopologyName': self._serialize.url("service_topology_name", service_topology_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.ServiceResource]] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + service_topology_name=service_topology_name, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -303,4 +478,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/serviceTopologies/{serviceTopologyName}/services"} # type: ignore + diff --git a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_steps_operations.py b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_steps_operations.py index 2ca21406f97c..590f2965135e 100644 --- a/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_steps_operations.py +++ b/sdk/deploymentmanager/azure-mgmt-deploymentmanager/azure/mgmt/deploymentmanager/operations/_steps_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,207 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, List, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + step_name: str, + *, + json: Optional[_models.StepResource] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/steps/{stepName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "stepName": _SERIALIZER.url("step_name", step_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + step_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/steps/{stepName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "stepName": _SERIALIZER.url("step_name", step_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + step_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/steps/{stepName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "stepName": _SERIALIZER.url("step_name", step_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/steps") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class StepsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class StepsOperations(object): - """StepsOperations 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.deploymentmanager.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.deploymentmanager.AzureDeploymentManager`'s + :attr:`steps` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - step_name, # type: str - step_info=None, # type: Optional["_models.StepResource"] - **kwargs # type: Any - ): - # type: (...) -> "_models.StepResource" + resource_group_name: str, + step_name: str, + step_info: Optional[_models.StepResource] = None, + **kwargs: Any + ) -> _models.StepResource: """Creates or updates a rollout step with the given step properties. Synchronously creates a new step or updates an existing step. @@ -60,48 +215,49 @@ def create_or_update( :type resource_group_name: str :param step_name: The name of the deployment step. :type step_name: str - :param step_info: The step object. + :param step_info: The step object. Default value is None. :type step_info: ~azure.mgmt.deploymentmanager.models.StepResource :keyword callable cls: A custom type or function that will be passed the direct response :return: StepResource, or the result of cls(response) :rtype: ~azure.mgmt.deploymentmanager.models.StepResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StepResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'stepName': self._serialize.url("step_name", step_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # 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') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.StepResource] - body_content_kwargs = {} # type: Dict[str, Any] if step_info is not None: - body_content = self._serialize.body(step_info, 'StepResource') + _json = self._serialize.body(step_info, 'StepResource') else: - body_content = None - 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) + _json = None + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + step_name=step_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -114,15 +270,17 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/steps/{stepName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/steps/{stepName}"} # type: ignore + + + @distributed_trace def get( self, - resource_group_name, # type: str - step_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.StepResource" + resource_group_name: str, + step_name: str, + **kwargs: Any + ) -> _models.StepResource: """Gets the step. Gets the step. @@ -136,33 +294,35 @@ def get( :rtype: ~azure.mgmt.deploymentmanager.models.StepResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StepResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'stepName': self._serialize.url("step_name", step_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StepResource] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + step_name=step_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -175,15 +335,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/steps/{stepName}'} # type: ignore - def delete( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/steps/{stepName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - step_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + step_name: str, + **kwargs: Any + ) -> None: """Deletes the step. Deletes the step. @@ -197,33 +359,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'stepName': self._serialize.url("step_name", step_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + step_name=step_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -233,14 +397,15 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/steps/{stepName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/steps/{stepName}"} # type: ignore + + @distributed_trace def list( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> List["_models.StepResource"] + resource_group_name: str, + **kwargs: Any + ) -> List[_models.StepResource]: """Lists the steps in a resource group. Lists the steps in a resource group. @@ -252,32 +417,34 @@ def list( :rtype: list[~azure.mgmt.deploymentmanager.models.StepResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.StepResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.StepResource]] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -290,4 +457,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/steps'} # type: ignore + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeploymentManager/steps"} # type: ignore +