From 071c83a11cc8ef64d6a9bf65b6c59565698824a1 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 15 Mar 2022 04:06:42 +0000 Subject: [PATCH] CodeGen from PR 18223 in Azure/azure-rest-api-specs Merge fc71dc5ae5995566b5a68be1ab11fa21cc0b1d63 into 2abe647120f14bb145968a5543ead8ed51394498 --- sdk/support/azure-mgmt-support/_meta.json | 11 + .../azure/mgmt/support/__init__.py | 9 +- .../azure/mgmt/support/_configuration.py | 19 +- .../azure/mgmt/support/_metadata.json | 69 +- .../azure/mgmt/support/_microsoft_support.py | 88 +- .../azure/mgmt/support/_patch.py | 31 + .../azure/mgmt/support/_vendor.py | 27 + .../azure/mgmt/support/_version.py | 2 +- .../azure/mgmt/support/aio/__init__.py | 5 + .../azure/mgmt/support/aio/_configuration.py | 6 +- .../mgmt/support/aio/_microsoft_support.py | 77 +- .../azure/mgmt/support/aio/_patch.py | 31 + .../operations/_communications_operations.py | 222 ++--- .../support/aio/operations/_operations.py | 52 +- .../_problem_classifications_operations.py | 93 +- .../aio/operations/_services_operations.py | 77 +- .../operations/_support_tickets_operations.py | 263 +++-- .../azure/mgmt/support/models/__init__.py | 75 +- .../models/_microsoft_support_enums.py | 31 +- .../azure/mgmt/support/models/_models.py | 909 ------------------ .../azure/mgmt/support/models/_models_py3.py | 461 ++++++--- .../operations/_communications_operations.py | 433 ++++++--- .../mgmt/support/operations/_operations.py | 88 +- .../_problem_classifications_operations.py | 180 ++-- .../operations/_services_operations.py | 152 ++- .../operations/_support_tickets_operations.py | 505 ++++++---- 26 files changed, 1867 insertions(+), 2049 deletions(-) create mode 100644 sdk/support/azure-mgmt-support/_meta.json create mode 100644 sdk/support/azure-mgmt-support/azure/mgmt/support/_patch.py create mode 100644 sdk/support/azure-mgmt-support/azure/mgmt/support/_vendor.py create mode 100644 sdk/support/azure-mgmt-support/azure/mgmt/support/aio/_patch.py delete mode 100644 sdk/support/azure-mgmt-support/azure/mgmt/support/models/_models.py diff --git a/sdk/support/azure-mgmt-support/_meta.json b/sdk/support/azure-mgmt-support/_meta.json new file mode 100644 index 000000000000..7e4002ae837d --- /dev/null +++ b/sdk/support/azure-mgmt-support/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "36fd2229efc2ae16afdbfe2b3806fca275754413", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/support/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/support/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/support/azure-mgmt-support/azure/mgmt/support/__init__.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/__init__.py index a6bda323bafd..33f01fa5ad15 100644 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/__init__.py +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MicrosoftSupport'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/support/azure-mgmt-support/azure/mgmt/support/_configuration.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/_configuration.py index c9949d764016..344372276376 100644 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/_configuration.py +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MicrosoftSupportConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(MicrosoftSupportConfiguration, self).__init__(**kwargs) 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(MicrosoftSupportConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,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/support/azure-mgmt-support/azure/mgmt/support/_metadata.json b/sdk/support/azure-mgmt-support/azure/mgmt/support/_metadata.json index 7e8b87be45d9..57a61171cfef 100644 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/_metadata.json +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/_metadata.json @@ -5,11 +5,13 @@ "name": "MicrosoftSupport", "filename": "_microsoft_support", "description": "Microsoft Azure Support Resource Provider.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, - "client_side_validation": false + "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\": [\"MicrosoftSupportConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MicrosoftSupportConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -28,13 +30,13 @@ }, "async": { "credential": { - "signature": "credential, # type: \"AsyncTokenCredential\"", + "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, # type: str", + "signature": "subscription_id: str,", "description": "Azure subscription Id.", "docstring_type": "str", "required": true @@ -42,14 +44,57 @@ }, "constant": { }, - "call": "credential, subscription_id" + "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=\"https://management.azure.com\", # type: 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: str = \"https://management.azure.com\",", + "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 + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", @@ -57,9 +102,5 @@ "problem_classifications": "ProblemClassificationsOperations", "support_tickets": "SupportTicketsOperations", "communications": "CommunicationsOperations" - }, - "operation_mixins": { - }, - "sync_imports": "None", - "async_imports": "None" + } } \ No newline at end of file diff --git a/sdk/support/azure-mgmt-support/azure/mgmt/support/_microsoft_support.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/_microsoft_support.py index e723ab9dd501..afc35a886ecf 100644 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/_microsoft_support.py +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/_microsoft_support.py @@ -6,27 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MicrosoftSupportConfiguration +from .operations import CommunicationsOperations, Operations, ProblemClassificationsOperations, ServicesOperations, SupportTicketsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential -from ._configuration import MicrosoftSupportConfiguration -from .operations import Operations -from .operations import ServicesOperations -from .operations import ProblemClassificationsOperations -from .operations import SupportTicketsOperations -from .operations import CommunicationsOperations -from . import models - - -class MicrosoftSupport(object): +class MicrosoftSupport: """Microsoft Azure Support Resource Provider. :ivar operations: Operations operations @@ -34,7 +29,8 @@ class MicrosoftSupport(object): :ivar services: ServicesOperations operations :vartype services: azure.mgmt.support.operations.ServicesOperations :ivar problem_classifications: ProblemClassificationsOperations operations - :vartype problem_classifications: azure.mgmt.support.operations.ProblemClassificationsOperations + :vartype problem_classifications: + azure.mgmt.support.operations.ProblemClassificationsOperations :ivar support_tickets: SupportTicketsOperations operations :vartype support_tickets: azure.mgmt.support.operations.SupportTicketsOperations :ivar communications: CommunicationsOperations operations @@ -43,38 +39,58 @@ class MicrosoftSupport(object): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Azure subscription Id. :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 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 = MicrosoftSupportConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = MicrosoftSupportConfiguration(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.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.problem_classifications = ProblemClassificationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.support_tickets = SupportTicketsOperations(self._client, self._config, self._serialize, self._deserialize) + self.communications = CommunicationsOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> 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.rest.HttpResponse + """ - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.services = ServicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.problem_classifications = ProblemClassificationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.support_tickets = SupportTicketsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.communications = CommunicationsOperations( - self._client, self._config, self._serialize, self._deserialize) + 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/support/azure-mgmt-support/azure/mgmt/support/_patch.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/support/azure-mgmt-support/azure/mgmt/support/_vendor.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/_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/support/azure-mgmt-support/azure/mgmt/support/_version.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/_version.py index caf312bd2d0b..e5754a47ce68 100644 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/_version.py +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "6.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/__init__.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/__init__.py index 72e51539a15c..f8f777a69be1 100644 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/__init__.py +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/__init__.py @@ -8,3 +8,8 @@ from ._microsoft_support import MicrosoftSupport __all__ = ['MicrosoftSupport'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/_configuration.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/_configuration.py index 8982ea2f383f..e75359deb13d 100644 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/_configuration.py +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/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 @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(MicrosoftSupportConfiguration, self).__init__(**kwargs) 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(MicrosoftSupportConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,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/support/azure-mgmt-support/azure/mgmt/support/aio/_microsoft_support.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/_microsoft_support.py index 46929739a715..1fac499d3172 100644 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/_microsoft_support.py +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/_microsoft_support.py @@ -6,25 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MicrosoftSupportConfiguration +from .operations import CommunicationsOperations, Operations, ProblemClassificationsOperations, ServicesOperations, SupportTicketsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MicrosoftSupportConfiguration -from .operations import Operations -from .operations import ServicesOperations -from .operations import ProblemClassificationsOperations -from .operations import SupportTicketsOperations -from .operations import CommunicationsOperations -from .. import models - - -class MicrosoftSupport(object): +class MicrosoftSupport: """Microsoft Azure Support Resource Provider. :ivar operations: Operations operations @@ -32,7 +29,8 @@ class MicrosoftSupport(object): :ivar services: ServicesOperations operations :vartype services: azure.mgmt.support.aio.operations.ServicesOperations :ivar problem_classifications: ProblemClassificationsOperations operations - :vartype problem_classifications: azure.mgmt.support.aio.operations.ProblemClassificationsOperations + :vartype problem_classifications: + azure.mgmt.support.aio.operations.ProblemClassificationsOperations :ivar support_tickets: SupportTicketsOperations operations :vartype support_tickets: azure.mgmt.support.aio.operations.SupportTicketsOperations :ivar communications: CommunicationsOperations operations @@ -41,37 +39,58 @@ class MicrosoftSupport(object): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Azure subscription Id. :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 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 = MicrosoftSupportConfiguration(credential, subscription_id, **kwargs) + self._config = MicrosoftSupportConfiguration(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.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.services = ServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.problem_classifications = ProblemClassificationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.support_tickets = SupportTicketsOperations(self._client, self._config, self._serialize, self._deserialize) + self.communications = CommunicationsOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> 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.rest.AsyncHttpResponse + """ - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.services = ServicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.problem_classifications = ProblemClassificationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.support_tickets = SupportTicketsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.communications = CommunicationsOperations( - self._client, self._config, self._serialize, self._deserialize) + 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/support/azure-mgmt-support/azure/mgmt/support/aio/_patch.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/operations/_communications_operations.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/operations/_communications_operations.py index afd580234b3c..9c06d3949417 100644 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/operations/_communications_operations.py +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/operations/_communications_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._communications_operations import build_check_name_availability_request, build_create_request_initial, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,11 +48,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def check_name_availability( self, support_ticket_name: str, check_name_availability_input: "_models.CheckNameAvailabilityInput", - **kwargs + **kwargs: Any ) -> "_models.CheckNameAvailabilityOutput": """Check the availability of a resource name. This API should be used to check the uniqueness of the name for adding a new communication to the support ticket. @@ -66,37 +72,27 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'supportTicketName': self._serialize.url("support_ticket_name", support_ticket_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(check_name_availability_input, 'CheckNameAvailabilityInput') + + request = build_check_name_availability_request( + support_ticket_name=support_ticket_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(check_name_availability_input, 'CheckNameAvailabilityInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ExceptionResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityOutput', pipeline_response) @@ -105,14 +101,17 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}/checkNameAvailability'} # type: ignore + + @distributed_trace def list( self, support_ticket_name: str, top: Optional[int] = None, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.CommunicationsListResult"]: """Lists all communications (attachments not included) for a support ticket. :code:`
`
You can also filter support ticket communications by *CreatedDate* or *CommunicationType* using @@ -132,8 +131,10 @@ def list( CommunicationType and CreatedDate filters by Logical And ('and') operator. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CommunicationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.support.models.CommunicationsListResult] + :return: An iterator like instance of either CommunicationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.support.models.CommunicationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunicationsListResult"] @@ -141,39 +142,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'supportTicketName': self._serialize.url("support_ticket_name", support_ticket_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + support_ticket_name=support_ticket_name, + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + support_ticket_name=support_ticket_name, + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('CommunicationsListResult', pipeline_response) + deserialized = self._deserialize("CommunicationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -186,22 +183,24 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ExceptionResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}/communications'} # type: ignore + @distributed_trace_async async def get( self, support_ticket_name: str, communication_name: str, - **kwargs + **kwargs: Any ) -> "_models.CommunicationDetails": """Returns communication details for a support ticket. @@ -219,33 +218,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'supportTicketName': self._serialize.url("support_ticket_name", support_ticket_name, 'str'), - 'communicationName': self._serialize.url("communication_name", communication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + support_ticket_name=support_ticket_name, + communication_name=communication_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ExceptionResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CommunicationDetails', pipeline_response) @@ -254,53 +243,44 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}/communications/{communicationName}'} # type: ignore + async def _create_initial( self, support_ticket_name: str, communication_name: str, create_communication_parameters: "_models.CommunicationDetails", - **kwargs + **kwargs: Any ) -> Optional["_models.CommunicationDetails"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.CommunicationDetails"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'supportTicketName': self._serialize.url("support_ticket_name", support_ticket_name, 'str'), - 'communicationName': self._serialize.url("communication_name", communication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_communication_parameters, 'CommunicationDetails') + + request = build_create_request_initial( + support_ticket_name=support_ticket_name, + communication_name=communication_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_communication_parameters, 'CommunicationDetails') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ExceptionResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -310,14 +290,17 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}/communications/{communicationName}'} # type: ignore + + @distributed_trace_async async def begin_create( self, support_ticket_name: str, communication_name: str, create_communication_parameters: "_models.CommunicationDetails", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.CommunicationDetails"]: """Adds a new customer communication to an Azure support ticket. @@ -329,15 +312,19 @@ async def begin_create( :type create_communication_parameters: ~azure.mgmt.support.models.CommunicationDetails :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: True for ARMPolling, False for no polling, or a - polling object for 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 CommunicationDetails 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 CommunicationDetails or the result + of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.support.models.CommunicationDetails] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunicationDetails"] lro_delay = kwargs.pop( 'polling_interval', @@ -349,27 +336,21 @@ async def begin_create( support_ticket_name=support_ticket_name, communication_name=communication_name, create_communication_parameters=create_communication_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('CommunicationDetails', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'supportTicketName': self._serialize.url("support_ticket_name", support_ticket_name, 'str'), - 'communicationName': self._serialize.url("communication_name", communication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -381,4 +362,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}/communications/{communicationName}'} # type: ignore diff --git a/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/operations/_operations.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/operations/_operations.py index 5fae6d0ab685..ec702ea145b1 100644 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/operations/_operations.py +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,15 +46,18 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.OperationsListResult"]: """This lists all the available Microsoft Support REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.support.models.OperationsListResult] + :return: An iterator like instance of either OperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.support.models.OperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsListResult"] @@ -57,30 +65,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsListResult', pipeline_response) + deserialized = self._deserialize("OperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +98,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ExceptionResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/operations/_problem_classifications_operations.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/operations/_problem_classifications_operations.py index 7730a3b18dfe..36b30b16fb2e 100644 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/operations/_problem_classifications_operations.py +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/operations/_problem_classifications_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._problem_classifications_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,10 +46,11 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, service_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ProblemClassificationsListResult"]: """Lists all the problem classifications (categories) available for a specific Azure service. Always use the service and problem classifications obtained programmatically. This practice @@ -54,8 +60,10 @@ def list( retrieved. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProblemClassificationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.support.models.ProblemClassificationsListResult] + :return: An iterator like instance of either ProblemClassificationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.support.models.ProblemClassificationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProblemClassificationsListResult"] @@ -63,34 +71,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + service_name=service_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + service_name=service_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ProblemClassificationsListResult', pipeline_response) + deserialized = self._deserialize("ProblemClassificationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,22 +106,24 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ExceptionResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/providers/Microsoft.Support/services/{serviceName}/problemClassifications'} # type: ignore + @distributed_trace_async async def get( self, service_name: str, problem_classification_name: str, - **kwargs + **kwargs: Any ) -> "_models.ProblemClassification": """Get problem classification details for a specific Azure service. @@ -136,32 +141,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'serviceName': self._serialize.url("service_name", service_name, 'str'), - 'problemClassificationName': self._serialize.url("problem_classification_name", problem_classification_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 = build_get_request( + service_name=service_name, + problem_classification_name=problem_classification_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ExceptionResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ProblemClassification', pipeline_response) @@ -170,4 +165,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Support/services/{serviceName}/problemClassifications/{problemClassificationName}'} # type: ignore + diff --git a/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/operations/_services_operations.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/operations/_services_operations.py index 441180b97dac..43442aafdc12 100644 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/operations/_services_operations.py +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/operations/_services_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._services_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,9 +46,10 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ServicesListResult"]: """Lists all the Azure services available for support ticket creation. For **Technical** issues, select the Service Id that maps to the Azure service/product as displayed in the **Services** @@ -63,30 +69,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ServicesListResult', pipeline_response) + deserialized = self._deserialize("ServicesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -99,21 +102,23 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ExceptionResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/providers/Microsoft.Support/services'} # type: ignore + @distributed_trace_async async def get( self, service_name: str, - **kwargs + **kwargs: Any ) -> "_models.Service": """Gets a specific Azure service for support ticket creation. @@ -129,31 +134,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - '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 = build_get_request( + service_name=service_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ExceptionResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Service', pipeline_response) @@ -162,4 +157,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Support/services/{serviceName}'} # type: ignore + diff --git a/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/operations/_support_tickets_operations.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/operations/_support_tickets_operations.py index 47079757bd30..ba404ae173d6 100644 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/operations/_support_tickets_operations.py +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/aio/operations/_support_tickets_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._support_tickets_operations import build_check_name_availability_request, build_create_request_initial, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,10 +48,11 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def check_name_availability( self, check_name_availability_input: "_models.CheckNameAvailabilityInput", - **kwargs + **kwargs: Any ) -> "_models.CheckNameAvailabilityOutput": """Check the availability of a resource name. This API should be used to check the uniqueness of the name for support ticket creation for the selected subscription. @@ -63,36 +69,26 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(check_name_availability_input, 'CheckNameAvailabilityInput') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(check_name_availability_input, 'CheckNameAvailabilityInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ExceptionResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityOutput', pipeline_response) @@ -101,13 +97,16 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/checkNameAvailability'} # type: ignore + + @distributed_trace def list( self, top: Optional[int] = None, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.SupportTicketsListResult"]: """Lists all the support tickets for an Azure subscription. You can also filter the support tickets by *Status* or *CreatedDate* using the $filter parameter. Output will be a paged result @@ -124,8 +123,10 @@ def list( combine them using the logical 'AND'. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SupportTicketsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.support.models.SupportTicketsListResult] + :return: An iterator like instance of either SupportTicketsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.support.models.SupportTicketsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportTicketsListResult"] @@ -133,38 +134,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SupportTicketsListResult', pipeline_response) + deserialized = self._deserialize("SupportTicketsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -177,21 +173,23 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ExceptionResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets'} # type: ignore + @distributed_trace_async async def get( self, support_ticket_name: str, - **kwargs + **kwargs: Any ) -> "_models.SupportTicketDetails": """Get ticket details for an Azure subscription. Support ticket data is available for 18 months after ticket creation. If a ticket was created more than 18 months ago, a request for data @@ -209,32 +207,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'supportTicketName': self._serialize.url("support_ticket_name", support_ticket_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + support_ticket_name=support_ticket_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ExceptionResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SupportTicketDetails', pipeline_response) @@ -243,13 +231,16 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}'} # type: ignore + + @distributed_trace_async async def update( self, support_ticket_name: str, update_support_ticket: "_models.UpdateSupportTicket", - **kwargs + **kwargs: Any ) -> "_models.SupportTicketDetails": """This API allows you to update the severity level, ticket status, and your contact information in the support ticket.:code:`
`:code:`
`Note: The severity levels cannot be changed if @@ -273,37 +264,27 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'supportTicketName': self._serialize.url("support_ticket_name", support_ticket_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(update_support_ticket, 'UpdateSupportTicket') + + request = build_update_request( + support_ticket_name=support_ticket_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_support_ticket, 'UpdateSupportTicket') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ExceptionResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SupportTicketDetails', pipeline_response) @@ -312,51 +293,42 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}'} # type: ignore + async def _create_initial( self, support_ticket_name: str, create_support_ticket_parameters: "_models.SupportTicketDetails", - **kwargs + **kwargs: Any ) -> Optional["_models.SupportTicketDetails"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SupportTicketDetails"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'supportTicketName': self._serialize.url("support_ticket_name", support_ticket_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(create_support_ticket_parameters, 'SupportTicketDetails') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request_initial( + support_ticket_name=support_ticket_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_support_ticket_parameters, 'SupportTicketDetails') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ExceptionResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -366,13 +338,16 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}'} # type: ignore + + @distributed_trace_async async def begin_create( self, support_ticket_name: str, create_support_ticket_parameters: "_models.SupportTicketDetails", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.SupportTicketDetails"]: """Creates a new support ticket for Subscription and Service limits (Quota), Technical, Billing, and Subscription Management issues for the specified subscription. Learn the `prerequisites @@ -388,11 +363,11 @@ async def begin_create( ticket will reach out to you for consent if your issue requires gathering diagnostic information from your Azure resources.:code:`
`:code:`
`\ **Creating a support ticket for on-behalf-of**\ : Include *x-ms-authorization-auxiliary* header to provide an auxiliary - token as per `documentation `_. The primary token will be from the tenant for - whom a support ticket is being raised against the subscription, i.e. Cloud solution provider - (CSP) customer tenant. The auxiliary token will be from the Cloud solution provider (CSP) - partner tenant. + token as per `documentation + `_. + The primary token will be from the tenant for whom a support ticket is being raised against the + subscription, i.e. Cloud solution provider (CSP) customer tenant. The auxiliary token will be + from the Cloud solution provider (CSP) partner tenant. :param support_ticket_name: Support ticket name. :type support_ticket_name: str @@ -400,15 +375,19 @@ async def begin_create( :type create_support_ticket_parameters: ~azure.mgmt.support.models.SupportTicketDetails :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: True for ARMPolling, False for no polling, or a - polling object for 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 SupportTicketDetails 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 SupportTicketDetails or the result + of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.support.models.SupportTicketDetails] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportTicketDetails"] lro_delay = kwargs.pop( 'polling_interval', @@ -419,26 +398,21 @@ async def begin_create( raw_result = await self._create_initial( support_ticket_name=support_ticket_name, create_support_ticket_parameters=create_support_ticket_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SupportTicketDetails', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'supportTicketName': self._serialize.url("support_ticket_name", support_ticket_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -450,4 +424,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}'} # type: ignore diff --git a/sdk/support/azure-mgmt-support/azure/mgmt/support/models/__init__.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/models/__init__.py index f988a47f40bb..7165db494f4a 100644 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/models/__init__.py +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/models/__init__.py @@ -6,56 +6,31 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import CheckNameAvailabilityInput - from ._models_py3 import CheckNameAvailabilityOutput - from ._models_py3 import CommunicationDetails - from ._models_py3 import CommunicationsListResult - from ._models_py3 import ContactProfile - from ._models_py3 import ExceptionResponse - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationsListResult - from ._models_py3 import ProblemClassification - from ._models_py3 import ProblemClassificationsListResult - from ._models_py3 import QuotaChangeRequest - from ._models_py3 import QuotaTicketDetails - from ._models_py3 import Service - from ._models_py3 import ServiceError - from ._models_py3 import ServiceErrorDetail - from ._models_py3 import ServiceLevelAgreement - from ._models_py3 import ServicesListResult - from ._models_py3 import SupportEngineer - from ._models_py3 import SupportTicketDetails - from ._models_py3 import SupportTicketsListResult - from ._models_py3 import TechnicalTicketDetails - from ._models_py3 import UpdateContactProfile - from ._models_py3 import UpdateSupportTicket -except (SyntaxError, ImportError): - from ._models import CheckNameAvailabilityInput # type: ignore - from ._models import CheckNameAvailabilityOutput # type: ignore - from ._models import CommunicationDetails # type: ignore - from ._models import CommunicationsListResult # type: ignore - from ._models import ContactProfile # type: ignore - from ._models import ExceptionResponse # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationsListResult # type: ignore - from ._models import ProblemClassification # type: ignore - from ._models import ProblemClassificationsListResult # type: ignore - from ._models import QuotaChangeRequest # type: ignore - from ._models import QuotaTicketDetails # type: ignore - from ._models import Service # type: ignore - from ._models import ServiceError # type: ignore - from ._models import ServiceErrorDetail # type: ignore - from ._models import ServiceLevelAgreement # type: ignore - from ._models import ServicesListResult # type: ignore - from ._models import SupportEngineer # type: ignore - from ._models import SupportTicketDetails # type: ignore - from ._models import SupportTicketsListResult # type: ignore - from ._models import TechnicalTicketDetails # type: ignore - from ._models import UpdateContactProfile # type: ignore - from ._models import UpdateSupportTicket # type: ignore +from ._models_py3 import CheckNameAvailabilityInput +from ._models_py3 import CheckNameAvailabilityOutput +from ._models_py3 import CommunicationDetails +from ._models_py3 import CommunicationsListResult +from ._models_py3 import ContactProfile +from ._models_py3 import ExceptionResponse +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationsListResult +from ._models_py3 import ProblemClassification +from ._models_py3 import ProblemClassificationsListResult +from ._models_py3 import QuotaChangeRequest +from ._models_py3 import QuotaTicketDetails +from ._models_py3 import Service +from ._models_py3 import ServiceError +from ._models_py3 import ServiceErrorDetail +from ._models_py3 import ServiceLevelAgreement +from ._models_py3 import ServicesListResult +from ._models_py3 import SupportEngineer +from ._models_py3 import SupportTicketDetails +from ._models_py3 import SupportTicketsListResult +from ._models_py3 import TechnicalTicketDetails +from ._models_py3 import UpdateContactProfile +from ._models_py3 import UpdateSupportTicket + from ._microsoft_support_enums import ( CommunicationDirection, diff --git a/sdk/support/azure-mgmt-support/azure/mgmt/support/models/_microsoft_support_enums.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/models/_microsoft_support_enums.py index dd243534cf75..62c960a2c204 100644 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/models/_microsoft_support_enums.py +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/models/_microsoft_support_enums.py @@ -6,48 +6,33 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class CommunicationDirection(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CommunicationDirection(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Direction of communication. """ INBOUND = "inbound" OUTBOUND = "outbound" -class CommunicationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CommunicationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Communication type. """ WEB = "web" PHONE = "phone" -class PreferredContactMethod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PreferredContactMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Preferred contact method. """ EMAIL = "email" PHONE = "phone" -class SeverityLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SeverityLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """A value that indicates the urgency of the case, which in turn determines the response time according to the service level agreement of the technical support plan you have with Azure. Note: 'Highest critical impact', also known as the 'Emergency - Severe impact' level in the @@ -59,14 +44,14 @@ class SeverityLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CRITICAL = "critical" HIGHESTCRITICALIMPACT = "highestcriticalimpact" -class Status(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Status(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Status to be updated on the ticket. """ OPEN = "open" CLOSED = "closed" -class Type(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Type(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of resource. """ diff --git a/sdk/support/azure-mgmt-support/azure/mgmt/support/models/_models.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/models/_models.py deleted file mode 100644 index 80d9d6bd4902..000000000000 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/models/_models.py +++ /dev/null @@ -1,909 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class CheckNameAvailabilityInput(msrest.serialization.Model): - """Input of CheckNameAvailability API. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The resource name to validate. - :type name: str - :param type: Required. The type of resource. Possible values include: - "Microsoft.Support/supportTickets", "Microsoft.Support/communications". - :type type: str or ~azure.mgmt.support.models.Type - """ - - _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailabilityInput, self).__init__(**kwargs) - self.name = kwargs['name'] - self.type = kwargs['type'] - - -class CheckNameAvailabilityOutput(msrest.serialization.Model): - """Output of check name availability API. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name_available: Indicates whether the name is available. - :vartype name_available: bool - :ivar reason: The reason why the name is not available. - :vartype reason: str - :ivar message: The detailed error message describing why the name is not available. - :vartype message: str - """ - - _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CheckNameAvailabilityOutput, self).__init__(**kwargs) - self.name_available = None - self.reason = None - self.message = None - - -class CommunicationDetails(msrest.serialization.Model): - """Object that represents a Communication resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Id of the resource. - :vartype id: str - :ivar name: Name of the resource. - :vartype name: str - :ivar type: Type of the resource 'Microsoft.Support/communications'. - :vartype type: str - :ivar communication_type: Communication type. Possible values include: "web", "phone". - :vartype communication_type: str or ~azure.mgmt.support.models.CommunicationType - :ivar communication_direction: Direction of communication. Possible values include: "inbound", - "outbound". - :vartype communication_direction: str or ~azure.mgmt.support.models.CommunicationDirection - :param sender: Email address of the sender. This property is required if called by a service - principal. - :type sender: str - :param subject: Subject of the communication. - :type subject: str - :param body: Body of the communication. - :type body: str - :ivar created_date: Time in UTC (ISO 8601 format) when the communication was created. - :vartype created_date: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'communication_type': {'readonly': True}, - 'communication_direction': {'readonly': True}, - 'created_date': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'communication_type': {'key': 'properties.communicationType', 'type': 'str'}, - 'communication_direction': {'key': 'properties.communicationDirection', 'type': 'str'}, - 'sender': {'key': 'properties.sender', 'type': 'str'}, - 'subject': {'key': 'properties.subject', 'type': 'str'}, - 'body': {'key': 'properties.body', 'type': 'str'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(CommunicationDetails, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.communication_type = None - self.communication_direction = None - self.sender = kwargs.get('sender', None) - self.subject = kwargs.get('subject', None) - self.body = kwargs.get('body', None) - self.created_date = None - - -class CommunicationsListResult(msrest.serialization.Model): - """Collection of Communication resources. - - :param value: List of Communication resources. - :type value: list[~azure.mgmt.support.models.CommunicationDetails] - :param next_link: The URI to fetch the next page of Communication resources. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CommunicationDetails]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CommunicationsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ContactProfile(msrest.serialization.Model): - """Contact information associated with the support ticket. - - All required parameters must be populated in order to send to Azure. - - :param first_name: Required. First name. - :type first_name: str - :param last_name: Required. Last name. - :type last_name: str - :param preferred_contact_method: Required. Preferred contact method. Possible values include: - "email", "phone". - :type preferred_contact_method: str or ~azure.mgmt.support.models.PreferredContactMethod - :param primary_email_address: Required. Primary email address. - :type primary_email_address: str - :param additional_email_addresses: Additional email addresses listed will be copied on any - correspondence about the support ticket. - :type additional_email_addresses: list[str] - :param phone_number: Phone number. This is required if preferred contact method is phone. - :type phone_number: str - :param preferred_time_zone: Required. Time zone of the user. This is the name of the time zone - from `Microsoft Time Zone Index Values `_. - :type preferred_time_zone: str - :param country: Required. Country of the user. This is the ISO 3166-1 alpha-3 code. - :type country: str - :param preferred_support_language: Required. Preferred language of support from Azure. Support - languages vary based on the severity you choose for your support ticket. Learn more at `Azure - Severity and responsiveness `_. Use the - standard language-country code. Valid values are 'en-us' for English, 'zh-hans' for Chinese, - 'es-es' for Spanish, 'fr-fr' for French, 'ja-jp' for Japanese, 'ko-kr' for Korean, 'ru-ru' for - Russian, 'pt-br' for Portuguese, 'it-it' for Italian, 'zh-tw' for Chinese and 'de-de' for - German. - :type preferred_support_language: str - """ - - _validation = { - 'first_name': {'required': True}, - 'last_name': {'required': True}, - 'preferred_contact_method': {'required': True}, - 'primary_email_address': {'required': True}, - 'preferred_time_zone': {'required': True}, - 'country': {'required': True}, - 'preferred_support_language': {'required': True}, - } - - _attribute_map = { - 'first_name': {'key': 'firstName', 'type': 'str'}, - 'last_name': {'key': 'lastName', 'type': 'str'}, - 'preferred_contact_method': {'key': 'preferredContactMethod', 'type': 'str'}, - 'primary_email_address': {'key': 'primaryEmailAddress', 'type': 'str'}, - 'additional_email_addresses': {'key': 'additionalEmailAddresses', 'type': '[str]'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - 'preferred_time_zone': {'key': 'preferredTimeZone', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, - 'preferred_support_language': {'key': 'preferredSupportLanguage', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ContactProfile, self).__init__(**kwargs) - self.first_name = kwargs['first_name'] - self.last_name = kwargs['last_name'] - self.preferred_contact_method = kwargs['preferred_contact_method'] - self.primary_email_address = kwargs['primary_email_address'] - self.additional_email_addresses = kwargs.get('additional_email_addresses', None) - self.phone_number = kwargs.get('phone_number', None) - self.preferred_time_zone = kwargs['preferred_time_zone'] - self.country = kwargs['country'] - self.preferred_support_language = kwargs['preferred_support_language'] - - -class ExceptionResponse(msrest.serialization.Model): - """The API error. - - :param error: The API error details. - :type error: ~azure.mgmt.support.models.ServiceError - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ServiceError'}, - } - - def __init__( - self, - **kwargs - ): - super(ExceptionResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class Operation(msrest.serialization.Model): - """The operation supported by Microsoft Support resource provider. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :param display: The object that describes the operation. - :type display: ~azure.mgmt.support.models.OperationDisplay - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.serialization.Model): - """The object that describes the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: The description of the operation. - :vartype description: str - :ivar operation: The action that users can perform, based on their permission level. - :vartype operation: str - :ivar provider: Service provider: Microsoft Support. - :vartype provider: str - :ivar resource: Resource on which the operation is performed. - :vartype resource: str - """ - - _validation = { - 'description': {'readonly': True}, - 'operation': {'readonly': True}, - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.description = None - self.operation = None - self.provider = None - self.resource = None - - -class OperationsListResult(msrest.serialization.Model): - """The list of operations supported by Microsoft Support resource provider. - - :param value: The list of operations supported by Microsoft Support resource provider. - :type value: list[~azure.mgmt.support.models.Operation] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ProblemClassification(msrest.serialization.Model): - """ProblemClassification resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Id of the resource. - :vartype id: str - :ivar name: Name of the resource. - :vartype name: str - :ivar type: Type of the resource 'Microsoft.Support/problemClassification'. - :vartype type: str - :param display_name: Localized name of problem classification. - :type display_name: 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'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProblemClassification, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.display_name = kwargs.get('display_name', None) - - -class ProblemClassificationsListResult(msrest.serialization.Model): - """Collection of ProblemClassification resources. - - :param value: List of ProblemClassification resources. - :type value: list[~azure.mgmt.support.models.ProblemClassification] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ProblemClassification]'}, - } - - def __init__( - self, - **kwargs - ): - super(ProblemClassificationsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class QuotaChangeRequest(msrest.serialization.Model): - """This property is required for providing the region and new quota limits. - - :param region: Region for which the quota increase request is being made. - :type region: str - :param payload: Payload of the quota increase request. - :type payload: str - """ - - _attribute_map = { - 'region': {'key': 'region', 'type': 'str'}, - 'payload': {'key': 'payload', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(QuotaChangeRequest, self).__init__(**kwargs) - self.region = kwargs.get('region', None) - self.payload = kwargs.get('payload', None) - - -class QuotaTicketDetails(msrest.serialization.Model): - """Additional set of information required for quota increase support ticket for certain quota types, e.g.: Virtual machine cores. Get complete details about Quota payload support request along with examples at `Support quota request `_. - - :param quota_change_request_sub_type: Required for certain quota types when there is a sub - type, such as Batch, for which you are requesting a quota increase. - :type quota_change_request_sub_type: str - :param quota_change_request_version: Quota change request version. - :type quota_change_request_version: str - :param quota_change_requests: This property is required for providing the region and new quota - limits. - :type quota_change_requests: list[~azure.mgmt.support.models.QuotaChangeRequest] - """ - - _attribute_map = { - 'quota_change_request_sub_type': {'key': 'quotaChangeRequestSubType', 'type': 'str'}, - 'quota_change_request_version': {'key': 'quotaChangeRequestVersion', 'type': 'str'}, - 'quota_change_requests': {'key': 'quotaChangeRequests', 'type': '[QuotaChangeRequest]'}, - } - - def __init__( - self, - **kwargs - ): - super(QuotaTicketDetails, self).__init__(**kwargs) - self.quota_change_request_sub_type = kwargs.get('quota_change_request_sub_type', None) - self.quota_change_request_version = kwargs.get('quota_change_request_version', None) - self.quota_change_requests = kwargs.get('quota_change_requests', None) - - -class Service(msrest.serialization.Model): - """Object that represents a Service resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Id of the resource. - :vartype id: str - :ivar name: Name of the resource. - :vartype name: str - :ivar type: Type of the resource 'Microsoft.Support/services'. - :vartype type: str - :param display_name: Localized name of the Azure service. - :type display_name: str - :param resource_types: ARM Resource types. - :type resource_types: list[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'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'resource_types': {'key': 'properties.resourceTypes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(Service, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.display_name = kwargs.get('display_name', None) - self.resource_types = kwargs.get('resource_types', None) - - -class ServiceError(msrest.serialization.Model): - """The API error details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param code: The error code. - :type code: str - :param message: The error message. - :type message: str - :param target: The target of the error. - :type target: str - :ivar details: The list of error details. - :vartype details: list[~azure.mgmt.support.models.ServiceErrorDetail] - """ - - _validation = { - 'details': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ServiceErrorDetail]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceError, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.target = kwargs.get('target', None) - self.details = None - - -class ServiceErrorDetail(msrest.serialization.Model): - """The error details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :param target: The target of the error. - :type target: str - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = kwargs.get('target', None) - - -class ServiceLevelAgreement(msrest.serialization.Model): - """Service Level Agreement details for a support ticket. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar start_time: Time in UTC (ISO 8601 format) when the service level agreement starts. - :vartype start_time: ~datetime.datetime - :ivar expiration_time: Time in UTC (ISO 8601 format) when the service level agreement expires. - :vartype expiration_time: ~datetime.datetime - :ivar sla_minutes: Service Level Agreement in minutes. - :vartype sla_minutes: int - """ - - _validation = { - 'start_time': {'readonly': True}, - 'expiration_time': {'readonly': True}, - 'sla_minutes': {'readonly': True}, - } - - _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'expiration_time': {'key': 'expirationTime', 'type': 'iso-8601'}, - 'sla_minutes': {'key': 'slaMinutes', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceLevelAgreement, self).__init__(**kwargs) - self.start_time = None - self.expiration_time = None - self.sla_minutes = None - - -class ServicesListResult(msrest.serialization.Model): - """Collection of Service resources. - - :param value: List of Service resources. - :type value: list[~azure.mgmt.support.models.Service] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Service]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServicesListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class SupportEngineer(msrest.serialization.Model): - """Support engineer information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar email_address: Email address of the Azure Support engineer assigned to the support - ticket. - :vartype email_address: str - """ - - _validation = { - 'email_address': {'readonly': True}, - } - - _attribute_map = { - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SupportEngineer, self).__init__(**kwargs) - self.email_address = None - - -class SupportTicketDetails(msrest.serialization.Model): - """Object that represents SupportTicketDetails resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Id of the resource. - :vartype id: str - :ivar name: Name of the resource. - :vartype name: str - :ivar type: Type of the resource 'Microsoft.Support/supportTickets'. - :vartype type: str - :param support_ticket_id: System generated support ticket Id that is unique. - :type support_ticket_id: str - :param description: Detailed description of the question or issue. - :type description: str - :param problem_classification_id: Each Azure service has its own set of issue categories, also - known as problem classification. This parameter is the unique Id for the type of problem you - are experiencing. - :type problem_classification_id: str - :ivar problem_classification_display_name: Localized name of problem classification. - :vartype problem_classification_display_name: str - :param severity: A value that indicates the urgency of the case, which in turn determines the - response time according to the service level agreement of the technical support plan you have - with Azure. Note: 'Highest critical impact', also known as the 'Emergency - Severe impact' - level in the Azure portal is reserved only for our Premium customers. Possible values include: - "minimal", "moderate", "critical", "highestcriticalimpact". - :type severity: str or ~azure.mgmt.support.models.SeverityLevel - :ivar enrollment_id: Enrollment Id associated with the support ticket. - :vartype enrollment_id: str - :param require24_x7_response: Indicates if this requires a 24x7 response from Azure. - :type require24_x7_response: bool - :param contact_details: Contact information of the user requesting to create a support ticket. - :type contact_details: ~azure.mgmt.support.models.ContactProfile - :param service_level_agreement: Service Level Agreement information for this support ticket. - :type service_level_agreement: ~azure.mgmt.support.models.ServiceLevelAgreement - :param support_engineer: Information about the support engineer working on this support ticket. - :type support_engineer: ~azure.mgmt.support.models.SupportEngineer - :ivar support_plan_type: Support plan type associated with the support ticket. - :vartype support_plan_type: str - :param title: Title of the support ticket. - :type title: str - :param problem_start_time: Time in UTC (ISO 8601 format) when the problem started. - :type problem_start_time: ~datetime.datetime - :param service_id: This is the resource Id of the Azure service resource associated with the - support ticket. - :type service_id: str - :ivar service_display_name: Localized name of the Azure service. - :vartype service_display_name: str - :ivar status: Status of the support ticket. - :vartype status: str - :ivar created_date: Time in UTC (ISO 8601 format) when the support ticket was created. - :vartype created_date: ~datetime.datetime - :ivar modified_date: Time in UTC (ISO 8601 format) when the support ticket was last modified. - :vartype modified_date: ~datetime.datetime - :param technical_ticket_details: Additional ticket details associated with a technical support - ticket request. - :type technical_ticket_details: ~azure.mgmt.support.models.TechnicalTicketDetails - :param quota_ticket_details: Additional ticket details associated with a quota support ticket - request. - :type quota_ticket_details: ~azure.mgmt.support.models.QuotaTicketDetails - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'problem_classification_display_name': {'readonly': True}, - 'enrollment_id': {'readonly': True}, - 'support_plan_type': {'readonly': True}, - 'service_display_name': {'readonly': True}, - 'status': {'readonly': True}, - 'created_date': {'readonly': True}, - 'modified_date': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'support_ticket_id': {'key': 'properties.supportTicketId', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'problem_classification_id': {'key': 'properties.problemClassificationId', 'type': 'str'}, - 'problem_classification_display_name': {'key': 'properties.problemClassificationDisplayName', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'enrollment_id': {'key': 'properties.enrollmentId', 'type': 'str'}, - 'require24_x7_response': {'key': 'properties.require24X7Response', 'type': 'bool'}, - 'contact_details': {'key': 'properties.contactDetails', 'type': 'ContactProfile'}, - 'service_level_agreement': {'key': 'properties.serviceLevelAgreement', 'type': 'ServiceLevelAgreement'}, - 'support_engineer': {'key': 'properties.supportEngineer', 'type': 'SupportEngineer'}, - 'support_plan_type': {'key': 'properties.supportPlanType', 'type': 'str'}, - 'title': {'key': 'properties.title', 'type': 'str'}, - 'problem_start_time': {'key': 'properties.problemStartTime', 'type': 'iso-8601'}, - 'service_id': {'key': 'properties.serviceId', 'type': 'str'}, - 'service_display_name': {'key': 'properties.serviceDisplayName', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'modified_date': {'key': 'properties.modifiedDate', 'type': 'iso-8601'}, - 'technical_ticket_details': {'key': 'properties.technicalTicketDetails', 'type': 'TechnicalTicketDetails'}, - 'quota_ticket_details': {'key': 'properties.quotaTicketDetails', 'type': 'QuotaTicketDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(SupportTicketDetails, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.support_ticket_id = kwargs.get('support_ticket_id', None) - self.description = kwargs.get('description', None) - self.problem_classification_id = kwargs.get('problem_classification_id', None) - self.problem_classification_display_name = None - self.severity = kwargs.get('severity', None) - self.enrollment_id = None - self.require24_x7_response = kwargs.get('require24_x7_response', None) - self.contact_details = kwargs.get('contact_details', None) - self.service_level_agreement = kwargs.get('service_level_agreement', None) - self.support_engineer = kwargs.get('support_engineer', None) - self.support_plan_type = None - self.title = kwargs.get('title', None) - self.problem_start_time = kwargs.get('problem_start_time', None) - self.service_id = kwargs.get('service_id', None) - self.service_display_name = None - self.status = None - self.created_date = None - self.modified_date = None - self.technical_ticket_details = kwargs.get('technical_ticket_details', None) - self.quota_ticket_details = kwargs.get('quota_ticket_details', None) - - -class SupportTicketsListResult(msrest.serialization.Model): - """Object that represents a collection of SupportTicket resources. - - :param value: List of SupportTicket resources. - :type value: list[~azure.mgmt.support.models.SupportTicketDetails] - :param next_link: The URI to fetch the next page of SupportTicket resources. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SupportTicketDetails]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SupportTicketsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class TechnicalTicketDetails(msrest.serialization.Model): - """Additional information for technical support ticket. - - :param resource_id: This is the resource Id of the Azure service resource (For example: A - virtual machine resource or an HDInsight resource) for which the support ticket is created. - :type resource_id: str - """ - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TechnicalTicketDetails, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - - -class UpdateContactProfile(msrest.serialization.Model): - """Contact information associated with the support ticket. - - :param first_name: First name. - :type first_name: str - :param last_name: Last name. - :type last_name: str - :param preferred_contact_method: Preferred contact method. Possible values include: "email", - "phone". - :type preferred_contact_method: str or ~azure.mgmt.support.models.PreferredContactMethod - :param primary_email_address: Primary email address. - :type primary_email_address: str - :param additional_email_addresses: Email addresses listed will be copied on any correspondence - about the support ticket. - :type additional_email_addresses: list[str] - :param phone_number: Phone number. This is required if preferred contact method is phone. - :type phone_number: str - :param preferred_time_zone: Time zone of the user. This is the name of the time zone from - `Microsoft Time Zone Index Values `_. - :type preferred_time_zone: str - :param country: Country of the user. This is the ISO 3166-1 alpha-3 code. - :type country: str - :param preferred_support_language: Preferred language of support from Azure. Support languages - vary based on the severity you choose for your support ticket. Learn more at `Azure Severity - and responsiveness `_. Use the standard - language-country code. Valid values are 'en-us' for English, 'zh-hans' for Chinese, 'es-es' for - Spanish, 'fr-fr' for French, 'ja-jp' for Japanese, 'ko-kr' for Korean, 'ru-ru' for Russian, - 'pt-br' for Portuguese, 'it-it' for Italian, 'zh-tw' for Chinese and 'de-de' for German. - :type preferred_support_language: str - """ - - _attribute_map = { - 'first_name': {'key': 'firstName', 'type': 'str'}, - 'last_name': {'key': 'lastName', 'type': 'str'}, - 'preferred_contact_method': {'key': 'preferredContactMethod', 'type': 'str'}, - 'primary_email_address': {'key': 'primaryEmailAddress', 'type': 'str'}, - 'additional_email_addresses': {'key': 'additionalEmailAddresses', 'type': '[str]'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - 'preferred_time_zone': {'key': 'preferredTimeZone', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, - 'preferred_support_language': {'key': 'preferredSupportLanguage', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateContactProfile, self).__init__(**kwargs) - self.first_name = kwargs.get('first_name', None) - self.last_name = kwargs.get('last_name', None) - self.preferred_contact_method = kwargs.get('preferred_contact_method', None) - self.primary_email_address = kwargs.get('primary_email_address', None) - self.additional_email_addresses = kwargs.get('additional_email_addresses', None) - self.phone_number = kwargs.get('phone_number', None) - self.preferred_time_zone = kwargs.get('preferred_time_zone', None) - self.country = kwargs.get('country', None) - self.preferred_support_language = kwargs.get('preferred_support_language', None) - - -class UpdateSupportTicket(msrest.serialization.Model): - """Updates severity, ticket status, and contact details in the support ticket. - - :param severity: Severity level. Possible values include: "minimal", "moderate", "critical", - "highestcriticalimpact". - :type severity: str or ~azure.mgmt.support.models.SeverityLevel - :param status: Status to be updated on the ticket. Possible values include: "open", "closed". - :type status: str or ~azure.mgmt.support.models.Status - :param contact_details: Contact details to be updated on the support ticket. - :type contact_details: ~azure.mgmt.support.models.UpdateContactProfile - """ - - _attribute_map = { - 'severity': {'key': 'severity', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'contact_details': {'key': 'contactDetails', 'type': 'UpdateContactProfile'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateSupportTicket, self).__init__(**kwargs) - self.severity = kwargs.get('severity', None) - self.status = kwargs.get('status', None) - self.contact_details = kwargs.get('contact_details', None) diff --git a/sdk/support/azure-mgmt-support/azure/mgmt/support/models/_models_py3.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/models/_models_py3.py index 704ea8c58ae4..eca676761eca 100644 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/models/_models_py3.py +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/models/_models_py3.py @@ -20,11 +20,11 @@ class CheckNameAvailabilityInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The resource name to validate. - :type name: str - :param type: Required. The type of resource. Possible values include: + :ivar name: Required. The resource name to validate. + :vartype name: str + :ivar type: Required. The type of resource. Possible values include: "Microsoft.Support/supportTickets", "Microsoft.Support/communications". - :type type: str or ~azure.mgmt.support.models.Type + :vartype type: str or ~azure.mgmt.support.models.Type """ _validation = { @@ -44,6 +44,13 @@ def __init__( type: Union[str, "Type"], **kwargs ): + """ + :keyword name: Required. The resource name to validate. + :paramtype name: str + :keyword type: Required. The type of resource. Possible values include: + "Microsoft.Support/supportTickets", "Microsoft.Support/communications". + :paramtype type: str or ~azure.mgmt.support.models.Type + """ super(CheckNameAvailabilityInput, self).__init__(**kwargs) self.name = name self.type = type @@ -78,6 +85,8 @@ def __init__( self, **kwargs ): + """ + """ super(CheckNameAvailabilityOutput, self).__init__(**kwargs) self.name_available = None self.reason = None @@ -100,13 +109,13 @@ class CommunicationDetails(msrest.serialization.Model): :ivar communication_direction: Direction of communication. Possible values include: "inbound", "outbound". :vartype communication_direction: str or ~azure.mgmt.support.models.CommunicationDirection - :param sender: Email address of the sender. This property is required if called by a service + :ivar sender: Email address of the sender. This property is required if called by a service principal. - :type sender: str - :param subject: Subject of the communication. - :type subject: str - :param body: Body of the communication. - :type body: str + :vartype sender: str + :ivar subject: Subject of the communication. + :vartype subject: str + :ivar body: Body of the communication. + :vartype body: str :ivar created_date: Time in UTC (ISO 8601 format) when the communication was created. :vartype created_date: ~datetime.datetime """ @@ -140,6 +149,15 @@ def __init__( body: Optional[str] = None, **kwargs ): + """ + :keyword sender: Email address of the sender. This property is required if called by a service + principal. + :paramtype sender: str + :keyword subject: Subject of the communication. + :paramtype subject: str + :keyword body: Body of the communication. + :paramtype body: str + """ super(CommunicationDetails, self).__init__(**kwargs) self.id = None self.name = None @@ -155,10 +173,10 @@ def __init__( class CommunicationsListResult(msrest.serialization.Model): """Collection of Communication resources. - :param value: List of Communication resources. - :type value: list[~azure.mgmt.support.models.CommunicationDetails] - :param next_link: The URI to fetch the next page of Communication resources. - :type next_link: str + :ivar value: List of Communication resources. + :vartype value: list[~azure.mgmt.support.models.CommunicationDetails] + :ivar next_link: The URI to fetch the next page of Communication resources. + :vartype next_link: str """ _attribute_map = { @@ -173,6 +191,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Communication resources. + :paramtype value: list[~azure.mgmt.support.models.CommunicationDetails] + :keyword next_link: The URI to fetch the next page of Communication resources. + :paramtype next_link: str + """ super(CommunicationsListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -183,34 +207,34 @@ class ContactProfile(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param first_name: Required. First name. - :type first_name: str - :param last_name: Required. Last name. - :type last_name: str - :param preferred_contact_method: Required. Preferred contact method. Possible values include: + :ivar first_name: Required. First name. + :vartype first_name: str + :ivar last_name: Required. Last name. + :vartype last_name: str + :ivar preferred_contact_method: Required. Preferred contact method. Possible values include: "email", "phone". - :type preferred_contact_method: str or ~azure.mgmt.support.models.PreferredContactMethod - :param primary_email_address: Required. Primary email address. - :type primary_email_address: str - :param additional_email_addresses: Additional email addresses listed will be copied on any + :vartype preferred_contact_method: str or ~azure.mgmt.support.models.PreferredContactMethod + :ivar primary_email_address: Required. Primary email address. + :vartype primary_email_address: str + :ivar additional_email_addresses: Additional email addresses listed will be copied on any correspondence about the support ticket. - :type additional_email_addresses: list[str] - :param phone_number: Phone number. This is required if preferred contact method is phone. - :type phone_number: str - :param preferred_time_zone: Required. Time zone of the user. This is the name of the time zone - from `Microsoft Time Zone Index Values `_. - :type preferred_time_zone: str - :param country: Required. Country of the user. This is the ISO 3166-1 alpha-3 code. - :type country: str - :param preferred_support_language: Required. Preferred language of support from Azure. Support + :vartype additional_email_addresses: list[str] + :ivar phone_number: Phone number. This is required if preferred contact method is phone. + :vartype phone_number: str + :ivar preferred_time_zone: Required. Time zone of the user. This is the name of the time zone + from `Microsoft Time Zone Index Values + `_. + :vartype preferred_time_zone: str + :ivar country: Required. Country of the user. This is the ISO 3166-1 alpha-3 code. + :vartype country: str + :ivar preferred_support_language: Required. Preferred language of support from Azure. Support languages vary based on the severity you choose for your support ticket. Learn more at `Azure Severity and responsiveness `_. Use the standard language-country code. Valid values are 'en-us' for English, 'zh-hans' for Chinese, 'es-es' for Spanish, 'fr-fr' for French, 'ja-jp' for Japanese, 'ko-kr' for Korean, 'ru-ru' for Russian, 'pt-br' for Portuguese, 'it-it' for Italian, 'zh-tw' for Chinese and 'de-de' for German. - :type preferred_support_language: str + :vartype preferred_support_language: str """ _validation = { @@ -249,6 +273,36 @@ def __init__( phone_number: Optional[str] = None, **kwargs ): + """ + :keyword first_name: Required. First name. + :paramtype first_name: str + :keyword last_name: Required. Last name. + :paramtype last_name: str + :keyword preferred_contact_method: Required. Preferred contact method. Possible values include: + "email", "phone". + :paramtype preferred_contact_method: str or ~azure.mgmt.support.models.PreferredContactMethod + :keyword primary_email_address: Required. Primary email address. + :paramtype primary_email_address: str + :keyword additional_email_addresses: Additional email addresses listed will be copied on any + correspondence about the support ticket. + :paramtype additional_email_addresses: list[str] + :keyword phone_number: Phone number. This is required if preferred contact method is phone. + :paramtype phone_number: str + :keyword preferred_time_zone: Required. Time zone of the user. This is the name of the time + zone from `Microsoft Time Zone Index Values + `_. + :paramtype preferred_time_zone: str + :keyword country: Required. Country of the user. This is the ISO 3166-1 alpha-3 code. + :paramtype country: str + :keyword preferred_support_language: Required. Preferred language of support from Azure. + Support languages vary based on the severity you choose for your support ticket. Learn more at + `Azure Severity and responsiveness `_. Use + the standard language-country code. Valid values are 'en-us' for English, 'zh-hans' for + Chinese, 'es-es' for Spanish, 'fr-fr' for French, 'ja-jp' for Japanese, 'ko-kr' for Korean, + 'ru-ru' for Russian, 'pt-br' for Portuguese, 'it-it' for Italian, 'zh-tw' for Chinese and + 'de-de' for German. + :paramtype preferred_support_language: str + """ super(ContactProfile, self).__init__(**kwargs) self.first_name = first_name self.last_name = last_name @@ -264,8 +318,8 @@ def __init__( class ExceptionResponse(msrest.serialization.Model): """The API error. - :param error: The API error details. - :type error: ~azure.mgmt.support.models.ServiceError + :ivar error: The API error details. + :vartype error: ~azure.mgmt.support.models.ServiceError """ _attribute_map = { @@ -278,6 +332,10 @@ def __init__( error: Optional["ServiceError"] = None, **kwargs ): + """ + :keyword error: The API error details. + :paramtype error: ~azure.mgmt.support.models.ServiceError + """ super(ExceptionResponse, self).__init__(**kwargs) self.error = error @@ -289,8 +347,8 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{operation}. :vartype name: str - :param display: The object that describes the operation. - :type display: ~azure.mgmt.support.models.OperationDisplay + :ivar display: The object that describes the operation. + :vartype display: ~azure.mgmt.support.models.OperationDisplay """ _validation = { @@ -308,6 +366,10 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword display: The object that describes the operation. + :paramtype display: ~azure.mgmt.support.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = display @@ -346,6 +408,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.description = None self.operation = None @@ -356,8 +420,8 @@ def __init__( class OperationsListResult(msrest.serialization.Model): """The list of operations supported by Microsoft Support resource provider. - :param value: The list of operations supported by Microsoft Support resource provider. - :type value: list[~azure.mgmt.support.models.Operation] + :ivar value: The list of operations supported by Microsoft Support resource provider. + :vartype value: list[~azure.mgmt.support.models.Operation] """ _attribute_map = { @@ -370,6 +434,10 @@ def __init__( value: Optional[List["Operation"]] = None, **kwargs ): + """ + :keyword value: The list of operations supported by Microsoft Support resource provider. + :paramtype value: list[~azure.mgmt.support.models.Operation] + """ super(OperationsListResult, self).__init__(**kwargs) self.value = value @@ -385,8 +453,8 @@ class ProblemClassification(msrest.serialization.Model): :vartype name: str :ivar type: Type of the resource 'Microsoft.Support/problemClassification'. :vartype type: str - :param display_name: Localized name of problem classification. - :type display_name: str + :ivar display_name: Localized name of problem classification. + :vartype display_name: str """ _validation = { @@ -408,6 +476,10 @@ def __init__( display_name: Optional[str] = None, **kwargs ): + """ + :keyword display_name: Localized name of problem classification. + :paramtype display_name: str + """ super(ProblemClassification, self).__init__(**kwargs) self.id = None self.name = None @@ -418,8 +490,8 @@ def __init__( class ProblemClassificationsListResult(msrest.serialization.Model): """Collection of ProblemClassification resources. - :param value: List of ProblemClassification resources. - :type value: list[~azure.mgmt.support.models.ProblemClassification] + :ivar value: List of ProblemClassification resources. + :vartype value: list[~azure.mgmt.support.models.ProblemClassification] """ _attribute_map = { @@ -432,6 +504,10 @@ def __init__( value: Optional[List["ProblemClassification"]] = None, **kwargs ): + """ + :keyword value: List of ProblemClassification resources. + :paramtype value: list[~azure.mgmt.support.models.ProblemClassification] + """ super(ProblemClassificationsListResult, self).__init__(**kwargs) self.value = value @@ -439,10 +515,10 @@ def __init__( class QuotaChangeRequest(msrest.serialization.Model): """This property is required for providing the region and new quota limits. - :param region: Region for which the quota increase request is being made. - :type region: str - :param payload: Payload of the quota increase request. - :type payload: str + :ivar region: Region for which the quota increase request is being made. + :vartype region: str + :ivar payload: Payload of the quota increase request. + :vartype payload: str """ _attribute_map = { @@ -457,6 +533,12 @@ def __init__( payload: Optional[str] = None, **kwargs ): + """ + :keyword region: Region for which the quota increase request is being made. + :paramtype region: str + :keyword payload: Payload of the quota increase request. + :paramtype payload: str + """ super(QuotaChangeRequest, self).__init__(**kwargs) self.region = region self.payload = payload @@ -465,14 +547,14 @@ def __init__( class QuotaTicketDetails(msrest.serialization.Model): """Additional set of information required for quota increase support ticket for certain quota types, e.g.: Virtual machine cores. Get complete details about Quota payload support request along with examples at `Support quota request `_. - :param quota_change_request_sub_type: Required for certain quota types when there is a sub - type, such as Batch, for which you are requesting a quota increase. - :type quota_change_request_sub_type: str - :param quota_change_request_version: Quota change request version. - :type quota_change_request_version: str - :param quota_change_requests: This property is required for providing the region and new quota + :ivar quota_change_request_sub_type: Required for certain quota types when there is a sub type, + such as Batch, for which you are requesting a quota increase. + :vartype quota_change_request_sub_type: str + :ivar quota_change_request_version: Quota change request version. + :vartype quota_change_request_version: str + :ivar quota_change_requests: This property is required for providing the region and new quota limits. - :type quota_change_requests: list[~azure.mgmt.support.models.QuotaChangeRequest] + :vartype quota_change_requests: list[~azure.mgmt.support.models.QuotaChangeRequest] """ _attribute_map = { @@ -489,6 +571,16 @@ def __init__( quota_change_requests: Optional[List["QuotaChangeRequest"]] = None, **kwargs ): + """ + :keyword quota_change_request_sub_type: Required for certain quota types when there is a sub + type, such as Batch, for which you are requesting a quota increase. + :paramtype quota_change_request_sub_type: str + :keyword quota_change_request_version: Quota change request version. + :paramtype quota_change_request_version: str + :keyword quota_change_requests: This property is required for providing the region and new + quota limits. + :paramtype quota_change_requests: list[~azure.mgmt.support.models.QuotaChangeRequest] + """ super(QuotaTicketDetails, self).__init__(**kwargs) self.quota_change_request_sub_type = quota_change_request_sub_type self.quota_change_request_version = quota_change_request_version @@ -506,10 +598,10 @@ class Service(msrest.serialization.Model): :vartype name: str :ivar type: Type of the resource 'Microsoft.Support/services'. :vartype type: str - :param display_name: Localized name of the Azure service. - :type display_name: str - :param resource_types: ARM Resource types. - :type resource_types: list[str] + :ivar display_name: Localized name of the Azure service. + :vartype display_name: str + :ivar resource_types: ARM Resource types. + :vartype resource_types: list[str] """ _validation = { @@ -533,6 +625,12 @@ def __init__( resource_types: Optional[List[str]] = None, **kwargs ): + """ + :keyword display_name: Localized name of the Azure service. + :paramtype display_name: str + :keyword resource_types: ARM Resource types. + :paramtype resource_types: list[str] + """ super(Service, self).__init__(**kwargs) self.id = None self.name = None @@ -546,12 +644,12 @@ class ServiceError(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param code: The error code. - :type code: str - :param message: The error message. - :type message: str - :param target: The target of the error. - :type target: str + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The target of the error. + :vartype target: str :ivar details: The list of error details. :vartype details: list[~azure.mgmt.support.models.ServiceErrorDetail] """ @@ -575,6 +673,14 @@ def __init__( target: Optional[str] = None, **kwargs ): + """ + :keyword code: The error code. + :paramtype code: str + :keyword message: The error message. + :paramtype message: str + :keyword target: The target of the error. + :paramtype target: str + """ super(ServiceError, self).__init__(**kwargs) self.code = code self.message = message @@ -591,8 +697,8 @@ class ServiceErrorDetail(msrest.serialization.Model): :vartype code: str :ivar message: The error message. :vartype message: str - :param target: The target of the error. - :type target: str + :ivar target: The target of the error. + :vartype target: str """ _validation = { @@ -612,6 +718,10 @@ def __init__( target: Optional[str] = None, **kwargs ): + """ + :keyword target: The target of the error. + :paramtype target: str + """ super(ServiceErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -647,6 +757,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServiceLevelAgreement, self).__init__(**kwargs) self.start_time = None self.expiration_time = None @@ -656,8 +768,8 @@ def __init__( class ServicesListResult(msrest.serialization.Model): """Collection of Service resources. - :param value: List of Service resources. - :type value: list[~azure.mgmt.support.models.Service] + :ivar value: List of Service resources. + :vartype value: list[~azure.mgmt.support.models.Service] """ _attribute_map = { @@ -670,6 +782,10 @@ def __init__( value: Optional[List["Service"]] = None, **kwargs ): + """ + :keyword value: List of Service resources. + :paramtype value: list[~azure.mgmt.support.models.Service] + """ super(ServicesListResult, self).__init__(**kwargs) self.value = value @@ -696,6 +812,8 @@ def __init__( self, **kwargs ): + """ + """ super(SupportEngineer, self).__init__(**kwargs) self.email_address = None @@ -711,41 +829,41 @@ class SupportTicketDetails(msrest.serialization.Model): :vartype name: str :ivar type: Type of the resource 'Microsoft.Support/supportTickets'. :vartype type: str - :param support_ticket_id: System generated support ticket Id that is unique. - :type support_ticket_id: str - :param description: Detailed description of the question or issue. - :type description: str - :param problem_classification_id: Each Azure service has its own set of issue categories, also + :ivar support_ticket_id: System generated support ticket Id that is unique. + :vartype support_ticket_id: str + :ivar description: Detailed description of the question or issue. + :vartype description: str + :ivar problem_classification_id: Each Azure service has its own set of issue categories, also known as problem classification. This parameter is the unique Id for the type of problem you are experiencing. - :type problem_classification_id: str + :vartype problem_classification_id: str :ivar problem_classification_display_name: Localized name of problem classification. :vartype problem_classification_display_name: str - :param severity: A value that indicates the urgency of the case, which in turn determines the + :ivar severity: A value that indicates the urgency of the case, which in turn determines the response time according to the service level agreement of the technical support plan you have with Azure. Note: 'Highest critical impact', also known as the 'Emergency - Severe impact' level in the Azure portal is reserved only for our Premium customers. Possible values include: "minimal", "moderate", "critical", "highestcriticalimpact". - :type severity: str or ~azure.mgmt.support.models.SeverityLevel + :vartype severity: str or ~azure.mgmt.support.models.SeverityLevel :ivar enrollment_id: Enrollment Id associated with the support ticket. :vartype enrollment_id: str - :param require24_x7_response: Indicates if this requires a 24x7 response from Azure. - :type require24_x7_response: bool - :param contact_details: Contact information of the user requesting to create a support ticket. - :type contact_details: ~azure.mgmt.support.models.ContactProfile - :param service_level_agreement: Service Level Agreement information for this support ticket. - :type service_level_agreement: ~azure.mgmt.support.models.ServiceLevelAgreement - :param support_engineer: Information about the support engineer working on this support ticket. - :type support_engineer: ~azure.mgmt.support.models.SupportEngineer + :ivar require24_x7_response: Indicates if this requires a 24x7 response from Azure. + :vartype require24_x7_response: bool + :ivar contact_details: Contact information of the user requesting to create a support ticket. + :vartype contact_details: ~azure.mgmt.support.models.ContactProfile + :ivar service_level_agreement: Service Level Agreement information for this support ticket. + :vartype service_level_agreement: ~azure.mgmt.support.models.ServiceLevelAgreement + :ivar support_engineer: Information about the support engineer working on this support ticket. + :vartype support_engineer: ~azure.mgmt.support.models.SupportEngineer :ivar support_plan_type: Support plan type associated with the support ticket. :vartype support_plan_type: str - :param title: Title of the support ticket. - :type title: str - :param problem_start_time: Time in UTC (ISO 8601 format) when the problem started. - :type problem_start_time: ~datetime.datetime - :param service_id: This is the resource Id of the Azure service resource associated with the + :ivar title: Title of the support ticket. + :vartype title: str + :ivar problem_start_time: Time in UTC (ISO 8601 format) when the problem started. + :vartype problem_start_time: ~datetime.datetime + :ivar service_id: This is the resource Id of the Azure service resource associated with the support ticket. - :type service_id: str + :vartype service_id: str :ivar service_display_name: Localized name of the Azure service. :vartype service_display_name: str :ivar status: Status of the support ticket. @@ -754,12 +872,12 @@ class SupportTicketDetails(msrest.serialization.Model): :vartype created_date: ~datetime.datetime :ivar modified_date: Time in UTC (ISO 8601 format) when the support ticket was last modified. :vartype modified_date: ~datetime.datetime - :param technical_ticket_details: Additional ticket details associated with a technical support + :ivar technical_ticket_details: Additional ticket details associated with a technical support ticket request. - :type technical_ticket_details: ~azure.mgmt.support.models.TechnicalTicketDetails - :param quota_ticket_details: Additional ticket details associated with a quota support ticket + :vartype technical_ticket_details: ~azure.mgmt.support.models.TechnicalTicketDetails + :ivar quota_ticket_details: Additional ticket details associated with a quota support ticket request. - :type quota_ticket_details: ~azure.mgmt.support.models.QuotaTicketDetails + :vartype quota_ticket_details: ~azure.mgmt.support.models.QuotaTicketDetails """ _validation = { @@ -819,6 +937,45 @@ def __init__( quota_ticket_details: Optional["QuotaTicketDetails"] = None, **kwargs ): + """ + :keyword support_ticket_id: System generated support ticket Id that is unique. + :paramtype support_ticket_id: str + :keyword description: Detailed description of the question or issue. + :paramtype description: str + :keyword problem_classification_id: Each Azure service has its own set of issue categories, + also known as problem classification. This parameter is the unique Id for the type of problem + you are experiencing. + :paramtype problem_classification_id: str + :keyword severity: A value that indicates the urgency of the case, which in turn determines the + response time according to the service level agreement of the technical support plan you have + with Azure. Note: 'Highest critical impact', also known as the 'Emergency - Severe impact' + level in the Azure portal is reserved only for our Premium customers. Possible values include: + "minimal", "moderate", "critical", "highestcriticalimpact". + :paramtype severity: str or ~azure.mgmt.support.models.SeverityLevel + :keyword require24_x7_response: Indicates if this requires a 24x7 response from Azure. + :paramtype require24_x7_response: bool + :keyword contact_details: Contact information of the user requesting to create a support + ticket. + :paramtype contact_details: ~azure.mgmt.support.models.ContactProfile + :keyword service_level_agreement: Service Level Agreement information for this support ticket. + :paramtype service_level_agreement: ~azure.mgmt.support.models.ServiceLevelAgreement + :keyword support_engineer: Information about the support engineer working on this support + ticket. + :paramtype support_engineer: ~azure.mgmt.support.models.SupportEngineer + :keyword title: Title of the support ticket. + :paramtype title: str + :keyword problem_start_time: Time in UTC (ISO 8601 format) when the problem started. + :paramtype problem_start_time: ~datetime.datetime + :keyword service_id: This is the resource Id of the Azure service resource associated with the + support ticket. + :paramtype service_id: str + :keyword technical_ticket_details: Additional ticket details associated with a technical + support ticket request. + :paramtype technical_ticket_details: ~azure.mgmt.support.models.TechnicalTicketDetails + :keyword quota_ticket_details: Additional ticket details associated with a quota support ticket + request. + :paramtype quota_ticket_details: ~azure.mgmt.support.models.QuotaTicketDetails + """ super(SupportTicketDetails, self).__init__(**kwargs) self.id = None self.name = None @@ -848,10 +1005,10 @@ def __init__( class SupportTicketsListResult(msrest.serialization.Model): """Object that represents a collection of SupportTicket resources. - :param value: List of SupportTicket resources. - :type value: list[~azure.mgmt.support.models.SupportTicketDetails] - :param next_link: The URI to fetch the next page of SupportTicket resources. - :type next_link: str + :ivar value: List of SupportTicket resources. + :vartype value: list[~azure.mgmt.support.models.SupportTicketDetails] + :ivar next_link: The URI to fetch the next page of SupportTicket resources. + :vartype next_link: str """ _attribute_map = { @@ -866,6 +1023,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of SupportTicket resources. + :paramtype value: list[~azure.mgmt.support.models.SupportTicketDetails] + :keyword next_link: The URI to fetch the next page of SupportTicket resources. + :paramtype next_link: str + """ super(SupportTicketsListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -874,9 +1037,9 @@ def __init__( class TechnicalTicketDetails(msrest.serialization.Model): """Additional information for technical support ticket. - :param resource_id: This is the resource Id of the Azure service resource (For example: A + :ivar resource_id: This is the resource Id of the Azure service resource (For example: A virtual machine resource or an HDInsight resource) for which the support ticket is created. - :type resource_id: str + :vartype resource_id: str """ _attribute_map = { @@ -889,6 +1052,11 @@ def __init__( resource_id: Optional[str] = None, **kwargs ): + """ + :keyword resource_id: This is the resource Id of the Azure service resource (For example: A + virtual machine resource or an HDInsight resource) for which the support ticket is created. + :paramtype resource_id: str + """ super(TechnicalTicketDetails, self).__init__(**kwargs) self.resource_id = resource_id @@ -896,33 +1064,33 @@ def __init__( class UpdateContactProfile(msrest.serialization.Model): """Contact information associated with the support ticket. - :param first_name: First name. - :type first_name: str - :param last_name: Last name. - :type last_name: str - :param preferred_contact_method: Preferred contact method. Possible values include: "email", + :ivar first_name: First name. + :vartype first_name: str + :ivar last_name: Last name. + :vartype last_name: str + :ivar preferred_contact_method: Preferred contact method. Possible values include: "email", "phone". - :type preferred_contact_method: str or ~azure.mgmt.support.models.PreferredContactMethod - :param primary_email_address: Primary email address. - :type primary_email_address: str - :param additional_email_addresses: Email addresses listed will be copied on any correspondence + :vartype preferred_contact_method: str or ~azure.mgmt.support.models.PreferredContactMethod + :ivar primary_email_address: Primary email address. + :vartype primary_email_address: str + :ivar additional_email_addresses: Email addresses listed will be copied on any correspondence about the support ticket. - :type additional_email_addresses: list[str] - :param phone_number: Phone number. This is required if preferred contact method is phone. - :type phone_number: str - :param preferred_time_zone: Time zone of the user. This is the name of the time zone from - `Microsoft Time Zone Index Values `_. - :type preferred_time_zone: str - :param country: Country of the user. This is the ISO 3166-1 alpha-3 code. - :type country: str - :param preferred_support_language: Preferred language of support from Azure. Support languages + :vartype additional_email_addresses: list[str] + :ivar phone_number: Phone number. This is required if preferred contact method is phone. + :vartype phone_number: str + :ivar preferred_time_zone: Time zone of the user. This is the name of the time zone from + `Microsoft Time Zone Index Values + `_. + :vartype preferred_time_zone: str + :ivar country: Country of the user. This is the ISO 3166-1 alpha-3 code. + :vartype country: str + :ivar preferred_support_language: Preferred language of support from Azure. Support languages vary based on the severity you choose for your support ticket. Learn more at `Azure Severity and responsiveness `_. Use the standard language-country code. Valid values are 'en-us' for English, 'zh-hans' for Chinese, 'es-es' for Spanish, 'fr-fr' for French, 'ja-jp' for Japanese, 'ko-kr' for Korean, 'ru-ru' for Russian, 'pt-br' for Portuguese, 'it-it' for Italian, 'zh-tw' for Chinese and 'de-de' for German. - :type preferred_support_language: str + :vartype preferred_support_language: str """ _attribute_map = { @@ -951,6 +1119,36 @@ def __init__( preferred_support_language: Optional[str] = None, **kwargs ): + """ + :keyword first_name: First name. + :paramtype first_name: str + :keyword last_name: Last name. + :paramtype last_name: str + :keyword preferred_contact_method: Preferred contact method. Possible values include: "email", + "phone". + :paramtype preferred_contact_method: str or ~azure.mgmt.support.models.PreferredContactMethod + :keyword primary_email_address: Primary email address. + :paramtype primary_email_address: str + :keyword additional_email_addresses: Email addresses listed will be copied on any + correspondence about the support ticket. + :paramtype additional_email_addresses: list[str] + :keyword phone_number: Phone number. This is required if preferred contact method is phone. + :paramtype phone_number: str + :keyword preferred_time_zone: Time zone of the user. This is the name of the time zone from + `Microsoft Time Zone Index Values + `_. + :paramtype preferred_time_zone: str + :keyword country: Country of the user. This is the ISO 3166-1 alpha-3 code. + :paramtype country: str + :keyword preferred_support_language: Preferred language of support from Azure. Support + languages vary based on the severity you choose for your support ticket. Learn more at `Azure + Severity and responsiveness `_. Use the + standard language-country code. Valid values are 'en-us' for English, 'zh-hans' for Chinese, + 'es-es' for Spanish, 'fr-fr' for French, 'ja-jp' for Japanese, 'ko-kr' for Korean, 'ru-ru' for + Russian, 'pt-br' for Portuguese, 'it-it' for Italian, 'zh-tw' for Chinese and 'de-de' for + German. + :paramtype preferred_support_language: str + """ super(UpdateContactProfile, self).__init__(**kwargs) self.first_name = first_name self.last_name = last_name @@ -966,13 +1164,13 @@ def __init__( class UpdateSupportTicket(msrest.serialization.Model): """Updates severity, ticket status, and contact details in the support ticket. - :param severity: Severity level. Possible values include: "minimal", "moderate", "critical", + :ivar severity: Severity level. Possible values include: "minimal", "moderate", "critical", "highestcriticalimpact". - :type severity: str or ~azure.mgmt.support.models.SeverityLevel - :param status: Status to be updated on the ticket. Possible values include: "open", "closed". - :type status: str or ~azure.mgmt.support.models.Status - :param contact_details: Contact details to be updated on the support ticket. - :type contact_details: ~azure.mgmt.support.models.UpdateContactProfile + :vartype severity: str or ~azure.mgmt.support.models.SeverityLevel + :ivar status: Status to be updated on the ticket. Possible values include: "open", "closed". + :vartype status: str or ~azure.mgmt.support.models.Status + :ivar contact_details: Contact details to be updated on the support ticket. + :vartype contact_details: ~azure.mgmt.support.models.UpdateContactProfile """ _attribute_map = { @@ -989,6 +1187,15 @@ def __init__( contact_details: Optional["UpdateContactProfile"] = None, **kwargs ): + """ + :keyword severity: Severity level. Possible values include: "minimal", "moderate", "critical", + "highestcriticalimpact". + :paramtype severity: str or ~azure.mgmt.support.models.SeverityLevel + :keyword status: Status to be updated on the ticket. Possible values include: "open", "closed". + :paramtype status: str or ~azure.mgmt.support.models.Status + :keyword contact_details: Contact details to be updated on the support ticket. + :paramtype contact_details: ~azure.mgmt.support.models.UpdateContactProfile + """ super(UpdateSupportTicket, self).__init__(**kwargs) self.severity = severity self.status = status diff --git a/sdk/support/azure-mgmt-support/azure/mgmt/support/operations/_communications_operations.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/operations/_communications_operations.py index e434a0ce0739..9ec4f0b2c14b 100644 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/operations/_communications_operations.py +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/operations/_communications_operations.py @@ -5,25 +5,189 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_check_name_availability_request( + support_ticket_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}/checkNameAvailability') + path_format_arguments = { + "supportTicketName": _SERIALIZER.url("support_ticket_name", support_ticket_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + support_ticket_name: str, + subscription_id: str, + *, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}/communications') + path_format_arguments = { + "supportTicketName": _SERIALIZER.url("support_ticket_name", support_ticket_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + support_ticket_name: str, + communication_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}/communications/{communicationName}') + path_format_arguments = { + "supportTicketName": _SERIALIZER.url("support_ticket_name", support_ticket_name, 'str'), + "communicationName": _SERIALIZER.url("communication_name", communication_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request_initial( + support_ticket_name: str, + communication_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}/communications/{communicationName}') + path_format_arguments = { + "supportTicketName": _SERIALIZER.url("support_ticket_name", support_ticket_name, 'str'), + "communicationName": _SERIALIZER.url("communication_name", communication_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class CommunicationsOperations(object): """CommunicationsOperations operations. @@ -47,13 +211,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def check_name_availability( self, - support_ticket_name, # type: str - check_name_availability_input, # type: "_models.CheckNameAvailabilityInput" - **kwargs # type: Any - ): - # type: (...) -> "_models.CheckNameAvailabilityOutput" + support_ticket_name: str, + check_name_availability_input: "_models.CheckNameAvailabilityInput", + **kwargs: Any + ) -> "_models.CheckNameAvailabilityOutput": """Check the availability of a resource name. This API should be used to check the uniqueness of the name for adding a new communication to the support ticket. @@ -71,37 +235,27 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'supportTicketName': self._serialize.url("support_ticket_name", support_ticket_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(check_name_availability_input, 'CheckNameAvailabilityInput') + + request = build_check_name_availability_request( + support_ticket_name=support_ticket_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(check_name_availability_input, 'CheckNameAvailabilityInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ExceptionResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityOutput', pipeline_response) @@ -110,16 +264,18 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}/checkNameAvailability'} # type: ignore + + @distributed_trace def list( self, - support_ticket_name, # type: str - top=None, # type: Optional[int] - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.CommunicationsListResult"] + support_ticket_name: str, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.CommunicationsListResult"]: """Lists all communications (attachments not included) for a support ticket. :code:`
`
You can also filter support ticket communications by *CreatedDate* or *CommunicationType* using the $filter parameter. The only type of communication supported today is *Web*. Output will be @@ -138,7 +294,8 @@ def list( CommunicationType and CreatedDate filters by Logical And ('and') operator. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CommunicationsListResult or the result of cls(response) + :return: An iterator like instance of either CommunicationsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.support.models.CommunicationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -147,39 +304,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'supportTicketName': self._serialize.url("support_ticket_name", support_ticket_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + support_ticket_name=support_ticket_name, + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + support_ticket_name=support_ticket_name, + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('CommunicationsListResult', pipeline_response) + deserialized = self._deserialize("CommunicationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -192,24 +345,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ExceptionResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}/communications'} # type: ignore + @distributed_trace def get( self, - support_ticket_name, # type: str - communication_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CommunicationDetails" + support_ticket_name: str, + communication_name: str, + **kwargs: Any + ) -> "_models.CommunicationDetails": """Returns communication details for a support ticket. :param support_ticket_name: Support ticket name. @@ -226,33 +380,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'supportTicketName': self._serialize.url("support_ticket_name", support_ticket_name, 'str'), - 'communicationName': self._serialize.url("communication_name", communication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + support_ticket_name=support_ticket_name, + communication_name=communication_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ExceptionResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CommunicationDetails', pipeline_response) @@ -261,54 +405,44 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}/communications/{communicationName}'} # type: ignore + def _create_initial( self, - support_ticket_name, # type: str - communication_name, # type: str - create_communication_parameters, # type: "_models.CommunicationDetails" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.CommunicationDetails"] + support_ticket_name: str, + communication_name: str, + create_communication_parameters: "_models.CommunicationDetails", + **kwargs: Any + ) -> Optional["_models.CommunicationDetails"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.CommunicationDetails"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'supportTicketName': self._serialize.url("support_ticket_name", support_ticket_name, 'str'), - 'communicationName': self._serialize.url("communication_name", communication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(create_communication_parameters, 'CommunicationDetails') + + request = build_create_request_initial( + support_ticket_name=support_ticket_name, + communication_name=communication_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_communication_parameters, 'CommunicationDetails') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ExceptionResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -318,16 +452,18 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}/communications/{communicationName}'} # type: ignore + + @distributed_trace def begin_create( self, - support_ticket_name, # type: str - communication_name, # type: str - create_communication_parameters, # type: "_models.CommunicationDetails" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.CommunicationDetails"] + support_ticket_name: str, + communication_name: str, + create_communication_parameters: "_models.CommunicationDetails", + **kwargs: Any + ) -> LROPoller["_models.CommunicationDetails"]: """Adds a new customer communication to an Azure support ticket. :param support_ticket_name: Support ticket name. @@ -338,15 +474,19 @@ def begin_create( :type create_communication_parameters: ~azure.mgmt.support.models.CommunicationDetails :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: True for ARMPolling, False for no polling, or a - polling object for 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 CommunicationDetails 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 CommunicationDetails or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.support.models.CommunicationDetails] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunicationDetails"] lro_delay = kwargs.pop( 'polling_interval', @@ -358,27 +498,21 @@ def begin_create( support_ticket_name=support_ticket_name, communication_name=communication_name, create_communication_parameters=create_communication_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('CommunicationDetails', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'supportTicketName': self._serialize.url("support_ticket_name", support_ticket_name, 'str'), - 'communicationName': self._serialize.url("communication_name", communication_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -390,4 +524,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}/communications/{communicationName}'} # type: ignore diff --git a/sdk/support/azure-mgmt-support/azure/mgmt/support/operations/_operations.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/operations/_operations.py index 51255a98dcb4..cb8699bb7a5d 100644 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/operations/_operations.py +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/operations/_operations.py @@ -5,23 +5,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Support/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,15 +72,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationsListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationsListResult"]: """This lists all the available Microsoft Support REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsListResult or the result of cls(response) + :return: An iterator like instance of either OperationsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.support.models.OperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -62,30 +90,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsListResult', pipeline_response) + deserialized = self._deserialize("OperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +123,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ExceptionResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/support/azure-mgmt-support/azure/mgmt/support/operations/_problem_classifications_operations.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/operations/_problem_classifications_operations.py index f8871b516c67..5156868892e6 100644 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/operations/_problem_classifications_operations.py +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/operations/_problem_classifications_operations.py @@ -5,23 +5,89 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + service_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Support/services/{serviceName}/problemClassifications') + path_format_arguments = { + "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + service_name: str, + problem_classification_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Support/services/{serviceName}/problemClassifications/{problemClassificationName}') + path_format_arguments = { + "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + "problemClassificationName": _SERIALIZER.url("problem_classification_name", problem_classification_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ProblemClassificationsOperations(object): """ProblemClassificationsOperations operations. @@ -45,12 +111,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProblemClassificationsListResult"] + service_name: str, + **kwargs: Any + ) -> Iterable["_models.ProblemClassificationsListResult"]: """Lists all the problem classifications (categories) available for a specific Azure service. Always use the service and problem classifications obtained programmatically. This practice ensures that you always have the most recent set of service and problem classification Ids. @@ -59,8 +125,10 @@ def list( retrieved. :type service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProblemClassificationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.support.models.ProblemClassificationsListResult] + :return: An iterator like instance of either ProblemClassificationsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.support.models.ProblemClassificationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProblemClassificationsListResult"] @@ -68,34 +136,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + service_name=service_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + service_name=service_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ProblemClassificationsListResult', pipeline_response) + deserialized = self._deserialize("ProblemClassificationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,24 +171,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ExceptionResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/providers/Microsoft.Support/services/{serviceName}/problemClassifications'} # type: ignore + @distributed_trace def get( self, - service_name, # type: str - problem_classification_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ProblemClassification" + service_name: str, + problem_classification_name: str, + **kwargs: Any + ) -> "_models.ProblemClassification": """Get problem classification details for a specific Azure service. :param service_name: Name of the Azure service available for support. @@ -142,32 +206,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'serviceName': self._serialize.url("service_name", service_name, 'str'), - 'problemClassificationName': self._serialize.url("problem_classification_name", problem_classification_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 = build_get_request( + service_name=service_name, + problem_classification_name=problem_classification_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ExceptionResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ProblemClassification', pipeline_response) @@ -176,4 +230,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Support/services/{serviceName}/problemClassifications/{problemClassificationName}'} # type: ignore + diff --git a/sdk/support/azure-mgmt-support/azure/mgmt/support/operations/_services_operations.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/operations/_services_operations.py index 4cd3b2ad61a6..4dcac0829f1e 100644 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/operations/_services_operations.py +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/operations/_services_operations.py @@ -5,23 +5,81 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Support/services') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + service_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Support/services/{serviceName}') + path_format_arguments = { + "serviceName": _SERIALIZER.url("service_name", service_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ServicesOperations(object): """ServicesOperations operations. @@ -45,11 +103,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ServicesListResult"] + **kwargs: Any + ) -> Iterable["_models.ServicesListResult"]: """Lists all the Azure services available for support ticket creation. For **Technical** issues, select the Service Id that maps to the Azure service/product as displayed in the **Services** drop-down list on the Azure portal's `New support request @@ -68,30 +126,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ServicesListResult', pipeline_response) + deserialized = self._deserialize("ServicesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -104,23 +159,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ExceptionResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/providers/Microsoft.Support/services'} # type: ignore + @distributed_trace def get( self, - service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Service" + service_name: str, + **kwargs: Any + ) -> "_models.Service": """Gets a specific Azure service for support ticket creation. :param service_name: Name of the Azure service. @@ -135,31 +191,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - accept = "application/json" - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - '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 = build_get_request( + service_name=service_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ExceptionResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Service', pipeline_response) @@ -168,4 +214,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Support/services/{serviceName}'} # type: ignore + diff --git a/sdk/support/azure-mgmt-support/azure/mgmt/support/operations/_support_tickets_operations.py b/sdk/support/azure-mgmt-support/azure/mgmt/support/operations/_support_tickets_operations.py index b15abbd63394..140bcfa5582c 100644 --- a/sdk/support/azure-mgmt-support/azure/mgmt/support/operations/_support_tickets_operations.py +++ b/sdk/support/azure-mgmt-support/azure/mgmt/support/operations/_support_tickets_operations.py @@ -5,25 +5,223 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Support/checkNameAvailability') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + *, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + support_ticket_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}') + path_format_arguments = { + "supportTicketName": _SERIALIZER.url("support_ticket_name", support_ticket_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + support_ticket_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}') + path_format_arguments = { + "supportTicketName": _SERIALIZER.url("support_ticket_name", support_ticket_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_create_request_initial( + support_ticket_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}') + path_format_arguments = { + "supportTicketName": _SERIALIZER.url("support_ticket_name", support_ticket_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class SupportTicketsOperations(object): """SupportTicketsOperations operations. @@ -47,12 +245,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def check_name_availability( self, - check_name_availability_input, # type: "_models.CheckNameAvailabilityInput" - **kwargs # type: Any - ): - # type: (...) -> "_models.CheckNameAvailabilityOutput" + check_name_availability_input: "_models.CheckNameAvailabilityInput", + **kwargs: Any + ) -> "_models.CheckNameAvailabilityOutput": """Check the availability of a resource name. This API should be used to check the uniqueness of the name for support ticket creation for the selected subscription. @@ -68,36 +266,26 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(check_name_availability_input, 'CheckNameAvailabilityInput') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(check_name_availability_input, 'CheckNameAvailabilityInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ExceptionResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckNameAvailabilityOutput', pipeline_response) @@ -106,15 +294,17 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/checkNameAvailability'} # type: ignore + + @distributed_trace def list( self, - top=None, # type: Optional[int] - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SupportTicketsListResult"] + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.SupportTicketsListResult"]: """Lists all the support tickets for an Azure subscription. You can also filter the support tickets by *Status* or *CreatedDate* using the $filter parameter. Output will be a paged result with *nextLink*\ , using which you can retrieve the next set of support tickets. @@ -130,7 +320,8 @@ def list( combine them using the logical 'AND'. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SupportTicketsListResult or the result of cls(response) + :return: An iterator like instance of either SupportTicketsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.support.models.SupportTicketsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -139,38 +330,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SupportTicketsListResult', pipeline_response) + deserialized = self._deserialize("SupportTicketsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -183,23 +369,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ExceptionResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets'} # type: ignore + @distributed_trace def get( self, - support_ticket_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SupportTicketDetails" + support_ticket_name: str, + **kwargs: Any + ) -> "_models.SupportTicketDetails": """Get ticket details for an Azure subscription. Support ticket data is available for 18 months after ticket creation. If a ticket was created more than 18 months ago, a request for data might cause an error. @@ -216,32 +403,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'supportTicketName': self._serialize.url("support_ticket_name", support_ticket_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + support_ticket_name=support_ticket_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ExceptionResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SupportTicketDetails', pipeline_response) @@ -250,15 +427,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}'} # type: ignore + + @distributed_trace def update( self, - support_ticket_name, # type: str - update_support_ticket, # type: "_models.UpdateSupportTicket" - **kwargs # type: Any - ): - # type: (...) -> "_models.SupportTicketDetails" + support_ticket_name: str, + update_support_ticket: "_models.UpdateSupportTicket", + **kwargs: Any + ) -> "_models.SupportTicketDetails": """This API allows you to update the severity level, ticket status, and your contact information in the support ticket.:code:`
`:code:`
`Note: The severity levels cannot be changed if a support ticket is actively being worked upon by an Azure support engineer. In such a case, @@ -281,37 +460,27 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'supportTicketName': self._serialize.url("support_ticket_name", support_ticket_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(update_support_ticket, 'UpdateSupportTicket') + + request = build_update_request( + support_ticket_name=support_ticket_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_support_ticket, 'UpdateSupportTicket') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ExceptionResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ExceptionResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SupportTicketDetails', pipeline_response) @@ -320,52 +489,42 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}'} # type: ignore + def _create_initial( self, - support_ticket_name, # type: str - create_support_ticket_parameters, # type: "_models.SupportTicketDetails" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.SupportTicketDetails"] + support_ticket_name: str, + create_support_ticket_parameters: "_models.SupportTicketDetails", + **kwargs: Any + ) -> Optional["_models.SupportTicketDetails"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SupportTicketDetails"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'supportTicketName': self._serialize.url("support_ticket_name", support_ticket_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(create_support_ticket_parameters, 'SupportTicketDetails') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_request_initial( + support_ticket_name=support_ticket_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(create_support_ticket_parameters, 'SupportTicketDetails') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ExceptionResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -375,15 +534,17 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}'} # type: ignore + + @distributed_trace def begin_create( self, - support_ticket_name, # type: str - create_support_ticket_parameters, # type: "_models.SupportTicketDetails" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.SupportTicketDetails"] + support_ticket_name: str, + create_support_ticket_parameters: "_models.SupportTicketDetails", + **kwargs: Any + ) -> LROPoller["_models.SupportTicketDetails"]: """Creates a new support ticket for Subscription and Service limits (Quota), Technical, Billing, and Subscription Management issues for the specified subscription. Learn the `prerequisites `_ required to create a support @@ -398,11 +559,11 @@ def begin_create( ticket will reach out to you for consent if your issue requires gathering diagnostic information from your Azure resources.:code:`
`:code:`
`\ **Creating a support ticket for on-behalf-of**\ : Include *x-ms-authorization-auxiliary* header to provide an auxiliary - token as per `documentation `_. The primary token will be from the tenant for - whom a support ticket is being raised against the subscription, i.e. Cloud solution provider - (CSP) customer tenant. The auxiliary token will be from the Cloud solution provider (CSP) - partner tenant. + token as per `documentation + `_. + The primary token will be from the tenant for whom a support ticket is being raised against the + subscription, i.e. Cloud solution provider (CSP) customer tenant. The auxiliary token will be + from the Cloud solution provider (CSP) partner tenant. :param support_ticket_name: Support ticket name. :type support_ticket_name: str @@ -410,15 +571,19 @@ def begin_create( :type create_support_ticket_parameters: ~azure.mgmt.support.models.SupportTicketDetails :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: True for ARMPolling, False for no polling, or a - polling object for 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 SupportTicketDetails 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 SupportTicketDetails or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.support.models.SupportTicketDetails] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportTicketDetails"] lro_delay = kwargs.pop( 'polling_interval', @@ -429,26 +594,21 @@ def begin_create( raw_result = self._create_initial( support_ticket_name=support_ticket_name, create_support_ticket_parameters=create_support_ticket_parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('SupportTicketDetails', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'supportTicketName': self._serialize.url("support_ticket_name", support_ticket_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -460,4 +620,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Support/supportTickets/{supportTicketName}'} # type: ignore