diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/CHANGELOG.md b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/CHANGELOG.md index c2f9f315bfe6..daca2ac6999b 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/CHANGELOG.md +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/CHANGELOG.md @@ -1,5 +1,35 @@ # Release History +## 1.0.0b1 (2020-11-02) + +This is beta preview version. + +This version uses a next-generation code generator that introduces important breaking changes, but also important new features (like unified authentication and async programming). + +General breaking changes + +Credential system has been completly revamped: + +azure.common.credentials or msrestazure.azure_active_directory instances are no longer supported, use the azure-identity classes instead: https://pypi.org/project/azure-identity/ +credentials parameter has been renamed credential +The config attribute no longer exists on a client, configuration should be passed as kwarg. Example: MyClient(credential, subscription_id, enable_logging=True). For a complete set of supported options, see the parameters accept in init documentation of azure-core + +You can't import a version module anymore, use __version__ instead + +Operations that used to return a msrest.polling.LROPoller now returns a azure.core.polling.LROPoller and are prefixed with begin_. + +Exceptions tree have been simplified and most exceptions are now azure.core.exceptions.HttpResponseError (CloudError has been removed). + +Most of the operation kwarg have changed. Some of the most noticeable: + +raw has been removed. Equivalent feature can be found using cls, a callback that will give access to internal HTTP response for advanced user +For a complete set of supported options, see the parameters accept in Request documentation of azure-core +General new features + +Type annotations support using typing. SDKs are mypy ready. +This client has now stable and official support for async. Check the aio namespace of your package to find the async client. +This client now support natively tracing library like OpenCensus or OpenTelemetry. See this tracing quickstart for an overview. + ## 0.1.0 (2020-01-24) * Initial Release diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/README.md b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/README.md index d8c777dc896d..2c5186a2aff7 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/README.md +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/README.md @@ -1,6 +1,6 @@ ## Microsoft Azure SDK for Python -This is the Microsoft Azure MyService Management Client Library. +This is the Microsoft Azure OperationsManagement Management Client Library. Azure Resource Manager (ARM) is the next generation of management APIs that replace the old Azure Service Management (ASM). @@ -14,11 +14,18 @@ library. For a more complete set of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + ## Usage -For code examples, see [MyService -Management](https://docs.microsoft.com/python/api/overview/azure/) on -docs.microsoft.com. + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [Operationsmanagement Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + ## Provide Feedback 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 35c1a070aa94..3d7f726a5a41 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/__init__.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/__init__.py @@ -1,19 +1,16 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import OperationsManagementClientConfiguration from ._operations_management_client import OperationsManagementClient -__all__ = ['OperationsManagementClient', 'OperationsManagementClientConfiguration'] - -from .version import VERSION - -__version__ = VERSION +__all__ = ['OperationsManagementClient'] +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass 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 9cbd71f615f0..9a95dc7e8d2a 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_configuration.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_configuration.py @@ -1,44 +1,55 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class OperationsManagementClientConfiguration(Configuration): + """Configuration for OperationsManagementClient. -class OperationsManagementClientConfiguration(AzureConfiguration): - """Configuration for OperationsManagementClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :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 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. :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 + :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 """ def __init__( - self, credentials, subscription_id, provider_name, resource_type, resource_name, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + 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 + 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: @@ -47,19 +58,31 @@ def __init__( raise ValueError("Parameter 'resource_type' must not be None.") if resource_name is None: raise ValueError("Parameter 'resource_name' must not be None.") - if not base_url: - base_url = 'https://management.azure.com' + super(OperationsManagementClientConfiguration, self).__init__(**kwargs) - super(OperationsManagementClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True - - self.add_user_agent('azure-mgmt-operationsmanagement/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + 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.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-operationsmanagement/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 1d7c40270c11..9ac214c7a54a 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 @@ -1,16 +1,21 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import 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 ._configuration import OperationsManagementClientConfiguration from .operations import SolutionsOperations @@ -20,53 +25,70 @@ from . import models -class OperationsManagementClient(SDKClient): - """Operations Management Client +class OperationsManagementClient(object): + """Operations Management Client. - :ivar config: Configuration for client. - :vartype config: OperationsManagementClientConfiguration - - :ivar solutions: Solutions operations - :vartype solutions: azure.mgmt.operationsmanagement.operations.SolutionsOperations - :ivar management_associations: ManagementAssociations operations - :vartype management_associations: azure.mgmt.operationsmanagement.operations.ManagementAssociationsOperations - :ivar management_configurations: ManagementConfigurations operations - :vartype management_configurations: azure.mgmt.operationsmanagement.operations.ManagementConfigurationsOperations + :ivar solutions: SolutionsOperations operations + :vartype solutions: operations_management_client.operations.SolutionsOperations + :ivar management_associations: ManagementAssociationsOperations operations + :vartype management_associations: operations_management_client.operations.ManagementAssociationsOperations + :ivar management_configurations: ManagementConfigurationsOperations operations + :vartype management_configurations: operations_management_client.operations.ManagementConfigurationsOperations :ivar operations: Operations operations - :vartype operations: azure.mgmt.operationsmanagement.operations.Operations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param subscription_id: Gets subscription credentials which uniquely - identify Microsoft Azure subscription. The subscription ID forms part of - the URI for every service call. + :vartype operations: operations_management_client.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. :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 + :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. """ def __init__( - self, credentials, subscription_id, provider_name, resource_type, resource_name, base_url=None): - - self.config = OperationsManagementClientConfiguration(credentials, subscription_id, provider_name, resource_type, resource_name, base_url) - super(OperationsManagementClient, self).__init__(self.config.credentials, self.config) + 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) + 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.api_version = '2015-11-01-preview' self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) 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 close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> OperationsManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/version.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_version.py similarity index 95% rename from sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/version.py rename to sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_version.py index e0ec669828cb..affaef0c987e 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/version.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/_version.py @@ -9,5 +9,5 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "0.1.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 new file mode 100644 index 000000000000..43ba214d6776 --- /dev/null +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/__init__.py @@ -0,0 +1,10 @@ +# 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 ._operations_management_client import OperationsManagementClient +__all__ = ['OperationsManagementClient'] 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 new file mode 100644 index 000000000000..a717a359bedc --- /dev/null +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/_configuration.py @@ -0,0 +1,84 @@ +# 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 typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +VERSION = "unknown" + +class OperationsManagementClientConfiguration(Configuration): + """Configuration for OperationsManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :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. + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + provider_name: str, + resource_type: str, + resource_name: str, + **kwargs: Any + ) -> None: + 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.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-operationsmanagement/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + 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) 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 new file mode 100644 index 000000000000..d2b953d70fd5 --- /dev/null +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/_operations_management_client.py @@ -0,0 +1,88 @@ +# 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 typing import Any, Optional, 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 ._configuration import OperationsManagementClientConfiguration +from .operations import SolutionsOperations +from .operations import ManagementAssociationsOperations +from .operations import ManagementConfigurationsOperations +from .operations import Operations +from .. import models + + +class OperationsManagementClient(object): + """Operations Management Client. + + :ivar solutions: SolutionsOperations operations + :vartype solutions: operations_management_client.aio.operations.SolutionsOperations + :ivar management_associations: ManagementAssociationsOperations operations + :vartype management_associations: operations_management_client.aio.operations.ManagementAssociationsOperations + :ivar management_configurations: ManagementConfigurationsOperations operations + :vartype management_configurations: operations_management_client.aio.operations.ManagementConfigurationsOperations + :ivar operations: Operations operations + :vartype operations: operations_management_client.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. + :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. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + provider_name: str, + resource_type: str, + resource_name: str, + base_url: Optional[str] = None, + **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._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.solutions = SolutionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.management_associations = ManagementAssociationsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.management_configurations = ManagementConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "OperationsManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) 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 new file mode 100644 index 000000000000..2782e69839b6 --- /dev/null +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/__init__.py @@ -0,0 +1,19 @@ +# 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 ._solutions_operations import SolutionsOperations +from ._management_associations_operations import ManagementAssociationsOperations +from ._management_configurations_operations import ManagementConfigurationsOperations +from ._operations import Operations + +__all__ = [ + 'SolutionsOperations', + 'ManagementAssociationsOperations', + 'ManagementConfigurationsOperations', + 'Operations', +] 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 new file mode 100644 index 000000000000..9e263d3a327d --- /dev/null +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_management_associations_operations.py @@ -0,0 +1,294 @@ +# 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 typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~operations_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def list_by_subscription( + self, + **kwargs + ) -> "models.ManagementAssociationPropertiesList": + """Retrieves the ManagementAssociations list for the subscription. + + Retrieves the ManagementAssociations list. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementAssociationPropertiesList, or the result of cls(response) + :rtype: ~operations_management_client.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) + 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) + + deserialized = self._deserialize('ManagementAssociationPropertiesList', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/ManagementAssociations'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + management_association_name: str, + parameters: "models.ManagementAssociation", + **kwargs + ) -> "models.ManagementAssociation": + """Create/Update ManagementAssociation. + + Creates or updates the ManagementAssociation. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. + :type resource_group_name: str + :param management_association_name: User ManagementAssociation Name. + :type management_association_name: str + :param parameters: The parameters required to create ManagementAssociation extension. + :type parameters: ~operations_management_client.models.ManagementAssociation + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementAssociation, or the result of cls(response) + :rtype: ~operations_management_client.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) + 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) + + deserialized = self._deserialize('ManagementAssociation', pipeline_response) + + if cls: + 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( + self, + resource_group_name: str, + management_association_name: str, + **kwargs + ) -> None: + """Deletes the ManagementAssociation. + + Deletes the ManagementAssociation in the subscription. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. + :type resource_group_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 + :return: None, or the result of cls(response) + :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) + + # 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.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.CodeMessageError, 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 + + async def get( + self, + resource_group_name: str, + management_association_name: str, + **kwargs + ) -> "models.ManagementAssociation": + """Retrieve ManagementAssociation. + + Retrieves the user ManagementAssociation. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. + :type resource_group_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 + :return: ManagementAssociation, or the result of cls(response) + :rtype: ~operations_management_client.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) + 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) + + deserialized = self._deserialize('ManagementAssociation', pipeline_response) + + if cls: + 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 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 new file mode 100644 index 000000000000..26b68b210364 --- /dev/null +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_management_configurations_operations.py @@ -0,0 +1,285 @@ +# 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 typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~operations_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def list_by_subscription( + self, + **kwargs + ) -> "models.ManagementConfigurationPropertiesList": + """Retrieves the ManagementConfigurations list for the subscription. + + Retrieves the ManagementConfigurations list. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementConfigurationPropertiesList, or the result of cls(response) + :rtype: ~operations_management_client.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) + 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) + + deserialized = self._deserialize('ManagementConfigurationPropertiesList', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/ManagementConfigurations'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + management_configuration_name: str, + parameters: "models.ManagementConfiguration", + **kwargs + ) -> "models.ManagementConfiguration": + """Create/Update ManagementConfiguration. + + Creates or updates the ManagementConfiguration. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. + :type resource_group_name: str + :param management_configuration_name: User Management Configuration Name. + :type management_configuration_name: str + :param parameters: The parameters required to create OMS Solution. + :type parameters: ~operations_management_client.models.ManagementConfiguration + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementConfiguration, or the result of cls(response) + :rtype: ~operations_management_client.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) + 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) + + deserialized = self._deserialize('ManagementConfiguration', pipeline_response) + + if cls: + 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( + self, + resource_group_name: str, + management_configuration_name: str, + **kwargs + ) -> None: + """Deletes the ManagementConfiguration. + + Deletes the ManagementConfiguration in the subscription. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. + :type resource_group_name: str + :param management_configuration_name: User Management Configuration Name. + :type management_configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :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) + + # 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.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.CodeMessageError, 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 + + async def get( + self, + resource_group_name: str, + management_configuration_name: str, + **kwargs + ) -> "models.ManagementConfiguration": + """Retrieve ManagementConfiguration. + + Retrieves the user ManagementConfiguration. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. + :type resource_group_name: str + :param management_configuration_name: User Management Configuration Name. + :type management_configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementConfiguration, or the result of cls(response) + :rtype: ~operations_management_client.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) + 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) + + deserialized = self._deserialize('ManagementConfiguration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + 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 new file mode 100644 index 000000000000..c146da84bc3b --- /dev/null +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_operations.py @@ -0,0 +1,104 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~operations_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> 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[~operations_management_client.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + 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" + + 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 = 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) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.OperationsManagement/operations'} # type: ignore 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 new file mode 100644 index 000000000000..4e5f13beef1f --- /dev/null +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/aio/operations/_solutions_operations.py @@ -0,0 +1,566 @@ +# 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 typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~operations_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + 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"] + 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) + 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) + + deserialized = self._deserialize('Solution', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} # type: ignore + + async def begin_create_or_update( + self, + resource_group_name: str, + solution_name: str, + parameters: "models.Solution", + **kwargs + ) -> AsyncLROPoller["models.Solution"]: + """Create/Update Solution. + + Creates or updates the Solution. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. + :type resource_group_name: str + :param solution_name: User Solution Name. + :type solution_name: str + :param parameters: The parameters required to create OMS Solution. + :type parameters: ~operations_management_client.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 + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~operations_management_client.models.Solution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + 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( + resource_group_name=resource_group_name, + solution_name=solution_name, + parameters=parameters, + cls=lambda x,y,z: x, + **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 + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + 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 + + 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"] + 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) + 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) + + deserialized = self._deserialize('Solution', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} # type: ignore + + async def begin_update( + self, + resource_group_name: str, + solution_name: str, + parameters: "models.SolutionPatch", + **kwargs + ) -> AsyncLROPoller["models.Solution"]: + """Patch a Solution. + + Patch a Solution. Only updating tags supported. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. + :type resource_group_name: str + :param solution_name: User Solution Name. + :type solution_name: str + :param parameters: The parameters required to patch a Solution. + :type parameters: ~operations_management_client.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 + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~operations_management_client.models.Solution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + 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( + resource_group_name=resource_group_name, + solution_name=solution_name, + parameters=parameters, + cls=lambda x,y,z: x, + **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 + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + 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 + + async def _delete_initial( + self, + resource_group_name: str, + solution_name: str, + **kwargs + ) -> 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) + + # 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.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.CodeMessageError, response) + raise HttpResponseError(response=response, model=error, 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 + + async def begin_delete( + self, + resource_group_name: str, + solution_name: str, + **kwargs + ) -> AsyncLROPoller[None]: + """Deletes the solution. + + Deletes the solution in the subscription. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. + :type resource_group_name: str + :param solution_name: User Solution Name. + :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 + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + 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( + resource_group_name=resource_group_name, + solution_name=solution_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + 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 + + async def get( + self, + resource_group_name: str, + solution_name: str, + **kwargs + ) -> "models.Solution": + """Retrieve solution. + + Retrieves the user solution. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. + :type resource_group_name: str + :param solution_name: User Solution Name. + :type solution_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Solution, or the result of cls(response) + :rtype: ~operations_management_client.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') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.CodeMessageError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Solution', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} # type: ignore + + async def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> "models.SolutionPropertiesList": + """Retrieves the solution list for the subscription. + + Retrieves the solution list. It will retrieve both first party and third party solutions. + + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SolutionPropertiesList, or the result of cls(response) + :rtype: ~operations_management_client.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') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.CodeMessageError, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SolutionPropertiesList', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions'} # type: ignore + + async def list_by_subscription( + self, + **kwargs + ) -> "models.SolutionPropertiesList": + """Retrieves the solution list for the subscription. + + Retrieves the solution list. It will retrieve both first party and third party solutions. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SolutionPropertiesList, or the result of cls(response) + :rtype: ~operations_management_client.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) + + # 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) + 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) + + deserialized = self._deserialize('SolutionPropertiesList', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + 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 b024f0b38472..938bae76ee6f 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 @@ -1,18 +1,15 @@ # 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. -# +# 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. +# 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, CodeMessageErrorException - from ._models_py3 import CodeMessageErrorError + 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 @@ -21,34 +18,35 @@ 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 - from ._models import CodeMessageError, CodeMessageErrorException - from ._models import CodeMessageErrorError - from ._models import ManagementAssociation - from ._models import ManagementAssociationProperties - from ._models import ManagementAssociationPropertiesList - from ._models import ManagementConfiguration - from ._models import ManagementConfigurationProperties - from ._models import ManagementConfigurationPropertiesList - from ._models import Operation - from ._models import OperationDisplay - from ._models import Solution - from ._models import SolutionPatch - from ._models import SolutionPlan - from ._models import SolutionProperties - from ._models import SolutionPropertiesList -from ._paged_models import OperationPaged + 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 __all__ = [ 'ArmTemplateParameter', - 'CodeMessageError', 'CodeMessageErrorException', - 'CodeMessageErrorError', + 'CodeMessageError', + 'CodeMessageErrorAutoGenerated', 'ManagementAssociation', 'ManagementAssociationProperties', 'ManagementAssociationPropertiesList', @@ -57,10 +55,10 @@ 'ManagementConfigurationPropertiesList', 'Operation', 'OperationDisplay', + 'OperationListResult', 'Solution', 'SolutionPatch', 'SolutionPlan', 'SolutionProperties', 'SolutionPropertiesList', - 'OperationPaged', ] 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 index a609b5a9d320..400d637819e5 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/models/_models.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/models/_models.py @@ -1,24 +1,21 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class ArmTemplateParameter(Model): +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 + :param value: value for the parameter. In Jtoken. :type value: str """ @@ -27,49 +24,35 @@ class ArmTemplateParameter(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ArmTemplateParameter, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.value = kwargs.get('value', None) -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class CodeMessageError(Model): +class CodeMessageError(msrest.serialization.Model): """The error body contract. :param error: The error details for a failed request. - :type error: ~azure.mgmt.operationsmanagement.models.CodeMessageErrorError + :type error: ~operations_management_client.models.CodeMessageErrorAutoGenerated """ _attribute_map = { - 'error': {'key': 'error', 'type': 'CodeMessageErrorError'}, + 'error': {'key': 'error', 'type': 'CodeMessageErrorAutoGenerated'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CodeMessageError, self).__init__(**kwargs) self.error = kwargs.get('error', None) -class CodeMessageErrorException(HttpOperationError): - """Server responsed with exception of type: 'CodeMessageError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(CodeMessageErrorException, self).__init__(deserialize, response, 'CodeMessageError', *args) - - -class CodeMessageErrorError(Model): +class CodeMessageErrorAutoGenerated(msrest.serialization.Model): """The error details for a failed request. :param code: The error type. @@ -83,17 +66,19 @@ class CodeMessageErrorError(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, **kwargs): - super(CodeMessageErrorError, self).__init__(**kwargs) + def __init__( + self, + **kwargs + ): + super(CodeMessageErrorAutoGenerated, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) -class ManagementAssociation(Model): +class ManagementAssociation(msrest.serialization.Model): """The container for solution. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -101,12 +86,11 @@ class ManagementAssociation(Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location + :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 + :param properties: Properties for ManagementAssociation object supported by the + OperationsManagement resource provider. + :type properties: ~operations_management_client.models.ManagementAssociationProperties """ _validation = { @@ -123,7 +107,10 @@ class ManagementAssociation(Model): 'properties': {'key': 'properties', 'type': 'ManagementAssociationProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ManagementAssociation, self).__init__(**kwargs) self.id = None self.name = None @@ -132,14 +119,12 @@ def __init__(self, **kwargs): self.properties = kwargs.get('properties', None) -class ManagementAssociationProperties(Model): - """ManagementAssociation properties supported by the OperationsManagement - resource provider. +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. + :param application_id: Required. The applicationId of the appliance for this association. :type application_id: str """ @@ -151,34 +136,37 @@ class ManagementAssociationProperties(Model): 'application_id': {'key': 'applicationId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ManagementAssociationProperties, self).__init__(**kwargs) - self.application_id = kwargs.get('application_id', None) + self.application_id = kwargs['application_id'] -class ManagementAssociationPropertiesList(Model): +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] + :param value: List of Management Association properties within the subscription. + :type value: list[~operations_management_client.models.ManagementAssociation] """ _attribute_map = { 'value': {'key': 'value', 'type': '[ManagementAssociation]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ManagementAssociationPropertiesList, self).__init__(**kwargs) self.value = kwargs.get('value', None) -class ManagementConfiguration(Model): +class ManagementConfiguration(msrest.serialization.Model): """The container for solution. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -186,12 +174,11 @@ class ManagementConfiguration(Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location + :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 + :param properties: Properties for ManagementConfiguration object supported by the + OperationsManagement resource provider. + :type properties: ~operations_management_client.models.ManagementConfigurationProperties """ _validation = { @@ -208,7 +195,10 @@ class ManagementConfiguration(Model): 'properties': {'key': 'properties', 'type': 'ManagementConfigurationProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ManagementConfiguration, self).__init__(**kwargs) self.id = None self.name = None @@ -217,28 +207,22 @@ def __init__(self, **kwargs): self.properties = kwargs.get('properties', None) -class ManagementConfigurationProperties(Model): - """ManagementConfiguration properties supported by the OperationsManagement - resource provider. +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. + 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. + :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. + :param parameters: Required. Parameters to run the ARM template. + :type parameters: list[~operations_management_client.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 + :param template: Required. The Json object containing the ARM template to deploy. :type template: object """ @@ -257,40 +241,44 @@ class ManagementConfigurationProperties(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ManagementConfigurationProperties, self).__init__(**kwargs) self.application_id = kwargs.get('application_id', None) - self.parent_resource_type = kwargs.get('parent_resource_type', None) - self.parameters = kwargs.get('parameters', None) + self.parent_resource_type = kwargs['parent_resource_type'] + self.parameters = kwargs['parameters'] self.provisioning_state = None - self.template = kwargs.get('template', None) + self.template = kwargs['template'] -class ManagementConfigurationPropertiesList(Model): +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] + :param value: List of Management Configuration properties within the subscription. + :type value: list[~operations_management_client.models.ManagementConfiguration] """ _attribute_map = { 'value': {'key': 'value', 'type': '[ManagementConfiguration]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ManagementConfigurationPropertiesList, self).__init__(**kwargs) self.value = kwargs.get('value', None) -class Operation(Model): +class Operation(msrest.serialization.Model): """Supported operation of OperationsManagement resource provider. - :param name: Operation name: {provider}/{resource}/{operation} + :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 + :type display: ~operations_management_client.models.OperationDisplay """ _attribute_map = { @@ -298,13 +286,16 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """Display metadata associated with the operation. :param provider: Service provider: Microsoft OperationsManagement. @@ -321,18 +312,40 @@ class OperationDisplay(Model): 'operation': {'key': 'operation', 'type': 'str'}, } - def __init__(self, **kwargs): + 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 Solution(Model): +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[~operations_management_client.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. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -340,17 +353,15 @@ class Solution(Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 + :param plan: Plan for solution object supported by the OperationsManagement resource provider. + :type plan: ~operations_management_client.models.SolutionPlan + :param properties: Properties for solution object supported by the OperationsManagement + resource provider. + :type properties: ~operations_management_client.models.SolutionProperties """ _validation = { @@ -369,7 +380,10 @@ class Solution(Model): 'properties': {'key': 'properties', 'type': 'SolutionProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Solution, self).__init__(**kwargs) self.id = None self.name = None @@ -380,10 +394,10 @@ def __init__(self, **kwargs): self.properties = kwargs.get('properties', None) -class SolutionPatch(Model): +class SolutionPatch(msrest.serialization.Model): """The properties of a Solution that can be patched. - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -391,28 +405,27 @@ class SolutionPatch(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SolutionPatch, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) -class SolutionPlan(Model): - """Plan for solution object supported by the OperationsManagement resource - provider. +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. + :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 + :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/. This is case sensitive + :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 """ @@ -423,7 +436,10 @@ class SolutionPlan(Model): 'product': {'key': 'product', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SolutionPlan, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.publisher = kwargs.get('publisher', None) @@ -431,27 +447,23 @@ def __init__(self, **kwargs): self.product = kwargs.get('product', None) -class SolutionProperties(Model): - """Solution properties supported by the OperationsManagement resource - provider. +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. + 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. + :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. + :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. + :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] """ @@ -467,25 +479,31 @@ class SolutionProperties(Model): 'referenced_resources': {'key': 'referencedResources', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SolutionProperties, self).__init__(**kwargs) - self.workspace_resource_id = kwargs.get('workspace_resource_id', None) + 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(Model): +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] + :type value: list[~operations_management_client.models.Solution] """ _attribute_map = { 'value': {'key': 'value', 'type': '[Solution]'}, } - def __init__(self, **kwargs): + 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 7e6e39f9e4f5..933ae682c0f4 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 @@ -1,24 +1,23 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from typing import Dict, List, Optional +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class ArmTemplateParameter(Model): + +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 + :param value: value for the parameter. In Jtoken. :type value: str """ @@ -27,49 +26,40 @@ class ArmTemplateParameter(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, *, name: str=None, value: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + value: Optional[str] = None, + **kwargs + ): super(ArmTemplateParameter, self).__init__(**kwargs) self.name = name self.value = value -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class CodeMessageError(Model): +class CodeMessageError(msrest.serialization.Model): """The error body contract. :param error: The error details for a failed request. - :type error: ~azure.mgmt.operationsmanagement.models.CodeMessageErrorError + :type error: ~operations_management_client.models.CodeMessageErrorAutoGenerated """ _attribute_map = { - 'error': {'key': 'error', 'type': 'CodeMessageErrorError'}, + 'error': {'key': 'error', 'type': 'CodeMessageErrorAutoGenerated'}, } - def __init__(self, *, error=None, **kwargs) -> None: + def __init__( + self, + *, + error: Optional["CodeMessageErrorAutoGenerated"] = None, + **kwargs + ): super(CodeMessageError, self).__init__(**kwargs) self.error = error -class CodeMessageErrorException(HttpOperationError): - """Server responsed with exception of type: 'CodeMessageError'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(CodeMessageErrorException, self).__init__(deserialize, response, 'CodeMessageError', *args) - - -class CodeMessageErrorError(Model): +class CodeMessageErrorAutoGenerated(msrest.serialization.Model): """The error details for a failed request. :param code: The error type. @@ -83,17 +73,22 @@ class CodeMessageErrorError(Model): 'message': {'key': 'message', 'type': 'str'}, } - def __init__(self, *, code: str=None, message: str=None, **kwargs) -> None: - super(CodeMessageErrorError, self).__init__(**kwargs) + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): + super(CodeMessageErrorAutoGenerated, self).__init__(**kwargs) self.code = code self.message = message -class ManagementAssociation(Model): +class ManagementAssociation(msrest.serialization.Model): """The container for solution. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -101,12 +96,11 @@ class ManagementAssociation(Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location + :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 + :param properties: Properties for ManagementAssociation object supported by the + OperationsManagement resource provider. + :type properties: ~operations_management_client.models.ManagementAssociationProperties """ _validation = { @@ -123,7 +117,13 @@ class ManagementAssociation(Model): 'properties': {'key': 'properties', 'type': 'ManagementAssociationProperties'}, } - def __init__(self, *, location: str=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + properties: Optional["ManagementAssociationProperties"] = None, + **kwargs + ): super(ManagementAssociation, self).__init__(**kwargs) self.id = None self.name = None @@ -132,14 +132,12 @@ def __init__(self, *, location: str=None, properties=None, **kwargs) -> None: self.properties = properties -class ManagementAssociationProperties(Model): - """ManagementAssociation properties supported by the OperationsManagement - resource provider. +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. + :param application_id: Required. The applicationId of the appliance for this association. :type application_id: str """ @@ -151,34 +149,41 @@ class ManagementAssociationProperties(Model): 'application_id': {'key': 'applicationId', 'type': 'str'}, } - def __init__(self, *, application_id: str, **kwargs) -> None: + def __init__( + self, + *, + application_id: str, + **kwargs + ): super(ManagementAssociationProperties, self).__init__(**kwargs) self.application_id = application_id -class ManagementAssociationPropertiesList(Model): +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] + :param value: List of Management Association properties within the subscription. + :type value: list[~operations_management_client.models.ManagementAssociation] """ _attribute_map = { 'value': {'key': 'value', 'type': '[ManagementAssociation]'}, } - def __init__(self, *, value=None, **kwargs) -> None: + def __init__( + self, + *, + value: Optional[List["ManagementAssociation"]] = None, + **kwargs + ): super(ManagementAssociationPropertiesList, self).__init__(**kwargs) self.value = value -class ManagementConfiguration(Model): +class ManagementConfiguration(msrest.serialization.Model): """The container for solution. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -186,12 +191,11 @@ class ManagementConfiguration(Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location + :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 + :param properties: Properties for ManagementConfiguration object supported by the + OperationsManagement resource provider. + :type properties: ~operations_management_client.models.ManagementConfigurationProperties """ _validation = { @@ -208,7 +212,13 @@ class ManagementConfiguration(Model): 'properties': {'key': 'properties', 'type': 'ManagementConfigurationProperties'}, } - def __init__(self, *, location: str=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + properties: Optional["ManagementConfigurationProperties"] = None, + **kwargs + ): super(ManagementConfiguration, self).__init__(**kwargs) self.id = None self.name = None @@ -217,28 +227,22 @@ def __init__(self, *, location: str=None, properties=None, **kwargs) -> None: self.properties = properties -class ManagementConfigurationProperties(Model): - """ManagementConfiguration properties supported by the OperationsManagement - resource provider. +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. + 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. + :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. + :param parameters: Required. Parameters to run the ARM template. + :type parameters: list[~operations_management_client.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 + :param template: Required. The Json object containing the ARM template to deploy. :type template: object """ @@ -257,7 +261,15 @@ class ManagementConfigurationProperties(Model): 'template': {'key': 'template', 'type': 'object'}, } - def __init__(self, *, parent_resource_type: str, parameters, template, application_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + parent_resource_type: str, + parameters: List["ArmTemplateParameter"], + template: object, + application_id: Optional[str] = None, + **kwargs + ): super(ManagementConfigurationProperties, self).__init__(**kwargs) self.application_id = application_id self.parent_resource_type = parent_resource_type @@ -266,31 +278,34 @@ def __init__(self, *, parent_resource_type: str, parameters, template, applicati self.template = template -class ManagementConfigurationPropertiesList(Model): +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] + :param value: List of Management Configuration properties within the subscription. + :type value: list[~operations_management_client.models.ManagementConfiguration] """ _attribute_map = { 'value': {'key': 'value', 'type': '[ManagementConfiguration]'}, } - def __init__(self, *, value=None, **kwargs) -> None: + def __init__( + self, + *, + value: Optional[List["ManagementConfiguration"]] = None, + **kwargs + ): super(ManagementConfigurationPropertiesList, self).__init__(**kwargs) self.value = value -class Operation(Model): +class Operation(msrest.serialization.Model): """Supported operation of OperationsManagement resource provider. - :param name: Operation name: {provider}/{resource}/{operation} + :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 + :type display: ~operations_management_client.models.OperationDisplay """ _attribute_map = { @@ -298,13 +313,19 @@ class Operation(Model): 'display': {'key': 'display', 'type': 'OperationDisplay'}, } - def __init__(self, *, name: str=None, display=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = name self.display = display -class OperationDisplay(Model): +class OperationDisplay(msrest.serialization.Model): """Display metadata associated with the operation. :param provider: Service provider: Microsoft OperationsManagement. @@ -321,18 +342,46 @@ class OperationDisplay(Model): 'operation': {'key': 'operation', 'type': 'str'}, } - def __init__(self, *, provider: str=None, resource: str=None, operation: str=None, **kwargs) -> None: + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + **kwargs + ): super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation -class Solution(Model): +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[~operations_management_client.models.Operation] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = value + + +class Solution(msrest.serialization.Model): """The container for solution. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -340,17 +389,15 @@ class Solution(Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location + :param location: Resource location. :type location: str - :param tags: Resource tags + :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 + :param plan: Plan for solution object supported by the OperationsManagement resource provider. + :type plan: ~operations_management_client.models.SolutionPlan + :param properties: Properties for solution object supported by the OperationsManagement + resource provider. + :type properties: ~operations_management_client.models.SolutionProperties """ _validation = { @@ -369,7 +416,15 @@ class Solution(Model): 'properties': {'key': 'properties', 'type': 'SolutionProperties'}, } - def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + plan: Optional["SolutionPlan"] = None, + properties: Optional["SolutionProperties"] = None, + **kwargs + ): super(Solution, self).__init__(**kwargs) self.id = None self.name = None @@ -380,10 +435,10 @@ def __init__(self, *, location: str=None, tags=None, plan=None, properties=None, self.properties = properties -class SolutionPatch(Model): +class SolutionPatch(msrest.serialization.Model): """The properties of a Solution that can be patched. - :param tags: Resource tags + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -391,28 +446,29 @@ class SolutionPatch(Model): 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self, *, tags=None, **kwargs) -> None: + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): super(SolutionPatch, self).__init__(**kwargs) self.tags = tags -class SolutionPlan(Model): - """Plan for solution object supported by the OperationsManagement resource - provider. +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. + :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 + :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/. This is case sensitive + :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 """ @@ -423,7 +479,15 @@ class SolutionPlan(Model): 'product': {'key': 'product', 'type': 'str'}, } - def __init__(self, *, name: str=None, publisher: str=None, promotion_code: str=None, product: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + publisher: Optional[str] = None, + promotion_code: Optional[str] = None, + product: Optional[str] = None, + **kwargs + ): super(SolutionPlan, self).__init__(**kwargs) self.name = name self.publisher = publisher @@ -431,27 +495,23 @@ def __init__(self, *, name: str=None, publisher: str=None, promotion_code: str=N self.product = product -class SolutionProperties(Model): - """Solution properties supported by the OperationsManagement resource - provider. +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. + 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. + :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. + :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. + :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] """ @@ -467,7 +527,14 @@ class SolutionProperties(Model): 'referenced_resources': {'key': 'referencedResources', 'type': '[str]'}, } - def __init__(self, *, workspace_resource_id: str, contained_resources=None, referenced_resources=None, **kwargs) -> None: + def __init__( + self, + *, + workspace_resource_id: str, + contained_resources: Optional[List[str]] = None, + referenced_resources: Optional[List[str]] = None, + **kwargs + ): super(SolutionProperties, self).__init__(**kwargs) self.workspace_resource_id = workspace_resource_id self.provisioning_state = None @@ -475,17 +542,22 @@ def __init__(self, *, workspace_resource_id: str, contained_resources=None, refe self.referenced_resources = referenced_resources -class SolutionPropertiesList(Model): +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] + :type value: list[~operations_management_client.models.Solution] """ _attribute_map = { 'value': {'key': 'value', 'type': '[Solution]'}, } - def __init__(self, *, value=None, **kwargs) -> None: + def __init__( + self, + *, + value: Optional[List["Solution"]] = None, + **kwargs + ): super(SolutionPropertiesList, self).__init__(**kwargs) self.value = value diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/models/_paged_models.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/models/_paged_models.py deleted file mode 100644 index d933945d04b7..000000000000 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/models/_paged_models.py +++ /dev/null @@ -1,27 +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 msrest.paging import Paged - - -class OperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Operation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Operation]'} - } - - def __init__(self, *args, **kwargs): - - super(OperationPaged, self).__init__(*args, **kwargs) 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 215feff34f67..2782e69839b6 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 @@ -1,12 +1,9 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._solutions_operations import SolutionsOperations 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 0925e2f2e34c..90621172aea9 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,299 +1,302 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +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.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ManagementAssociationsOperations(object): """ManagementAssociationsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + 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: ~operations_management_client.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. - :ivar api_version: Client Api Version. Constant value: "2015-11-01-preview". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2015-11-01-preview" - - self.config = config + self._config = config def list_by_subscription( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> "models.ManagementAssociationPropertiesList" """Retrieves the ManagementAssociations list for the subscription. Retrieves the ManagementAssociations list. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ManagementAssociationPropertiesList or ClientRawResponse if - raw=true - :rtype: - ~azure.mgmt.operationsmanagement.models.ManagementAssociationPropertiesList - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`CodeMessageErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementAssociationPropertiesList, or the result of cls(response) + :rtype: ~operations_management_client.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'] + 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') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.CodeMessageErrorException(self._deserialize, response) + 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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ManagementAssociationPropertiesList', response) + deserialized = self._deserialize('ManagementAssociationPropertiesList', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/ManagementAssociations'} + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/ManagementAssociations'} # type: ignore def create_or_update( - self, resource_group_name, management_association_name, location=None, properties=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + management_association_name, # type: str + parameters, # type: "models.ManagementAssociation" + **kwargs # type: Any + ): + # type: (...) -> "models.ManagementAssociation" """Create/Update ManagementAssociation. Creates or updates the ManagementAssociation. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str :param management_association_name: User ManagementAssociation Name. :type management_association_name: 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 - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ManagementAssociation or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.operationsmanagement.models.ManagementAssociation - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`CodeMessageErrorException` + :param parameters: The parameters required to create ManagementAssociation extension. + :type parameters: ~operations_management_client.models.ManagementAssociation + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementAssociation, or the result of cls(response) + :rtype: ~operations_management_client.models.ManagementAssociation + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.ManagementAssociation(location=location, properties=properties) + 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'] + 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'), + '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') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ManagementAssociation') + 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') - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.CodeMessageErrorException(self._deserialize, response) + 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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ManagementAssociation', response) + deserialized = self._deserialize('ManagementAssociation', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + 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}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}'} # type: ignore def delete( - self, resource_group_name, management_association_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + management_association_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the ManagementAssociation. Deletes the ManagementAssociation in the subscription. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str :param management_association_name: User ManagementAssociation Name. :type management_association_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`CodeMessageErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :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'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + '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') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.CodeMessageErrorException(self._deserialize, response) + 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) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}'} + 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 def get( - self, resource_group_name, management_association_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + management_association_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ManagementAssociation" """Retrieve ManagementAssociation. Retrieves the user ManagementAssociation. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str :param management_association_name: User ManagementAssociation Name. :type management_association_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ManagementAssociation or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.operationsmanagement.models.ManagementAssociation - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`CodeMessageErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementAssociation, or the result of cls(response) + :rtype: ~operations_management_client.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'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + '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') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.CodeMessageErrorException(self._deserialize, response) + 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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ManagementAssociation', response) + deserialized = self._deserialize('ManagementAssociation', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.OperationsManagement/ManagementAssociations/{managementAssociationName}'} + 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 f07bc75b6920..3a5d3e3bd60e 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,295 +1,293 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +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.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ManagementConfigurationsOperations(object): """ManagementConfigurationsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + 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: ~operations_management_client.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. - :ivar api_version: Client Api Version. Constant value: "2015-11-01-preview". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2015-11-01-preview" - - self.config = config + self._config = config def list_by_subscription( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> "models.ManagementConfigurationPropertiesList" """Retrieves the ManagementConfigurations list for the subscription. Retrieves the ManagementConfigurations list. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ManagementConfigurationPropertiesList or ClientRawResponse if - raw=true - :rtype: - ~azure.mgmt.operationsmanagement.models.ManagementConfigurationPropertiesList - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`CodeMessageErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementConfigurationPropertiesList, or the result of cls(response) + :rtype: ~operations_management_client.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'] + 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') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.CodeMessageErrorException(self._deserialize, response) + 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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ManagementConfigurationPropertiesList', response) + deserialized = self._deserialize('ManagementConfigurationPropertiesList', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/ManagementConfigurations'} + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/ManagementConfigurations'} # type: ignore def create_or_update( - self, resource_group_name, management_configuration_name, location=None, properties=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + management_configuration_name, # type: str + parameters, # type: "models.ManagementConfiguration" + **kwargs # type: Any + ): + # type: (...) -> "models.ManagementConfiguration" """Create/Update ManagementConfiguration. Creates or updates the ManagementConfiguration. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str - :param management_configuration_name: User Management Configuration - Name. + :param management_configuration_name: User Management Configuration Name. :type management_configuration_name: 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 - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ManagementConfiguration or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.operationsmanagement.models.ManagementConfiguration or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`CodeMessageErrorException` + :param parameters: The parameters required to create OMS Solution. + :type parameters: ~operations_management_client.models.ManagementConfiguration + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementConfiguration, or the result of cls(response) + :rtype: ~operations_management_client.models.ManagementConfiguration + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.ManagementConfiguration(location=location, properties=properties) + 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'] + 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'), + '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') + 'managementConfigurationName': self._serialize.url("management_configuration_name", management_configuration_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ManagementConfiguration') + 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') - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.CodeMessageErrorException(self._deserialize, response) + 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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ManagementConfiguration', response) + deserialized = self._deserialize('ManagementConfiguration', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/ManagementConfigurations/{managementConfigurationName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/ManagementConfigurations/{managementConfigurationName}'} # type: ignore def delete( - self, resource_group_name, management_configuration_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + management_configuration_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the ManagementConfiguration. Deletes the ManagementConfiguration in the subscription. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str - :param management_configuration_name: User Management Configuration - Name. + :param management_configuration_name: User Management Configuration Name. :type management_configuration_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`CodeMessageErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :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'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + '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') + 'managementConfigurationName': self._serialize.url("management_configuration_name", management_configuration_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.CodeMessageErrorException(self._deserialize, response) + 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) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/ManagementConfigurations/{managementConfigurationName}'} + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/ManagementConfigurations/{managementConfigurationName}'} # type: ignore def get( - self, resource_group_name, management_configuration_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + management_configuration_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ManagementConfiguration" """Retrieve ManagementConfiguration. Retrieves the user ManagementConfiguration. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str - :param management_configuration_name: User Management Configuration - Name. + :param management_configuration_name: User Management Configuration Name. :type management_configuration_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ManagementConfiguration or ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.operationsmanagement.models.ManagementConfiguration or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`CodeMessageErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementConfiguration, or the result of cls(response) + :rtype: ~operations_management_client.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'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + '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') + 'managementConfigurationName': self._serialize.url("management_configuration_name", management_configuration_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.CodeMessageErrorException(self._deserialize, response) + 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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ManagementConfiguration', response) + deserialized = self._deserialize('ManagementConfiguration', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/ManagementConfigurations/{managementConfigurationName}'} + 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 781193478d99..a243ae4905f4 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,102 +1,109 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +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.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class Operations(object): """Operations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + 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: ~operations_management_client.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. - :ivar api_version: Client Api Version. Constant value: "2015-11-01-preview". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2015-11-01-preview" - - self.config = config + self._config = config def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OperationListResult"] """Lists all of the available OperationsManagement Rest API operations. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Operation - :rtype: - ~azure.mgmt.operationsmanagement.models.OperationPaged[~azure.mgmt.operationsmanagement.models.Operation] - :raises: :class:`CloudError` + :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[~operations_management_client.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError """ + 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" + 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'] - + url = self.list.metadata['url'] # type: ignore # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/providers/Microsoft.OperationsManagement/operations'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.OperationsManagement/operations'} # type: ignore 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 842623cb4822..2c2ef8114dde 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,509 +1,579 @@ # 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. -# +# 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. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +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.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +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 directly this class, but create a Client instance that will create it for you and attach it as attribute. + 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: ~operations_management_client.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. - :ivar api_version: Client Api Version. Constant value: "2015-11-01-preview". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2015-11-01-preview" - - self.config = config - + self._config = config def _create_or_update_initial( - self, resource_group_name, solution_name, parameters, custom_headers=None, raw=False, **operation_config): + 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"] + 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'] + 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'), + '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') + 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'Solution') + 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') - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + response = pipeline_response.http_response if response.status_code not in [201]: - raise models.CodeMessageErrorException(self._deserialize, response) - - deserialized = None + 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) - if response.status_code == 201: - deserialized = self._deserialize('Solution', response) + deserialized = self._deserialize('Solution', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, solution_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} # type: ignore + + 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"] """Create/Update Solution. Creates or updates the Solution. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str :param solution_name: User Solution Name. :type solution_name: str :param parameters: The parameters required to create OMS Solution. - :type parameters: ~azure.mgmt.operationsmanagement.models.Solution - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :type parameters: ~operations_management_client.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 - :return: An instance of LROPoller that returns Solution or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.operationsmanagement.models.Solution] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.operationsmanagement.models.Solution]] - :raises: - :class:`CodeMessageErrorException` + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either Solution or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~operations_management_client.models.Solution] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - solution_name=solution_name, - parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + 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 ) - - def get_long_running_output(response): - deserialized = self._deserialize('Solution', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + solution_name=solution_name, + parameters=parameters, + cls=lambda x,y,z: x, + **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 - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} - + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + 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 def _update_initial( - self, resource_group_name, solution_name, tags=None, custom_headers=None, raw=False, **operation_config): - parameters = models.SolutionPatch(tags=tags) + 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"] + 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.metadata['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'), + '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') + 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'SolutionPatch') + 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') - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + 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) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.CodeMessageErrorException(self._deserialize, response) - - deserialized = None + 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) - if response.status_code == 200: - deserialized = self._deserialize('Solution', response) + deserialized = self._deserialize('Solution', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update( - self, resource_group_name, solution_name, tags=None, custom_headers=None, raw=False, polling=True, **operation_config): + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} # type: ignore + + def begin_update( + self, + resource_group_name, # type: str + solution_name, # type: str + parameters, # type: "models.SolutionPatch" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.Solution"] """Patch a Solution. Patch a Solution. Only updating tags supported. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str :param solution_name: User Solution Name. :type solution_name: str - :param tags: Resource tags - :type tags: dict[str, str] - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :param parameters: The parameters required to patch a Solution. + :type parameters: ~operations_management_client.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 - :return: An instance of LROPoller that returns Solution or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.operationsmanagement.models.Solution] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.operationsmanagement.models.Solution]] - :raises: - :class:`CodeMessageErrorException` + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either Solution or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~operations_management_client.models.Solution] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._update_initial( - resource_group_name=resource_group_name, - solution_name=solution_name, - tags=tags, - custom_headers=custom_headers, - raw=True, - **operation_config + 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 ) - - def get_long_running_output(response): - deserialized = self._deserialize('Solution', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + solution_name=solution_name, + parameters=parameters, + cls=lambda x,y,z: x, + **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 - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} - + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + 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 def _delete_initial( - self, resource_group_name, solution_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + solution_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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.metadata['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'), + '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') + 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.CodeMessageErrorException(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - def delete( - self, resource_group_name, solution_name, custom_headers=None, raw=False, polling=True, **operation_config): + 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) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + solution_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller[None] """Deletes the solution. Deletes the solution in the subscription. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str :param solution_name: User Solution Name. :type solution_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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 - :return: An instance of LROPoller that returns None or - ClientRawResponse if raw==True - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] - :raises: - :class:`CodeMessageErrorException` + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - solution_name=solution_name, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) - - def get_long_running_output(response): - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + solution_name=solution_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + 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 def get( - self, resource_group_name, solution_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + solution_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Solution" """Retrieve solution. Retrieves the user solution. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str :param solution_name: User Solution Name. :type solution_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: Solution or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.operationsmanagement.models.Solution or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`CodeMessageErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Solution, or the result of cls(response) + :rtype: ~operations_management_client.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'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + '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') + 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.CodeMessageErrorException(self._deserialize, response) + 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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Solution', response) + deserialized = self._deserialize('Solution', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions/{solutionName}'} # type: ignore def list_by_resource_group( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.SolutionPropertiesList" """Retrieves the solution list for the subscription. - Retrieves the solution list. It will retrieve both first party and - third party solutions. + Retrieves the solution list. It will retrieve both first party and third party solutions. - :param resource_group_name: The name of the resource group to get. The - name is case insensitive. + :param resource_group_name: The name of the resource group to get. The name is case + insensitive. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: SolutionPropertiesList or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.operationsmanagement.models.SolutionPropertiesList - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`CodeMessageErrorException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SolutionPropertiesList, or the result of cls(response) + :rtype: ~operations_management_client.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'] + 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\._\(\)]+$') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.CodeMessageErrorException(self._deserialize, response) + 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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('SolutionPropertiesList', response) + deserialized = self._deserialize('SolutionPropertiesList', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions'} + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.OperationsManagement/solutions'} # type: ignore def list_by_subscription( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> "models.SolutionPropertiesList" """Retrieves the solution list for the subscription. - Retrieves the solution list. It will retrieve both first party and - third party solutions. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: SolutionPropertiesList or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.operationsmanagement.models.SolutionPropertiesList - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`CodeMessageErrorException` + Retrieves the solution list. It will retrieve both first party and third party solutions. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SolutionPropertiesList, or the result of cls(response) + :rtype: ~operations_management_client.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'] + 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') + '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 = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.CodeMessageErrorException(self._deserialize, response) + 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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('SolutionPropertiesList', response) + deserialized = self._deserialize('SolutionPropertiesList', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/solutions'} + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OperationsManagement/solutions'} # type: ignore diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/py.typed b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/azure/mgmt/operationsmanagement/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/setup.py b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/setup.py index e9ec4a0563f8..6916395a8273 100644 --- a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/setup.py +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/setup.py @@ -36,7 +36,7 @@ pass # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py'), 'r') as fd: +with open(os.path.join(package_folder_path, '_version.py'), 'r') as fd: version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) @@ -79,8 +79,8 @@ ]), install_requires=[ 'msrest>=0.5.0', - 'msrestazure>=0.4.32,<2.0.0', 'azure-common~=1.1', + 'azure-mgmt-core>=1.2.0,<2.0.0' ], extras_require={ ":python_version<'3.0'": ['azure-mgmt-nspkg'],