diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/_meta.json b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/_meta.json new file mode 100644 index 000000000000..3bc67ac9f34c --- /dev/null +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.16.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "7b9bfbcb794fd6280b0d093d08dd7ef5dc1cd730", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/operationsmanagement/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/operationsmanagement/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/__init__.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/__init__.py index b7194c67dee5..6cc79988b6ef 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/__init__.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/__init__.py @@ -10,10 +10,14 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['OperationsManagementClient'] try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['OperationsManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_configuration.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_configuration.py index 4c4c396ee993..de5af0acea93 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_configuration.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class OperationsManagementClientConfiguration(Configuration): +class OperationsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for OperationsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,44 +27,31 @@ class OperationsManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param provider_name: Provider name for the parent resource. - :type provider_name: str - :param resource_type: Resource type for the parent resource. - :type resource_type: str - :param resource_name: Parent resource name. - :type resource_name: str + :keyword api_version: Api Version. Default value is "2015-11-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - provider_name, # type: str - resource_type, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(OperationsManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2015-11-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - if provider_name is None: - raise ValueError("Parameter 'provider_name' must not be None.") - if resource_type is None: - raise ValueError("Parameter 'resource_type' must not be None.") - if resource_name is None: - raise ValueError("Parameter 'resource_name' must not be None.") - super(OperationsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.provider_name = provider_name - self.resource_type = resource_type - self.resource_name = resource_name - self.api_version = "2015-11-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-operationsmanagement/{}'.format(VERSION)) self._configure(**kwargs) @@ -86,4 +71,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_operations_management_client.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_operations_management_client.py index a238c223573f..fc10fc1b1943 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_operations_management_client.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_operations_management_client.py @@ -6,79 +6,102 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import OperationsManagementClientConfiguration -from .operations import SolutionsOperations -from .operations import ManagementAssociationsOperations -from .operations import ManagementConfigurationsOperations -from .operations import Operations from . import models +from ._configuration import OperationsManagementClientConfiguration +from .operations import ManagementAssociationsOperations, ManagementConfigurationsOperations, Operations, SolutionsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class OperationsManagementClient(object): +class OperationsManagementClient: """Operations Management Client. :ivar solutions: SolutionsOperations operations :vartype solutions: azure.mgmt.operationsmanagement.operations.SolutionsOperations :ivar management_associations: ManagementAssociationsOperations operations - :vartype management_associations: azure.mgmt.operationsmanagement.operations.ManagementAssociationsOperations + :vartype management_associations: + azure.mgmt.operationsmanagement.operations.ManagementAssociationsOperations :ivar management_configurations: ManagementConfigurationsOperations operations - :vartype management_configurations: azure.mgmt.operationsmanagement.operations.ManagementConfigurationsOperations + :vartype management_configurations: + azure.mgmt.operationsmanagement.operations.ManagementConfigurationsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.operationsmanagement.operations.Operations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param provider_name: Provider name for the parent resource. - :type provider_name: str - :param resource_type: Resource type for the parent resource. - :type resource_type: str - :param resource_name: Parent resource name. - :type resource_name: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2015-11-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - provider_name, # type: str - resource_type, # type: str - resource_name, # 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 = OperationsManagementClientConfiguration(credential, subscription_id, provider_name, resource_type, resource_name, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = OperationsManagementClientConfiguration(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.solutions = SolutionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.management_associations = ManagementAssociationsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.management_configurations = ManagementConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + request: 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 + """ + + 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/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_patch.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_vendor.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_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/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_version.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_version.py index c47f66669f1b..e5754a47ce68 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_version.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/__init__.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/__init__.py index 43ba214d6776..3e8fe65f4e7b 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/__init__.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/__init__.py @@ -7,4 +7,14 @@ # -------------------------------------------------------------------------- from ._operations_management_client import OperationsManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['OperationsManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/_configuration.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/_configuration.py index f7388a32d624..6b82490aa485 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/_configuration.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class OperationsManagementClientConfiguration(Configuration): +class OperationsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for OperationsManagementClient. Note that all parameters used to create this instance are saved as instance @@ -27,43 +27,31 @@ class OperationsManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param provider_name: Provider name for the parent resource. - :type provider_name: str - :param resource_type: Resource type for the parent resource. - :type resource_type: str - :param resource_name: Parent resource name. - :type resource_name: str + :keyword api_version: Api Version. Default value is "2015-11-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - provider_name: str, - resource_type: str, - resource_name: str, **kwargs: Any ) -> None: + super(OperationsManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2015-11-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - if provider_name is None: - raise ValueError("Parameter 'provider_name' must not be None.") - if resource_type is None: - raise ValueError("Parameter 'resource_type' must not be None.") - if resource_name is None: - raise ValueError("Parameter 'resource_name' must not be None.") - super(OperationsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.provider_name = provider_name - self.resource_type = resource_type - self.resource_name = resource_name - self.api_version = "2015-11-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-operationsmanagement/{}'.format(VERSION)) self._configure(**kwargs) @@ -82,4 +70,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/_operations_management_client.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/_operations_management_client.py index e84b186c4ce8..eb35294da3e5 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/_operations_management_client.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/_operations_management_client.py @@ -6,76 +6,102 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import OperationsManagementClientConfiguration -from .operations import SolutionsOperations -from .operations import ManagementAssociationsOperations -from .operations import ManagementConfigurationsOperations -from .operations import Operations from .. import models +from ._configuration import OperationsManagementClientConfiguration +from .operations import ManagementAssociationsOperations, ManagementConfigurationsOperations, Operations, SolutionsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class OperationsManagementClient(object): +class OperationsManagementClient: """Operations Management Client. :ivar solutions: SolutionsOperations operations :vartype solutions: azure.mgmt.operationsmanagement.aio.operations.SolutionsOperations :ivar management_associations: ManagementAssociationsOperations operations - :vartype management_associations: azure.mgmt.operationsmanagement.aio.operations.ManagementAssociationsOperations + :vartype management_associations: + azure.mgmt.operationsmanagement.aio.operations.ManagementAssociationsOperations :ivar management_configurations: ManagementConfigurationsOperations operations - :vartype management_configurations: azure.mgmt.operationsmanagement.aio.operations.ManagementConfigurationsOperations + :vartype management_configurations: + azure.mgmt.operationsmanagement.aio.operations.ManagementConfigurationsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.operationsmanagement.aio.operations.Operations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param provider_name: Provider name for the parent resource. - :type provider_name: str - :param resource_type: Resource type for the parent resource. - :type resource_type: str - :param resource_name: Parent resource name. - :type resource_name: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2015-11-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - provider_name: str, - resource_type: str, - resource_name: 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 = OperationsManagementClientConfiguration(credential, subscription_id, provider_name, resource_type, resource_name, **kwargs) + self._config = OperationsManagementClientConfiguration(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.solutions = SolutionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.management_associations = ManagementAssociationsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.management_configurations = ManagementConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + 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 + """ + + 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/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/_patch.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/__init__.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/__init__.py index 2782e69839b6..88995a957c75 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/__init__.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/__init__.py @@ -11,9 +11,14 @@ from ._management_configurations_operations import ManagementConfigurationsOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'SolutionsOperations', 'ManagementAssociationsOperations', 'ManagementConfigurationsOperations', 'Operations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_management_associations_operations.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_management_associations_operations.py index 9752545e8b93..04832ccc9fc4 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_management_associations_operations.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_management_associations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,45 +6,47 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._management_associations_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_subscription_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ManagementAssociationsOperations: - """ManagementAssociationsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.operationsmanagement.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.operationsmanagement.aio.OperationsManagementClient`'s + :attr:`management_associations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def list_by_subscription( self, - **kwargs - ) -> "_models.ManagementAssociationPropertiesList": + **kwargs: Any + ) -> _models.ManagementAssociationPropertiesList: """Retrieves the ManagementAssociations list for the subscription. Retrieves the ManagementAssociations list. @@ -53,36 +56,38 @@ async def list_by_subscription( :rtype: ~azure.mgmt.operationsmanagement.models.ManagementAssociationPropertiesList :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementAssociationPropertiesList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_by_subscription.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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementAssociationPropertiesList] + + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ManagementAssociationPropertiesList', pipeline_response) @@ -91,15 +96,21 @@ async def list_by_subscription( return cls(pipeline_response, deserialized, {}) return deserialized - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/ManagementAssociations'} # type: ignore + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/ManagementAssociations"} # type: ignore + + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, management_association_name: str, - parameters: "_models.ManagementAssociation", - **kwargs - ) -> "_models.ManagementAssociation": + parameters: _models.ManagementAssociation, + **kwargs: Any + ) -> _models.ManagementAssociation: """Create/Update ManagementAssociation. Creates or updates the ManagementAssociation. @@ -107,6 +118,12 @@ async def create_or_update( :param resource_group_name: The name of the resource group to get. The name is case insensitive. :type resource_group_name: str + :param provider_name: Provider name for the parent resource. + :type provider_name: str + :param resource_type: Resource type for the parent resource. + :type resource_type: str + :param resource_name: Parent resource name. + :type resource_name: str :param management_association_name: User ManagementAssociation Name. :type management_association_name: str :param parameters: The parameters required to create ManagementAssociation extension. @@ -116,46 +133,47 @@ async def create_or_update( :rtype: ~azure.mgmt.operationsmanagement.models.ManagementAssociation :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementAssociation"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'providerName': self._serialize.url("self._config.provider_name", self._config.provider_name, 'str'), - 'resourceType': self._serialize.url("self._config.resource_type", self._config.resource_type, 'str'), - 'resourceName': self._serialize.url("self._config.resource_name", self._config.resource_name, 'str'), - 'managementAssociationName': self._serialize.url("management_association_name", management_association_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementAssociation') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementAssociation] + + _json = self._serialize.body(parameters, 'ManagementAssociation') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + management_association_name=management_association_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ManagementAssociation', pipeline_response) @@ -164,13 +182,19 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, management_association_name: str, - **kwargs + **kwargs: Any ) -> None: """Deletes the ManagementAssociation. @@ -179,6 +203,12 @@ async def delete( :param resource_group_name: The name of the resource group to get. The name is case insensitive. :type resource_group_name: str + :param provider_name: Provider name for the parent resource. + :type provider_name: str + :param resource_type: Resource type for the parent resource. + :type resource_type: str + :param resource_name: Parent resource name. + :type resource_name: str :param management_association_name: User ManagementAssociation Name. :type management_association_name: str :keyword callable cls: A custom type or function that will be passed the direct response @@ -186,54 +216,61 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'providerName': self._serialize.url("self._config.provider_name", self._config.provider_name, 'str'), - 'resourceType': self._serialize.url("self._config.resource_type", self._config.resource_type, 'str'), - 'resourceName': self._serialize.url("self._config.resource_name", self._config.resource_name, 'str'), - 'managementAssociationName': self._serialize.url("management_association_name", management_association_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + management_association_name=management_association_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, management_association_name: str, - **kwargs - ) -> "_models.ManagementAssociation": + **kwargs: Any + ) -> _models.ManagementAssociation: """Retrieve ManagementAssociation. Retrieves the user ManagementAssociation. @@ -241,6 +278,12 @@ async def get( :param resource_group_name: The name of the resource group to get. The name is case insensitive. :type resource_group_name: str + :param provider_name: Provider name for the parent resource. + :type provider_name: str + :param resource_type: Resource type for the parent resource. + :type resource_type: str + :param resource_name: Parent resource name. + :type resource_name: str :param management_association_name: User ManagementAssociation Name. :type management_association_name: str :keyword callable cls: A custom type or function that will be passed the direct response @@ -248,41 +291,43 @@ async def get( :rtype: ~azure.mgmt.operationsmanagement.models.ManagementAssociation :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementAssociation"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'providerName': self._serialize.url("self._config.provider_name", self._config.provider_name, 'str'), - 'resourceType': self._serialize.url("self._config.resource_type", self._config.resource_type, 'str'), - 'resourceName': self._serialize.url("self._config.resource_name", self._config.resource_name, 'str'), - 'managementAssociationName': self._serialize.url("management_association_name", management_association_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementAssociation] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + management_association_name=management_association_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ManagementAssociation', pipeline_response) @@ -291,4 +336,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}"} # type: ignore + diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_management_configurations_operations.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_management_configurations_operations.py index b49b047f397b..3f91a3ceacf3 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_management_configurations_operations.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_management_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,45 +6,47 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._management_configurations_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_subscription_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ManagementConfigurationsOperations: - """ManagementConfigurationsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.operationsmanagement.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.operationsmanagement.aio.OperationsManagementClient`'s + :attr:`management_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def list_by_subscription( self, - **kwargs - ) -> "_models.ManagementConfigurationPropertiesList": + **kwargs: Any + ) -> _models.ManagementConfigurationPropertiesList: """Retrieves the ManagementConfigurations list for the subscription. Retrieves the ManagementConfigurations list. @@ -53,36 +56,38 @@ async def list_by_subscription( :rtype: ~azure.mgmt.operationsmanagement.models.ManagementConfigurationPropertiesList :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementConfigurationPropertiesList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_by_subscription.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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementConfigurationPropertiesList] + + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ManagementConfigurationPropertiesList', pipeline_response) @@ -91,15 +96,18 @@ async def list_by_subscription( return cls(pipeline_response, deserialized, {}) return deserialized - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/ManagementConfigurations'} # type: ignore + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/ManagementConfigurations"} # type: ignore + + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, management_configuration_name: str, - parameters: "_models.ManagementConfiguration", - **kwargs - ) -> "_models.ManagementConfiguration": + parameters: _models.ManagementConfiguration, + **kwargs: Any + ) -> _models.ManagementConfiguration: """Create/Update ManagementConfiguration. Creates or updates the ManagementConfiguration. @@ -116,43 +124,44 @@ async def create_or_update( :rtype: ~azure.mgmt.operationsmanagement.models.ManagementConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementConfiguration"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'managementConfigurationName': self._serialize.url("management_configuration_name", management_configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementConfiguration] + + _json = self._serialize.body(parameters, 'ManagementConfiguration') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + management_configuration_name=management_configuration_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ManagementConfiguration', pipeline_response) @@ -161,13 +170,16 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/ManagementConfigurations/{managementConfigurationName}'} # type: ignore - async def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/ManagementConfigurations/{managementConfigurationName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, management_configuration_name: str, - **kwargs + **kwargs: Any ) -> None: """Deletes the ManagementConfiguration. @@ -183,51 +195,55 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'managementConfigurationName': self._serialize.url("management_configuration_name", management_configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + management_configuration_name=management_configuration_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/ManagementConfigurations/{managementConfigurationName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/ManagementConfigurations/{managementConfigurationName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, management_configuration_name: str, - **kwargs - ) -> "_models.ManagementConfiguration": + **kwargs: Any + ) -> _models.ManagementConfiguration: """Retrieve ManagementConfiguration. Retrieves the user ManagementConfiguration. @@ -242,38 +258,40 @@ async def get( :rtype: ~azure.mgmt.operationsmanagement.models.ManagementConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementConfiguration"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'managementConfigurationName': self._serialize.url("management_configuration_name", management_configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementConfiguration] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + management_configuration_name=management_configuration_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ManagementConfiguration', pipeline_response) @@ -282,4 +300,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/ManagementConfigurations/{managementConfigurationName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/ManagementConfigurations/{managementConfigurationName}"} # type: ignore + diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_operations.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_operations.py index dea0f92cce7b..49bb1f400a40 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_operations.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,93 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.operationsmanagement.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.operationsmanagement.aio.OperationsManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, - **kwargs - ) -> AsyncIterable["_models.OperationListResult"]: + **kwargs: Any + ) -> AsyncIterable[_models.OperationListResult]: """Lists all of the available OperationsManagement Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.operationsmanagement.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.operationsmanagement.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,7 +101,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -98,7 +114,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.OperationsManagement/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.OperationsManagement/operations"} # type: ignore diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_patch.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_solutions_operations.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_solutions_operations.py index 428fb9fd0d65..29257067de66 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_solutions_operations.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_solutions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,88 +6,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 Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._solutions_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SolutionsOperations: - """SolutionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.operationsmanagement.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.operationsmanagement.aio.OperationsManagementClient`'s + :attr:`solutions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, solution_name: str, - parameters: "_models.Solution", - **kwargs - ) -> "_models.Solution": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Solution"] + parameters: _models.Solution, + **kwargs: Any + ) -> _models.Solution: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Solution') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Solution] + + _json = self._serialize.body(parameters, 'Solution') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + solution_name=solution_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize('Solution', pipeline_response) @@ -94,15 +96,18 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}"} # type: ignore + + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, solution_name: str, - parameters: "_models.Solution", - **kwargs - ) -> AsyncLROPoller["_models.Solution"]: + parameters: _models.Solution, + **kwargs: Any + ) -> AsyncLROPoller[_models.Solution]: """Create/Update Solution. Creates or updates the Solution. @@ -116,48 +121,58 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.operationsmanagement.models.Solution :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 Solution 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 Solution or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.operationsmanagement.models.Solution] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Solution] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Solution"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, solution_name=solution_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('Solution', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -166,55 +181,55 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}"} # type: ignore async def _update_initial( self, resource_group_name: str, solution_name: str, - parameters: "_models.SolutionPatch", - **kwargs - ) -> "_models.Solution": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Solution"] + parameters: _models.SolutionPatch, + **kwargs: Any + ) -> _models.Solution: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SolutionPatch') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Solution] + + _json = self._serialize.body(parameters, 'SolutionPatch') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + solution_name=solution_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize('Solution', pipeline_response) @@ -222,15 +237,18 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}"} # type: ignore + + + @distributed_trace_async async def begin_update( self, resource_group_name: str, solution_name: str, - parameters: "_models.SolutionPatch", - **kwargs - ) -> AsyncLROPoller["_models.Solution"]: + parameters: _models.SolutionPatch, + **kwargs: Any + ) -> AsyncLROPoller[_models.Solution]: """Patch a Solution. Patch a Solution. Only updating tags supported. @@ -244,48 +262,58 @@ async def begin_update( :type parameters: ~azure.mgmt.operationsmanagement.models.SolutionPatch :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 Solution 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 Solution or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.operationsmanagement.models.Solution] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Solution] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Solution"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, solution_name=solution_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('Solution', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -294,60 +322,63 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}"} # type: ignore - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, solution_name: str, - **kwargs + **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + solution_name=solution_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}"} # type: ignore - async def begin_delete( + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, solution_name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the solution. @@ -360,44 +391,52 @@ async def begin_delete( :type solution_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: 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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, solution_name=solution_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -406,16 +445,17 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}"} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, solution_name: str, - **kwargs - ) -> "_models.Solution": + **kwargs: Any + ) -> _models.Solution: """Retrieve solution. Retrieves the user solution. @@ -430,38 +470,40 @@ async def get( :rtype: ~azure.mgmt.operationsmanagement.models.Solution :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Solution"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Solution] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + solution_name=solution_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Solution', pipeline_response) @@ -470,13 +512,16 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}"} # type: ignore + + + @distributed_trace_async async def list_by_resource_group( self, resource_group_name: str, - **kwargs - ) -> "_models.SolutionPropertiesList": + **kwargs: Any + ) -> _models.SolutionPropertiesList: """Retrieves the solution list for the subscription. Retrieves the solution list. It will retrieve both first party and third party solutions. @@ -489,37 +534,39 @@ async def list_by_resource_group( :rtype: ~azure.mgmt.operationsmanagement.models.SolutionPropertiesList :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SolutionPropertiesList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SolutionPropertiesList] + + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SolutionPropertiesList', pipeline_response) @@ -528,12 +575,15 @@ async def list_by_resource_group( return cls(pipeline_response, deserialized, {}) return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions"} # type: ignore + + + @distributed_trace_async async def list_by_subscription( self, - **kwargs - ) -> "_models.SolutionPropertiesList": + **kwargs: Any + ) -> _models.SolutionPropertiesList: """Retrieves the solution list for the subscription. Retrieves the solution list. It will retrieve both first party and third party solutions. @@ -543,36 +593,38 @@ async def list_by_subscription( :rtype: ~azure.mgmt.operationsmanagement.models.SolutionPropertiesList :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SolutionPropertiesList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_by_subscription.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) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SolutionPropertiesList] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SolutionPropertiesList', pipeline_response) @@ -581,4 +633,6 @@ async def list_by_subscription( return cls(pipeline_response, deserialized, {}) return deserialized - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/solutions'} # type: ignore + + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/solutions"} # type: ignore + diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/models/__init__.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/models/__init__.py index 938bae76ee6f..991eeb0642fd 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/models/__init__.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/models/__init__.py @@ -6,47 +6,31 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ArmTemplateParameter - from ._models_py3 import CodeMessageError - from ._models_py3 import CodeMessageErrorAutoGenerated - from ._models_py3 import ManagementAssociation - from ._models_py3 import ManagementAssociationProperties - from ._models_py3 import ManagementAssociationPropertiesList - from ._models_py3 import ManagementConfiguration - from ._models_py3 import ManagementConfigurationProperties - from ._models_py3 import ManagementConfigurationPropertiesList - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import Solution - from ._models_py3 import SolutionPatch - from ._models_py3 import SolutionPlan - from ._models_py3 import SolutionProperties - from ._models_py3 import SolutionPropertiesList -except (SyntaxError, ImportError): - from ._models import ArmTemplateParameter # type: ignore - from ._models import CodeMessageError # type: ignore - from ._models import CodeMessageErrorAutoGenerated # type: ignore - from ._models import ManagementAssociation # type: ignore - from ._models import ManagementAssociationProperties # type: ignore - from ._models import ManagementAssociationPropertiesList # type: ignore - from ._models import ManagementConfiguration # type: ignore - from ._models import ManagementConfigurationProperties # type: ignore - from ._models import ManagementConfigurationPropertiesList # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import Solution # type: ignore - from ._models import SolutionPatch # type: ignore - from ._models import SolutionPlan # type: ignore - from ._models import SolutionProperties # type: ignore - from ._models import SolutionPropertiesList # type: ignore +from ._models_py3 import ArmTemplateParameter +from ._models_py3 import CodeMessageError +from ._models_py3 import CodeMessageErrorError +from ._models_py3 import ManagementAssociation +from ._models_py3 import ManagementAssociationProperties +from ._models_py3 import ManagementAssociationPropertiesList +from ._models_py3 import ManagementConfiguration +from ._models_py3 import ManagementConfigurationProperties +from ._models_py3 import ManagementConfigurationPropertiesList +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import Solution +from ._models_py3 import SolutionPatch +from ._models_py3 import SolutionPlan +from ._models_py3 import SolutionProperties +from ._models_py3 import SolutionPropertiesList +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ArmTemplateParameter', 'CodeMessageError', - 'CodeMessageErrorAutoGenerated', + 'CodeMessageErrorError', 'ManagementAssociation', 'ManagementAssociationProperties', 'ManagementAssociationPropertiesList', @@ -62,3 +46,5 @@ 'SolutionProperties', 'SolutionPropertiesList', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/models/_models.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/models/_models.py deleted file mode 100644 index e1a3a4ab0859..000000000000 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/models/_models.py +++ /dev/null @@ -1,509 +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 ArmTemplateParameter(msrest.serialization.Model): - """Parameter to pass to ARM template. - - :param name: name of the parameter. - :type name: str - :param value: value for the parameter. In Jtoken. - :type value: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArmTemplateParameter, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.value = kwargs.get('value', None) - - -class CodeMessageError(msrest.serialization.Model): - """The error body contract. - - :param error: The error details for a failed request. - :type error: ~azure.mgmt.operationsmanagement.models.CodeMessageErrorAutoGenerated - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'CodeMessageErrorAutoGenerated'}, - } - - def __init__( - self, - **kwargs - ): - super(CodeMessageError, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class CodeMessageErrorAutoGenerated(msrest.serialization.Model): - """The error details for a failed request. - - :param code: The error type. - :type code: str - :param message: The error message. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CodeMessageErrorAutoGenerated, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class ManagementAssociation(msrest.serialization.Model): - """The container for solution. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Resource location. - :type location: str - :param properties: Properties for ManagementAssociation object supported by the - OperationsManagement resource provider. - :type properties: ~azure.mgmt.operationsmanagement.models.ManagementAssociationProperties - """ - - _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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ManagementAssociationProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementAssociation, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs.get('location', None) - self.properties = kwargs.get('properties', None) - - -class ManagementAssociationProperties(msrest.serialization.Model): - """ManagementAssociation properties supported by the OperationsManagement resource provider. - - All required parameters must be populated in order to send to Azure. - - :param application_id: Required. The applicationId of the appliance for this association. - :type application_id: str - """ - - _validation = { - 'application_id': {'required': True}, - } - - _attribute_map = { - 'application_id': {'key': 'applicationId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementAssociationProperties, self).__init__(**kwargs) - self.application_id = kwargs['application_id'] - - -class ManagementAssociationPropertiesList(msrest.serialization.Model): - """the list of ManagementAssociation response. - - :param value: List of Management Association properties within the subscription. - :type value: list[~azure.mgmt.operationsmanagement.models.ManagementAssociation] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ManagementAssociation]'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementAssociationPropertiesList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ManagementConfiguration(msrest.serialization.Model): - """The container for solution. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Resource location. - :type location: str - :param properties: Properties for ManagementConfiguration object supported by the - OperationsManagement resource provider. - :type properties: ~azure.mgmt.operationsmanagement.models.ManagementConfigurationProperties - """ - - _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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ManagementConfigurationProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementConfiguration, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs.get('location', None) - self.properties = kwargs.get('properties', None) - - -class ManagementConfigurationProperties(msrest.serialization.Model): - """ManagementConfiguration properties supported by the OperationsManagement resource provider. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param application_id: The applicationId of the appliance for this Management. - :type application_id: str - :param parent_resource_type: Required. The type of the parent resource. - :type parent_resource_type: str - :param parameters: Required. Parameters to run the ARM template. - :type parameters: list[~azure.mgmt.operationsmanagement.models.ArmTemplateParameter] - :ivar provisioning_state: The provisioning state for the ManagementConfiguration. - :vartype provisioning_state: str - :param template: Required. The Json object containing the ARM template to deploy. - :type template: object - """ - - _validation = { - 'parent_resource_type': {'required': True}, - 'parameters': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'template': {'required': True}, - } - - _attribute_map = { - 'application_id': {'key': 'applicationId', 'type': 'str'}, - 'parent_resource_type': {'key': 'parentResourceType', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': '[ArmTemplateParameter]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'template': {'key': 'template', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementConfigurationProperties, self).__init__(**kwargs) - self.application_id = kwargs.get('application_id', None) - self.parent_resource_type = kwargs['parent_resource_type'] - self.parameters = kwargs['parameters'] - self.provisioning_state = None - self.template = kwargs['template'] - - -class ManagementConfigurationPropertiesList(msrest.serialization.Model): - """the list of ManagementConfiguration response. - - :param value: List of Management Configuration properties within the subscription. - :type value: list[~azure.mgmt.operationsmanagement.models.ManagementConfiguration] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ManagementConfiguration]'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementConfigurationPropertiesList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class Operation(msrest.serialization.Model): - """Supported operation of OperationsManagement resource provider. - - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: Display metadata associated with the operation. - :type display: ~azure.mgmt.operationsmanagement.models.OperationDisplay - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.serialization.Model): - """Display metadata associated with the operation. - - :param provider: Service provider: Microsoft OperationsManagement. - :type provider: str - :param resource: Resource on which the operation is performed etc. - :type resource: str - :param operation: Type of operation: get, read, delete, etc. - :type operation: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - - -class OperationListResult(msrest.serialization.Model): - """Result of the request to list solution operations. - - :param value: List of solution operations supported by the OperationsManagement resource - provider. - :type value: list[~azure.mgmt.operationsmanagement.models.Operation] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class Solution(msrest.serialization.Model): - """The container for solution. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: Plan for solution object supported by the OperationsManagement resource provider. - :type plan: ~azure.mgmt.operationsmanagement.models.SolutionPlan - :param properties: Properties for solution object supported by the OperationsManagement - resource provider. - :type properties: ~azure.mgmt.operationsmanagement.models.SolutionProperties - """ - - _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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'plan': {'key': 'plan', 'type': 'SolutionPlan'}, - 'properties': {'key': 'properties', 'type': 'SolutionProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(Solution, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.plan = kwargs.get('plan', None) - self.properties = kwargs.get('properties', None) - - -class SolutionPatch(msrest.serialization.Model): - """The properties of a Solution that can be patched. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(SolutionPatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class SolutionPlan(msrest.serialization.Model): - """Plan for solution object supported by the OperationsManagement resource provider. - - :param name: name of the solution to be created. For Microsoft published solution it should be - in the format of solutionType(workspaceName). SolutionType part is case sensitive. For third - party solution, it can be anything. - :type name: str - :param publisher: Publisher name. For gallery solution, it is Microsoft. - :type publisher: str - :param promotion_code: promotionCode, Not really used now, can you left as empty. - :type promotion_code: str - :param product: name of the solution to enabled/add. For Microsoft published gallery solution - it should be in the format of OMSGallery/:code:``. This is case sensitive. - :type product: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'promotion_code': {'key': 'promotionCode', 'type': 'str'}, - 'product': {'key': 'product', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SolutionPlan, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.publisher = kwargs.get('publisher', None) - self.promotion_code = kwargs.get('promotion_code', None) - self.product = kwargs.get('product', None) - - -class SolutionProperties(msrest.serialization.Model): - """Solution properties supported by the OperationsManagement resource provider. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param workspace_resource_id: Required. The azure resourceId for the workspace where the - solution will be deployed/enabled. - :type workspace_resource_id: str - :ivar provisioning_state: The provisioning state for the solution. - :vartype provisioning_state: str - :param contained_resources: The azure resources that will be contained within the solutions. - They will be locked and gets deleted automatically when the solution is deleted. - :type contained_resources: list[str] - :param referenced_resources: The resources that will be referenced from this solution. Deleting - any of those solution out of band will break the solution. - :type referenced_resources: list[str] - """ - - _validation = { - 'workspace_resource_id': {'required': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'workspace_resource_id': {'key': 'workspaceResourceId', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'contained_resources': {'key': 'containedResources', 'type': '[str]'}, - 'referenced_resources': {'key': 'referencedResources', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(SolutionProperties, self).__init__(**kwargs) - self.workspace_resource_id = kwargs['workspace_resource_id'] - self.provisioning_state = None - self.contained_resources = kwargs.get('contained_resources', None) - self.referenced_resources = kwargs.get('referenced_resources', None) - - -class SolutionPropertiesList(msrest.serialization.Model): - """the list of solution response. - - :param value: List of solution properties within the subscription. - :type value: list[~azure.mgmt.operationsmanagement.models.Solution] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Solution]'}, - } - - def __init__( - self, - **kwargs - ): - super(SolutionPropertiesList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/models/_models_py3.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/models/_models_py3.py index a7fca052ac05..627ba3ed5436 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/models/_models_py3.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/models/_models_py3.py @@ -6,19 +6,23 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional +from typing import Any, Dict, List, Optional, TYPE_CHECKING from azure.core.exceptions import HttpResponseError import msrest.serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + class ArmTemplateParameter(msrest.serialization.Model): """Parameter to pass to ARM template. - :param name: name of the parameter. - :type name: str - :param value: value for the parameter. In Jtoken. - :type value: str + :ivar name: name of the parameter. + :vartype name: str + :ivar value: value for the parameter. In Jtoken. + :vartype value: str """ _attribute_map = { @@ -33,6 +37,12 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword name: name of the parameter. + :paramtype name: str + :keyword value: value for the parameter. In Jtoken. + :paramtype value: str + """ super(ArmTemplateParameter, self).__init__(**kwargs) self.name = name self.value = value @@ -41,31 +51,35 @@ def __init__( class CodeMessageError(msrest.serialization.Model): """The error body contract. - :param error: The error details for a failed request. - :type error: ~azure.mgmt.operationsmanagement.models.CodeMessageErrorAutoGenerated + :ivar error: The error details for a failed request. + :vartype error: ~azure.mgmt.operationsmanagement.models.CodeMessageErrorError """ _attribute_map = { - 'error': {'key': 'error', 'type': 'CodeMessageErrorAutoGenerated'}, + 'error': {'key': 'error', 'type': 'CodeMessageErrorError'}, } def __init__( self, *, - error: Optional["CodeMessageErrorAutoGenerated"] = None, + error: Optional["_models.CodeMessageErrorError"] = None, **kwargs ): + """ + :keyword error: The error details for a failed request. + :paramtype error: ~azure.mgmt.operationsmanagement.models.CodeMessageErrorError + """ super(CodeMessageError, self).__init__(**kwargs) self.error = error -class CodeMessageErrorAutoGenerated(msrest.serialization.Model): +class CodeMessageErrorError(msrest.serialization.Model): """The error details for a failed request. - :param code: The error type. - :type code: str - :param message: The error message. - :type message: str + :ivar code: The error type. + :vartype code: str + :ivar message: The error message. + :vartype message: str """ _attribute_map = { @@ -80,7 +94,13 @@ def __init__( message: Optional[str] = None, **kwargs ): - super(CodeMessageErrorAutoGenerated, self).__init__(**kwargs) + """ + :keyword code: The error type. + :paramtype code: str + :keyword message: The error message. + :paramtype message: str + """ + super(CodeMessageErrorError, self).__init__(**kwargs) self.code = code self.message = message @@ -96,11 +116,11 @@ class ManagementAssociation(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param properties: Properties for ManagementAssociation object supported by the + :ivar location: Resource location. + :vartype location: str + :ivar properties: Properties for ManagementAssociation object supported by the OperationsManagement resource provider. - :type properties: ~azure.mgmt.operationsmanagement.models.ManagementAssociationProperties + :vartype properties: ~azure.mgmt.operationsmanagement.models.ManagementAssociationProperties """ _validation = { @@ -121,9 +141,16 @@ def __init__( self, *, location: Optional[str] = None, - properties: Optional["ManagementAssociationProperties"] = None, + properties: Optional["_models.ManagementAssociationProperties"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword properties: Properties for ManagementAssociation object supported by the + OperationsManagement resource provider. + :paramtype properties: ~azure.mgmt.operationsmanagement.models.ManagementAssociationProperties + """ super(ManagementAssociation, self).__init__(**kwargs) self.id = None self.name = None @@ -137,8 +164,8 @@ class ManagementAssociationProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param application_id: Required. The applicationId of the appliance for this association. - :type application_id: str + :ivar application_id: Required. The applicationId of the appliance for this association. + :vartype application_id: str """ _validation = { @@ -155,6 +182,10 @@ def __init__( application_id: str, **kwargs ): + """ + :keyword application_id: Required. The applicationId of the appliance for this association. + :paramtype application_id: str + """ super(ManagementAssociationProperties, self).__init__(**kwargs) self.application_id = application_id @@ -162,8 +193,8 @@ def __init__( class ManagementAssociationPropertiesList(msrest.serialization.Model): """the list of ManagementAssociation response. - :param value: List of Management Association properties within the subscription. - :type value: list[~azure.mgmt.operationsmanagement.models.ManagementAssociation] + :ivar value: List of Management Association properties within the subscription. + :vartype value: list[~azure.mgmt.operationsmanagement.models.ManagementAssociation] """ _attribute_map = { @@ -173,9 +204,13 @@ class ManagementAssociationPropertiesList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ManagementAssociation"]] = None, + value: Optional[List["_models.ManagementAssociation"]] = None, **kwargs ): + """ + :keyword value: List of Management Association properties within the subscription. + :paramtype value: list[~azure.mgmt.operationsmanagement.models.ManagementAssociation] + """ super(ManagementAssociationPropertiesList, self).__init__(**kwargs) self.value = value @@ -191,11 +226,11 @@ class ManagementConfiguration(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param properties: Properties for ManagementConfiguration object supported by the + :ivar location: Resource location. + :vartype location: str + :ivar properties: Properties for ManagementConfiguration object supported by the OperationsManagement resource provider. - :type properties: ~azure.mgmt.operationsmanagement.models.ManagementConfigurationProperties + :vartype properties: ~azure.mgmt.operationsmanagement.models.ManagementConfigurationProperties """ _validation = { @@ -216,9 +251,17 @@ def __init__( self, *, location: Optional[str] = None, - properties: Optional["ManagementConfigurationProperties"] = None, + properties: Optional["_models.ManagementConfigurationProperties"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword properties: Properties for ManagementConfiguration object supported by the + OperationsManagement resource provider. + :paramtype properties: + ~azure.mgmt.operationsmanagement.models.ManagementConfigurationProperties + """ super(ManagementConfiguration, self).__init__(**kwargs) self.id = None self.name = None @@ -234,16 +277,16 @@ class ManagementConfigurationProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param application_id: The applicationId of the appliance for this Management. - :type application_id: str - :param parent_resource_type: Required. The type of the parent resource. - :type parent_resource_type: str - :param parameters: Required. Parameters to run the ARM template. - :type parameters: list[~azure.mgmt.operationsmanagement.models.ArmTemplateParameter] + :ivar application_id: The applicationId of the appliance for this Management. + :vartype application_id: str + :ivar parent_resource_type: Required. The type of the parent resource. + :vartype parent_resource_type: str + :ivar parameters: Required. Parameters to run the ARM template. + :vartype parameters: list[~azure.mgmt.operationsmanagement.models.ArmTemplateParameter] :ivar provisioning_state: The provisioning state for the ManagementConfiguration. :vartype provisioning_state: str - :param template: Required. The Json object containing the ARM template to deploy. - :type template: object + :ivar template: Required. The Json object containing the ARM template to deploy. + :vartype template: any """ _validation = { @@ -265,11 +308,21 @@ def __init__( self, *, parent_resource_type: str, - parameters: List["ArmTemplateParameter"], - template: object, + parameters: List["_models.ArmTemplateParameter"], + template: Any, application_id: Optional[str] = None, **kwargs ): + """ + :keyword application_id: The applicationId of the appliance for this Management. + :paramtype application_id: str + :keyword parent_resource_type: Required. The type of the parent resource. + :paramtype parent_resource_type: str + :keyword parameters: Required. Parameters to run the ARM template. + :paramtype parameters: list[~azure.mgmt.operationsmanagement.models.ArmTemplateParameter] + :keyword template: Required. The Json object containing the ARM template to deploy. + :paramtype template: any + """ super(ManagementConfigurationProperties, self).__init__(**kwargs) self.application_id = application_id self.parent_resource_type = parent_resource_type @@ -281,8 +334,8 @@ def __init__( class ManagementConfigurationPropertiesList(msrest.serialization.Model): """the list of ManagementConfiguration response. - :param value: List of Management Configuration properties within the subscription. - :type value: list[~azure.mgmt.operationsmanagement.models.ManagementConfiguration] + :ivar value: List of Management Configuration properties within the subscription. + :vartype value: list[~azure.mgmt.operationsmanagement.models.ManagementConfiguration] """ _attribute_map = { @@ -292,9 +345,13 @@ class ManagementConfigurationPropertiesList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ManagementConfiguration"]] = None, + value: Optional[List["_models.ManagementConfiguration"]] = None, **kwargs ): + """ + :keyword value: List of Management Configuration properties within the subscription. + :paramtype value: list[~azure.mgmt.operationsmanagement.models.ManagementConfiguration] + """ super(ManagementConfigurationPropertiesList, self).__init__(**kwargs) self.value = value @@ -302,10 +359,10 @@ def __init__( class Operation(msrest.serialization.Model): """Supported operation of OperationsManagement resource provider. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: Display metadata associated with the operation. - :type display: ~azure.mgmt.operationsmanagement.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: Display metadata associated with the operation. + :vartype display: ~azure.mgmt.operationsmanagement.models.OperationDisplay """ _attribute_map = { @@ -317,9 +374,15 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: Display metadata associated with the operation. + :paramtype display: ~azure.mgmt.operationsmanagement.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -328,12 +391,12 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """Display metadata associated with the operation. - :param provider: Service provider: Microsoft OperationsManagement. - :type provider: str - :param resource: Resource on which the operation is performed etc. - :type resource: str - :param operation: Type of operation: get, read, delete, etc. - :type operation: str + :ivar provider: Service provider: Microsoft OperationsManagement. + :vartype provider: str + :ivar resource: Resource on which the operation is performed etc. + :vartype resource: str + :ivar operation: Type of operation: get, read, delete, etc. + :vartype operation: str """ _attribute_map = { @@ -350,6 +413,14 @@ def __init__( operation: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft OperationsManagement. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed etc. + :paramtype resource: str + :keyword operation: Type of operation: get, read, delete, etc. + :paramtype operation: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -359,9 +430,9 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list solution operations. - :param value: List of solution operations supported by the OperationsManagement resource + :ivar value: List of solution operations supported by the OperationsManagement resource provider. - :type value: list[~azure.mgmt.operationsmanagement.models.Operation] + :vartype value: list[~azure.mgmt.operationsmanagement.models.Operation] """ _attribute_map = { @@ -371,9 +442,14 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, **kwargs ): + """ + :keyword value: List of solution operations supported by the OperationsManagement resource + provider. + :paramtype value: list[~azure.mgmt.operationsmanagement.models.Operation] + """ super(OperationListResult, self).__init__(**kwargs) self.value = value @@ -389,15 +465,15 @@ class Solution(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param plan: Plan for solution object supported by the OperationsManagement resource provider. - :type plan: ~azure.mgmt.operationsmanagement.models.SolutionPlan - :param properties: Properties for solution object supported by the OperationsManagement - resource provider. - :type properties: ~azure.mgmt.operationsmanagement.models.SolutionProperties + :ivar location: Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar plan: Plan for solution object supported by the OperationsManagement resource provider. + :vartype plan: ~azure.mgmt.operationsmanagement.models.SolutionPlan + :ivar properties: Properties for solution object supported by the OperationsManagement resource + provider. + :vartype properties: ~azure.mgmt.operationsmanagement.models.SolutionProperties """ _validation = { @@ -421,10 +497,22 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["SolutionPlan"] = None, - properties: Optional["SolutionProperties"] = None, + plan: Optional["_models.SolutionPlan"] = None, + properties: Optional["_models.SolutionProperties"] = None, **kwargs ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword plan: Plan for solution object supported by the OperationsManagement resource + provider. + :paramtype plan: ~azure.mgmt.operationsmanagement.models.SolutionPlan + :keyword properties: Properties for solution object supported by the OperationsManagement + resource provider. + :paramtype properties: ~azure.mgmt.operationsmanagement.models.SolutionProperties + """ super(Solution, self).__init__(**kwargs) self.id = None self.name = None @@ -438,8 +526,8 @@ def __init__( class SolutionPatch(msrest.serialization.Model): """The properties of a Solution that can be patched. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -452,6 +540,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(SolutionPatch, self).__init__(**kwargs) self.tags = tags @@ -459,17 +551,17 @@ def __init__( class SolutionPlan(msrest.serialization.Model): """Plan for solution object supported by the OperationsManagement resource provider. - :param name: name of the solution to be created. For Microsoft published solution it should be + :ivar name: name of the solution to be created. For Microsoft published solution it should be in the format of solutionType(workspaceName). SolutionType part is case sensitive. For third party solution, it can be anything. - :type name: str - :param publisher: Publisher name. For gallery solution, it is Microsoft. - :type publisher: str - :param promotion_code: promotionCode, Not really used now, can you left as empty. - :type promotion_code: str - :param product: name of the solution to enabled/add. For Microsoft published gallery solution - it should be in the format of OMSGallery/:code:``. This is case sensitive. - :type product: str + :vartype name: str + :ivar publisher: Publisher name. For gallery solution, it is Microsoft. + :vartype publisher: str + :ivar promotion_code: promotionCode, Not really used now, can you left as empty. + :vartype promotion_code: str + :ivar product: name of the solution to enabled/add. For Microsoft published gallery solution it + should be in the format of OMSGallery/:code:``. This is case sensitive. + :vartype product: str """ _attribute_map = { @@ -488,6 +580,19 @@ def __init__( product: Optional[str] = None, **kwargs ): + """ + :keyword name: name of the solution to be created. For Microsoft published solution it should + be in the format of solutionType(workspaceName). SolutionType part is case sensitive. For third + party solution, it can be anything. + :paramtype name: str + :keyword publisher: Publisher name. For gallery solution, it is Microsoft. + :paramtype publisher: str + :keyword promotion_code: promotionCode, Not really used now, can you left as empty. + :paramtype promotion_code: str + :keyword product: name of the solution to enabled/add. For Microsoft published gallery solution + it should be in the format of OMSGallery/:code:``. This is case sensitive. + :paramtype product: str + """ super(SolutionPlan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -502,17 +607,17 @@ class SolutionProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param workspace_resource_id: Required. The azure resourceId for the workspace where the + :ivar workspace_resource_id: Required. The azure resourceId for the workspace where the solution will be deployed/enabled. - :type workspace_resource_id: str + :vartype workspace_resource_id: str :ivar provisioning_state: The provisioning state for the solution. :vartype provisioning_state: str - :param contained_resources: The azure resources that will be contained within the solutions. + :ivar contained_resources: The azure resources that will be contained within the solutions. They will be locked and gets deleted automatically when the solution is deleted. - :type contained_resources: list[str] - :param referenced_resources: The resources that will be referenced from this solution. Deleting + :vartype contained_resources: list[str] + :ivar referenced_resources: The resources that will be referenced from this solution. Deleting any of those solution out of band will break the solution. - :type referenced_resources: list[str] + :vartype referenced_resources: list[str] """ _validation = { @@ -535,6 +640,17 @@ def __init__( referenced_resources: Optional[List[str]] = None, **kwargs ): + """ + :keyword workspace_resource_id: Required. The azure resourceId for the workspace where the + solution will be deployed/enabled. + :paramtype workspace_resource_id: str + :keyword contained_resources: The azure resources that will be contained within the solutions. + They will be locked and gets deleted automatically when the solution is deleted. + :paramtype contained_resources: list[str] + :keyword referenced_resources: The resources that will be referenced from this solution. + Deleting any of those solution out of band will break the solution. + :paramtype referenced_resources: list[str] + """ super(SolutionProperties, self).__init__(**kwargs) self.workspace_resource_id = workspace_resource_id self.provisioning_state = None @@ -545,8 +661,8 @@ def __init__( class SolutionPropertiesList(msrest.serialization.Model): """the list of solution response. - :param value: List of solution properties within the subscription. - :type value: list[~azure.mgmt.operationsmanagement.models.Solution] + :ivar value: List of solution properties within the subscription. + :vartype value: list[~azure.mgmt.operationsmanagement.models.Solution] """ _attribute_map = { @@ -556,8 +672,12 @@ class SolutionPropertiesList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Solution"]] = None, + value: Optional[List["_models.Solution"]] = None, **kwargs ): + """ + :keyword value: List of solution properties within the subscription. + :paramtype value: list[~azure.mgmt.operationsmanagement.models.Solution] + """ super(SolutionPropertiesList, self).__init__(**kwargs) self.value = value diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/models/_patch.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/__init__.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/__init__.py index 2782e69839b6..88995a957c75 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/__init__.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/__init__.py @@ -11,9 +11,14 @@ from ._management_configurations_operations import ManagementConfigurationsOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'SolutionsOperations', 'ManagementAssociationsOperations', 'ManagementConfigurationsOperations', 'Operations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/_management_associations_operations.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/_management_associations_operations.py index 63c392c79e85..6368f24af225 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/_management_associations_operations.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/_management_associations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,220 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import _convert_request, _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_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/ManagementAssociations") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + management_association_name: str, + *, + json: Optional[_models.ManagementAssociation] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "providerName": _SERIALIZER.url("provider_name", provider_name, 'str'), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "managementAssociationName": _SERIALIZER.url("management_association_name", management_association_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + management_association_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "providerName": _SERIALIZER.url("provider_name", provider_name, 'str'), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "managementAssociationName": _SERIALIZER.url("management_association_name", management_association_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + management_association_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "providerName": _SERIALIZER.url("provider_name", provider_name, 'str'), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "managementAssociationName": _SERIALIZER.url("management_association_name", management_association_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ManagementAssociationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ManagementAssociationsOperations(object): - """ManagementAssociationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.operationsmanagement.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.operationsmanagement.OperationsManagementClient`'s + :attr:`management_associations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagementAssociationPropertiesList" + **kwargs: Any + ) -> _models.ManagementAssociationPropertiesList: """Retrieves the ManagementAssociations list for the subscription. Retrieves the ManagementAssociations list. @@ -58,36 +229,38 @@ def list_by_subscription( :rtype: ~azure.mgmt.operationsmanagement.models.ManagementAssociationPropertiesList :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementAssociationPropertiesList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_by_subscription.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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementAssociationPropertiesList] + + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ManagementAssociationPropertiesList', pipeline_response) @@ -96,16 +269,21 @@ def list_by_subscription( return cls(pipeline_response, deserialized, {}) return deserialized - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/ManagementAssociations'} # type: ignore + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/ManagementAssociations"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - management_association_name, # type: str - parameters, # type: "_models.ManagementAssociation" - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagementAssociation" + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + management_association_name: str, + parameters: _models.ManagementAssociation, + **kwargs: Any + ) -> _models.ManagementAssociation: """Create/Update ManagementAssociation. Creates or updates the ManagementAssociation. @@ -113,6 +291,12 @@ def create_or_update( :param resource_group_name: The name of the resource group to get. The name is case insensitive. :type resource_group_name: str + :param provider_name: Provider name for the parent resource. + :type provider_name: str + :param resource_type: Resource type for the parent resource. + :type resource_type: str + :param resource_name: Parent resource name. + :type resource_name: str :param management_association_name: User ManagementAssociation Name. :type management_association_name: str :param parameters: The parameters required to create ManagementAssociation extension. @@ -122,46 +306,47 @@ def create_or_update( :rtype: ~azure.mgmt.operationsmanagement.models.ManagementAssociation :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementAssociation"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'providerName': self._serialize.url("self._config.provider_name", self._config.provider_name, 'str'), - 'resourceType': self._serialize.url("self._config.resource_type", self._config.resource_type, 'str'), - 'resourceName': self._serialize.url("self._config.resource_name", self._config.resource_name, 'str'), - 'managementAssociationName': self._serialize.url("management_association_name", management_association_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementAssociation') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementAssociation] + + _json = self._serialize.body(parameters, 'ManagementAssociation') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + management_association_name=management_association_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ManagementAssociation', pipeline_response) @@ -170,15 +355,20 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - management_association_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + management_association_name: str, + **kwargs: Any + ) -> None: """Deletes the ManagementAssociation. Deletes the ManagementAssociation in the subscription. @@ -186,6 +376,12 @@ def delete( :param resource_group_name: The name of the resource group to get. The name is case insensitive. :type resource_group_name: str + :param provider_name: Provider name for the parent resource. + :type provider_name: str + :param resource_type: Resource type for the parent resource. + :type resource_type: str + :param resource_name: Parent resource name. + :type resource_name: str :param management_association_name: User ManagementAssociation Name. :type management_association_name: str :keyword callable cls: A custom type or function that will be passed the direct response @@ -193,55 +389,61 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'providerName': self._serialize.url("self._config.provider_name", self._config.provider_name, 'str'), - 'resourceType': self._serialize.url("self._config.resource_type", self._config.resource_type, 'str'), - 'resourceName': self._serialize.url("self._config.resource_name", self._config.resource_name, 'str'), - 'managementAssociationName': self._serialize.url("management_association_name", management_association_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + management_association_name=management_association_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - management_association_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagementAssociation" + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + management_association_name: str, + **kwargs: Any + ) -> _models.ManagementAssociation: """Retrieve ManagementAssociation. Retrieves the user ManagementAssociation. @@ -249,6 +451,12 @@ def get( :param resource_group_name: The name of the resource group to get. The name is case insensitive. :type resource_group_name: str + :param provider_name: Provider name for the parent resource. + :type provider_name: str + :param resource_type: Resource type for the parent resource. + :type resource_type: str + :param resource_name: Parent resource name. + :type resource_name: str :param management_association_name: User ManagementAssociation Name. :type management_association_name: str :keyword callable cls: A custom type or function that will be passed the direct response @@ -256,41 +464,43 @@ def get( :rtype: ~azure.mgmt.operationsmanagement.models.ManagementAssociation :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementAssociation"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'providerName': self._serialize.url("self._config.provider_name", self._config.provider_name, 'str'), - 'resourceType': self._serialize.url("self._config.resource_type", self._config.resource_type, 'str'), - 'resourceName': self._serialize.url("self._config.resource_name", self._config.resource_name, 'str'), - 'managementAssociationName': self._serialize.url("management_association_name", management_association_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementAssociation] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + management_association_name=management_association_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ManagementAssociation', pipeline_response) @@ -299,4 +509,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}"} # type: ignore + diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/_management_configurations_operations.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/_management_configurations_operations.py index ee5b12165c84..a3da61d61aae 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/_management_configurations_operations.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/_management_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,50 +6,202 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import _convert_request, _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_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/ManagementConfigurations") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + management_configuration_name: str, + *, + json: Optional[_models.ManagementConfiguration] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/ManagementConfigurations/{managementConfigurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "managementConfigurationName": _SERIALIZER.url("management_configuration_name", management_configuration_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + management_configuration_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/ManagementConfigurations/{managementConfigurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "managementConfigurationName": _SERIALIZER.url("management_configuration_name", management_configuration_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + management_configuration_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/ManagementConfigurations/{managementConfigurationName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "managementConfigurationName": _SERIALIZER.url("management_configuration_name", management_configuration_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ManagementConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ManagementConfigurationsOperations(object): - """ManagementConfigurationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.operationsmanagement.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.operationsmanagement.OperationsManagementClient`'s + :attr:`management_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagementConfigurationPropertiesList" + **kwargs: Any + ) -> _models.ManagementConfigurationPropertiesList: """Retrieves the ManagementConfigurations list for the subscription. Retrieves the ManagementConfigurations list. @@ -58,36 +211,38 @@ def list_by_subscription( :rtype: ~azure.mgmt.operationsmanagement.models.ManagementConfigurationPropertiesList :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementConfigurationPropertiesList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_by_subscription.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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementConfigurationPropertiesList] + + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ManagementConfigurationPropertiesList', pipeline_response) @@ -96,16 +251,18 @@ def list_by_subscription( return cls(pipeline_response, deserialized, {}) return deserialized - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/ManagementConfigurations'} # type: ignore + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/ManagementConfigurations"} # type: ignore + + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - management_configuration_name, # type: str - parameters, # type: "_models.ManagementConfiguration" - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagementConfiguration" + resource_group_name: str, + management_configuration_name: str, + parameters: _models.ManagementConfiguration, + **kwargs: Any + ) -> _models.ManagementConfiguration: """Create/Update ManagementConfiguration. Creates or updates the ManagementConfiguration. @@ -122,43 +279,44 @@ def create_or_update( :rtype: ~azure.mgmt.operationsmanagement.models.ManagementConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementConfiguration"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'managementConfigurationName': self._serialize.url("management_configuration_name", management_configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementConfiguration] + + _json = self._serialize.body(parameters, 'ManagementConfiguration') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + management_configuration_name=management_configuration_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ManagementConfiguration', pipeline_response) @@ -167,15 +325,17 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/ManagementConfigurations/{managementConfigurationName}'} # type: ignore - def delete( + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/ManagementConfigurations/{managementConfigurationName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - management_configuration_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + management_configuration_name: str, + **kwargs: Any + ) -> None: """Deletes the ManagementConfiguration. Deletes the ManagementConfiguration in the subscription. @@ -190,52 +350,55 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'managementConfigurationName': self._serialize.url("management_configuration_name", management_configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + management_configuration_name=management_configuration_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/ManagementConfigurations/{managementConfigurationName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/ManagementConfigurations/{managementConfigurationName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - management_configuration_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagementConfiguration" + resource_group_name: str, + management_configuration_name: str, + **kwargs: Any + ) -> _models.ManagementConfiguration: """Retrieve ManagementConfiguration. Retrieves the user ManagementConfiguration. @@ -250,38 +413,40 @@ def get( :rtype: ~azure.mgmt.operationsmanagement.models.ManagementConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementConfiguration"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'managementConfigurationName': self._serialize.url("management_configuration_name", management_configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementConfiguration] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + management_configuration_name=management_configuration_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ManagementConfiguration', pipeline_response) @@ -290,4 +455,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/ManagementConfigurations/{managementConfigurationName}'} # type: ignore + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/ManagementConfigurations/{managementConfigurationName}"} # type: ignore + diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/_operations.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/_operations.py index 894be2634db0..7c588df951fd 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/_operations.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,87 +6,123 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.OperationsManagement/operations") -class Operations(object): - """Operations operations. + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.operationsmanagement.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.operationsmanagement.OperationsManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable[_models.OperationListResult]: """Lists all of the available OperationsManagement Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.operationsmanagement.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.operationsmanagement.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,7 +131,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,7 +144,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.OperationsManagement/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.OperationsManagement/operations"} # type: ignore diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/_patch.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/_solutions_operations.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/_solutions_operations.py index f9ce6489022e..83e5a634a62c 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/_solutions_operations.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/operations/_solutions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,93 +6,324 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + solution_name: str, + *, + json: Optional[_models.Solution] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "solutionName": _SERIALIZER.url("solution_name", solution_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + solution_name: str, + *, + json: Optional[_models.SolutionPatch] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "solutionName": _SERIALIZER.url("solution_name", solution_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + solution_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "solutionName": _SERIALIZER.url("solution_name", solution_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + solution_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "solutionName": _SERIALIZER.url("solution_name", solution_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/solutions") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class SolutionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class SolutionsOperations(object): - """SolutionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.operationsmanagement.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.operationsmanagement.OperationsManagementClient`'s + :attr:`solutions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, - resource_group_name, # type: str - solution_name, # type: str - parameters, # type: "_models.Solution" - **kwargs # type: Any - ): - # type: (...) -> "_models.Solution" - cls = kwargs.pop('cls', None) # type: ClsType["_models.Solution"] + resource_group_name: str, + solution_name: str, + parameters: _models.Solution, + **kwargs: Any + ) -> _models.Solution: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Solution') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Solution] + + _json = self._serialize.body(parameters, 'Solution') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + solution_name=solution_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize('Solution', pipeline_response) @@ -99,16 +331,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} # type: ignore + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}"} # type: ignore + + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - solution_name, # type: str - parameters, # type: "_models.Solution" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Solution"] + resource_group_name: str, + solution_name: str, + parameters: _models.Solution, + **kwargs: Any + ) -> LROPoller[_models.Solution]: """Create/Update Solution. Creates or updates the Solution. @@ -122,48 +356,57 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.operationsmanagement.models.Solution :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. + :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 Solution or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.operationsmanagement.models.Solution] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Solution] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Solution"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, solution_name=solution_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('Solution', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -172,56 +415,55 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}"} # type: ignore def _update_initial( self, - resource_group_name, # type: str - solution_name, # type: str - parameters, # type: "_models.SolutionPatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.Solution" - cls = kwargs.pop('cls', None) # type: ClsType["_models.Solution"] + resource_group_name: str, + solution_name: str, + parameters: _models.SolutionPatch, + **kwargs: Any + ) -> _models.Solution: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SolutionPatch') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Solution] + + _json = self._serialize.body(parameters, 'SolutionPatch') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + solution_name=solution_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize('Solution', pipeline_response) @@ -229,16 +471,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}"} # type: ignore + + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - solution_name, # type: str - parameters, # type: "_models.SolutionPatch" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Solution"] + resource_group_name: str, + solution_name: str, + parameters: _models.SolutionPatch, + **kwargs: Any + ) -> LROPoller[_models.Solution]: """Patch a Solution. Patch a Solution. Only updating tags supported. @@ -252,48 +496,57 @@ def begin_update( :type parameters: ~azure.mgmt.operationsmanagement.models.SolutionPatch :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. + :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 Solution or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.operationsmanagement.models.Solution] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Solution] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Solution"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, solution_name=solution_name, parameters=parameters, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): deserialized = self._deserialize('Solution', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -302,63 +555,64 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_initial( + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - solution_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + resource_group_name: str, + solution_name: str, + **kwargs: Any + ) -> None: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + solution_name=solution_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}"} # type: ignore + - def begin_delete( + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - solution_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + solution_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes the solution. Deletes the solution in the subscription. @@ -370,44 +624,52 @@ def begin_delete( :type solution_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: 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. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, solution_name=solution_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -416,17 +678,17 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - solution_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Solution" + resource_group_name: str, + solution_name: str, + **kwargs: Any + ) -> _models.Solution: """Retrieve solution. Retrieves the user solution. @@ -441,38 +703,40 @@ def get( :rtype: ~azure.mgmt.operationsmanagement.models.Solution :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Solution"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Solution] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + solution_name=solution_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Solution', pipeline_response) @@ -481,14 +745,16 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}"} # type: ignore + + + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SolutionPropertiesList" + resource_group_name: str, + **kwargs: Any + ) -> _models.SolutionPropertiesList: """Retrieves the solution list for the subscription. Retrieves the solution list. It will retrieve both first party and third party solutions. @@ -501,37 +767,39 @@ def list_by_resource_group( :rtype: ~azure.mgmt.operationsmanagement.models.SolutionPropertiesList :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SolutionPropertiesList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SolutionPropertiesList] + + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SolutionPropertiesList', pipeline_response) @@ -540,13 +808,15 @@ def list_by_resource_group( return cls(pipeline_response, deserialized, {}) return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions"} # type: ignore + + + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.SolutionPropertiesList" + **kwargs: Any + ) -> _models.SolutionPropertiesList: """Retrieves the solution list for the subscription. Retrieves the solution list. It will retrieve both first party and third party solutions. @@ -556,36 +826,38 @@ def list_by_subscription( :rtype: ~azure.mgmt.operationsmanagement.models.SolutionPropertiesList :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SolutionPropertiesList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_by_subscription.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) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-11-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SolutionPropertiesList] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.CodeMessageError, response) + error = self._deserialize.failsafe_deserialize(_models.CodeMessageError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SolutionPropertiesList', pipeline_response) @@ -594,4 +866,6 @@ def list_by_subscription( return cls(pipeline_response, deserialized, {}) return deserialized - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/solutions'} # type: ignore + + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/solutions"} # type: ignore +