diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/__init__.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/__init__.py index e9400926d2ea..1c42a80d3e93 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/__init__.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/__init__.py @@ -13,7 +13,7 @@ __all__ = ['AutomanageClient'] try: - from ._patch import patch_sdk + from ._patch import patch_sdk # type: ignore patch_sdk() except ImportError: pass diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_configuration.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_configuration.py index 1c10217f4124..0b0e93a46183 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_configuration.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_configuration.py @@ -10,6 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy from ._version import VERSION @@ -48,8 +49,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = "2020-06-30-preview" - self.credential_scopes = ['https://management.azure.com/.default'] - self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-automanage/{}'.format(VERSION)) self._configure(**kwargs) @@ -62,6 +62,7 @@ def _configure( 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) diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_metadata.json b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_metadata.json index 3ce69338c090..21d5d1105f92 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_metadata.json +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_metadata.json @@ -4,32 +4,37 @@ "client": { "name": "AutomanageClient", "filename": "_automanage_client", - "description": "Automanage Client." + "description": "Automanage Client.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": true }, "global_parameters": { - "sync_method": { + "sync": { "credential": { - "method_signature": "credential, # type: \"TokenCredential\"", + "signature": "credential, # type: \"TokenCredential\"", "description": "Credential needed for the client to connect to Azure.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "method_signature": "subscription_id, # type: str", + "signature": "subscription_id, # type: str", "description": "The ID of the target subscription.", "docstring_type": "str", "required": true } }, - "async_method": { + "async": { "credential": { - "method_signature": "credential, # type: \"AsyncTokenCredential\"", + "signature": "credential, # type: \"AsyncTokenCredential\"", "description": "Credential needed for the client to connect to Azure.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { - "method_signature": "subscription_id, # type: str", + "signature": "subscription_id, # type: str", "description": "The ID of the target subscription.", "docstring_type": "str", "required": true @@ -41,7 +46,10 @@ }, "config": { "credential": true, - "credential_scopes": ["https://management.azure.com/.default"] + "credential_scopes": ["https://management.azure.com/.default"], + "credential_default_policy_type": "BearerTokenCredentialPolicy", + "credential_default_policy_type_has_async_version": true, + "credential_key_header_name": null }, "operation_groups": { "accounts": "AccountsOperations", diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_version.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_version.py index e5754a47ce68..95e84007ac63 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_version.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b1" +VERSION = "0.1.0-preview" diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/__init__.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/__init__.py index a724e312f9bb..779b5eb6a249 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/__init__.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/__init__.py @@ -6,5 +6,5 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._automanage_client_async import AutomanageClient +from ._automanage_client import AutomanageClient __all__ = ['AutomanageClient'] diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_automanage_client.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_automanage_client.py new file mode 100644 index 000000000000..c604a8feeb8c --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_automanage_client.py @@ -0,0 +1,78 @@ +# 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 AutomanageClientConfiguration +from .operations import AccountsOperations +from .operations import ConfigurationProfileAssignmentsOperations +from .operations import ConfigurationProfilePreferencesOperations +from .operations import Operations +from .. import models + + +class AutomanageClient(object): + """Automanage Client. + + :ivar accounts: AccountsOperations operations + :vartype accounts: automanage_client.aio.operations.AccountsOperations + :ivar configuration_profile_assignments: ConfigurationProfileAssignmentsOperations operations + :vartype configuration_profile_assignments: automanage_client.aio.operations.ConfigurationProfileAssignmentsOperations + :ivar configuration_profile_preferences: ConfigurationProfilePreferencesOperations operations + :vartype configuration_profile_preferences: automanage_client.aio.operations.ConfigurationProfilePreferencesOperations + :ivar operations: Operations operations + :vartype operations: automanage_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: The ID of the target subscription. + :type subscription_id: str + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = AutomanageClientConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.accounts = AccountsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.configuration_profile_assignments = ConfigurationProfileAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.configuration_profile_preferences = ConfigurationProfilePreferencesOperations( + 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) -> "AutomanageClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_configuration.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_configuration.py new file mode 100644 index 000000000000..21b4c1d9af68 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_configuration.py @@ -0,0 +1,67 @@ +# 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 + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class AutomanageClientConfiguration(Configuration): + """Configuration for AutomanageClient. + + 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: The ID of the target subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: 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.") + super(AutomanageClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2020-06-30-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-automanage/{}'.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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/__init__.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/__init__.py new file mode 100644 index 000000000000..9520dfd09e18 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/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 ._accounts_operations import AccountsOperations +from ._configuration_profile_assignments_operations import ConfigurationProfileAssignmentsOperations +from ._configuration_profile_preferences_operations import ConfigurationProfilePreferencesOperations +from ._operations import Operations + +__all__ = [ + 'AccountsOperations', + 'ConfigurationProfileAssignmentsOperations', + 'ConfigurationProfilePreferencesOperations', + 'Operations', +] diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_accounts_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_accounts_operations.py new file mode 100644 index 000000000000..895b6c6923c2 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_accounts_operations.py @@ -0,0 +1,433 @@ +# 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, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AccountsOperations: + """AccountsOperations 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: ~automanage_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( + self, + account_name: str, + resource_group_name: str, + parameters: "_models.Account", + **kwargs + ) -> "_models.Account": + """Creates an Automanage Account. + + :param account_name: Name of the Automanage account. + :type account_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to create or update Automanage account. + :type parameters: ~automanage_client.models.Account + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Account, or the result of cls(response) + :rtype: ~automanage_client.models.Account + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-30-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 = { + 'accountName': self._serialize.url("account_name", account_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + '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['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, 'Account') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Account', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Account', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}'} # type: ignore + + async def get( + self, + account_name: str, + resource_group_name: str, + **kwargs + ) -> "_models.Account": + """Get information about a Automanage account. + + :param account_name: The Automanage account name. + :type account_name: str + :param resource_group_name: The name of the resource group. 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: Account, or the result of cls(response) + :rtype: ~automanage_client.models.Account + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-30-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'accountName': self._serialize.url("account_name", account_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + '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.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Account', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + account_name: str, + **kwargs + ) -> None: + """Delete a Automanage account. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param account_name: Name of the Automanage account. + :type account_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 = "2020-06-30-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + 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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.ErrorResponse, 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.Automanage/accounts/{accountName}'} # type: ignore + + async def update( + self, + account_name: str, + resource_group_name: str, + parameters: "_models.AccountUpdate", + **kwargs + ) -> "_models.Account": + """Updates an Automanage Account. + + :param account_name: Name of the Automanage account. + :type account_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to update Automanage account. + :type parameters: ~automanage_client.models.AccountUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Account, or the result of cls(response) + :rtype: ~automanage_client.models.Account + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-30-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'accountName': self._serialize.url("account_name", account_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + '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['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, 'AccountUpdate') + 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.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Account', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> AsyncIterable["_models.AccountList"]: + """Retrieve a list of Automanage accounts within a given resource group. + + :param resource_group_name: The name of the resource group. 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: An iterator like instance of either AccountList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.AccountList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccountList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-30-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_by_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + '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') + + 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('AccountList', 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]: + error = self._deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts'} # type: ignore + + def list_by_subscription( + self, + **kwargs + ) -> AsyncIterable["_models.AccountList"]: + """Retrieve a list of Automanage accounts within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AccountList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.AccountList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccountList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-30-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_by_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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('AccountList', 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]: + error = self._deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/accounts'} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_assignments_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_assignments_operations.py new file mode 100644 index 000000000000..a3f2ab0c35d6 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_assignments_operations.py @@ -0,0 +1,443 @@ +# 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, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.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 as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ConfigurationProfileAssignmentsOperations: + """ConfigurationProfileAssignmentsOperations 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: ~automanage_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, + configuration_profile_assignment_name: str, + resource_group_name: str, + vm_name: str, + parameters: "_models.ConfigurationProfileAssignment", + **kwargs + ) -> "_models.ConfigurationProfileAssignment": + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-30-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 = { + 'configurationProfileAssignmentName': self._serialize.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'vmName': self._serialize.url("vm_name", vm_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, 'ConfigurationProfileAssignment') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore + + async def begin_create_or_update( + self, + configuration_profile_assignment_name: str, + resource_group_name: str, + vm_name: str, + parameters: "_models.ConfigurationProfileAssignment", + **kwargs + ) -> AsyncLROPoller["_models.ConfigurationProfileAssignment"]: + """Creates an association between a VM and Automanage configuration profile. + + :param configuration_profile_assignment_name: Name of the configuration profile assignment. + Only default is supported. + :type configuration_profile_assignment_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param vm_name: The name of the virtual machine. + :type vm_name: str + :param parameters: Parameters supplied to the create or update configuration profile + assignment. + :type parameters: ~automanage_client.models.ConfigurationProfileAssignment + :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 ConfigurationProfileAssignment or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~automanage_client.models.ConfigurationProfileAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignment"] + 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( + configuration_profile_assignment_name=configuration_profile_assignment_name, + resource_group_name=resource_group_name, + vm_name=vm_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('ConfigurationProfileAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'configurationProfileAssignmentName': self._serialize.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'vmName': self._serialize.url("vm_name", vm_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + 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.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + configuration_profile_assignment_name: str, + vm_name: str, + **kwargs + ) -> "_models.ConfigurationProfileAssignment": + """Get information about a configuration profile assignment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param configuration_profile_assignment_name: The configuration profile assignment name. + :type configuration_profile_assignment_name: str + :param vm_name: The name of the virtual machine. + :type vm_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationProfileAssignment, or the result of cls(response) + :rtype: ~automanage_client.models.ConfigurationProfileAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-30-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'configurationProfileAssignmentName': self._serialize.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'vmName': self._serialize.url("vm_name", vm_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.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + configuration_profile_assignment_name: str, + vm_name: str, + **kwargs + ) -> None: + """Delete a configuration profile assignment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param configuration_profile_assignment_name: Name of the configuration profile assignment. + :type configuration_profile_assignment_name: str + :param vm_name: The name of the virtual machine. + :type vm_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 = "2020-06-30-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'configurationProfileAssignmentName': self._serialize.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'vmName': self._serialize.url("vm_name", vm_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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.ErrorResponse, 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.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore + + def list( + self, + resource_group_name: str, + **kwargs + ) -> AsyncIterable["_models.ConfigurationProfileAssignmentList"]: + """Get list of configuration profile assignments. + + :param resource_group_name: The name of the resource group. 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: An iterator like instance of either ConfigurationProfileAssignmentList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ConfigurationProfileAssignmentList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignmentList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-30-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + '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', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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('ConfigurationProfileAssignmentList', 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]: + error = self._deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfileAssignments'} # type: ignore + + def list_by_subscription( + self, + **kwargs + ) -> AsyncIterable["_models.ConfigurationProfileAssignmentList"]: + """Get list of configuration profile assignments under a given subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConfigurationProfileAssignmentList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ConfigurationProfileAssignmentList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignmentList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-30-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_by_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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('ConfigurationProfileAssignmentList', 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]: + error = self._deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/configurationProfileAssignments'} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_preferences_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_preferences_operations.py new file mode 100644 index 000000000000..0bbd0769c2c4 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_preferences_operations.py @@ -0,0 +1,433 @@ +# 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, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ConfigurationProfilePreferencesOperations: + """ConfigurationProfilePreferencesOperations 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: ~automanage_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( + self, + configuration_profile_preference_name: str, + resource_group_name: str, + parameters: "_models.ConfigurationProfilePreference", + **kwargs + ) -> "_models.ConfigurationProfilePreference": + """Creates a configuration profile preference. + + :param configuration_profile_preference_name: Name of the configuration profile preference. + :type configuration_profile_preference_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to create or update configuration profile preference. + :type parameters: ~automanage_client.models.ConfigurationProfilePreference + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationProfilePreference, or the result of cls(response) + :rtype: ~automanage_client.models.ConfigurationProfilePreference + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfilePreference"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-30-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 = { + 'configurationProfilePreferenceName': self._serialize.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + '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['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, 'ConfigurationProfilePreference') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ConfigurationProfilePreference', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ConfigurationProfilePreference', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}'} # type: ignore + + async def get( + self, + configuration_profile_preference_name: str, + resource_group_name: str, + **kwargs + ) -> "_models.ConfigurationProfilePreference": + """Get information about a configuration profile preference. + + :param configuration_profile_preference_name: The configuration profile preference name. + :type configuration_profile_preference_name: str + :param resource_group_name: The name of the resource group. 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: ConfigurationProfilePreference, or the result of cls(response) + :rtype: ~automanage_client.models.ConfigurationProfilePreference + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfilePreference"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-30-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'configurationProfilePreferenceName': self._serialize.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + '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.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConfigurationProfilePreference', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + configuration_profile_preference_name: str, + **kwargs + ) -> None: + """Delete a configuration profile preference. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param configuration_profile_preference_name: Name of the configuration profile preference. + :type configuration_profile_preference_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 = "2020-06-30-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'configurationProfilePreferenceName': self._serialize.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + 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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.ErrorResponse, 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.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}'} # type: ignore + + async def update( + self, + configuration_profile_preference_name: str, + resource_group_name: str, + parameters: "_models.ConfigurationProfilePreferenceUpdate", + **kwargs + ) -> "_models.ConfigurationProfilePreference": + """Updates a configuration profile preference. + + :param configuration_profile_preference_name: Name of the configuration profile preference. + :type configuration_profile_preference_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param parameters: Parameters supplied to create or update configuration profile preference. + :type parameters: ~automanage_client.models.ConfigurationProfilePreferenceUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationProfilePreference, or the result of cls(response) + :rtype: ~automanage_client.models.ConfigurationProfilePreference + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfilePreference"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-30-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'configurationProfilePreferenceName': self._serialize.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + '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['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, 'ConfigurationProfilePreferenceUpdate') + 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.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConfigurationProfilePreference', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> AsyncIterable["_models.ConfigurationProfilePreferenceList"]: + """Retrieve a list of configuration profile preferences within a given resource group. + + :param resource_group_name: The name of the resource group. 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: An iterator like instance of either ConfigurationProfilePreferenceList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ConfigurationProfilePreferenceList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfilePreferenceList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-30-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_by_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + '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') + + 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('ConfigurationProfilePreferenceList', 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]: + error = self._deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences'} # type: ignore + + def list_by_subscription( + self, + **kwargs + ) -> AsyncIterable["_models.ConfigurationProfilePreferenceList"]: + """Retrieve a list of configuration profile preferences within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConfigurationProfilePreferenceList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ConfigurationProfilePreferenceList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfilePreferenceList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-30-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_by_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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('ConfigurationProfilePreferenceList', 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]: + error = self._deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/configurationProfilePreferences'} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_operations.py new file mode 100644 index 000000000000..59a2d51ab4f9 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_operations.py @@ -0,0 +1,105 @@ +# 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 as _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: ~automanage_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.OperationList"]: + """Lists all of the available Automanage 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 OperationList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.OperationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-30-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('OperationList', 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]: + error = self._deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Automanage/operations'} # type: ignore diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/__init__.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/__init__.py index 1bce4240a948..5e0e4300a545 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/__init__.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/__init__.py @@ -22,8 +22,8 @@ from ._models_py3 import ConfigurationProfilePreferenceUpdate from ._models_py3 import ConfigurationProfilePreferenceVmBackup from ._models_py3 import ErrorAdditionalInfo + from ._models_py3 import ErrorDetail from ._models_py3 import ErrorResponse - from ._models_py3 import ErrorResponseError from ._models_py3 import Operation from ._models_py3 import OperationDisplay from ._models_py3 import OperationList @@ -47,8 +47,8 @@ from ._models import ConfigurationProfilePreferenceUpdate # type: ignore from ._models import ConfigurationProfilePreferenceVmBackup # type: ignore from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorDetail # type: ignore from ._models import ErrorResponse # type: ignore - from ._models import ErrorResponseError # type: ignore from ._models import Operation # type: ignore from ._models import OperationDisplay # type: ignore from ._models import OperationList # type: ignore @@ -60,7 +60,7 @@ from ._automanage_client_enums import ( ConfigurationProfile, EnableRealTimeProtection, - ProvisioningStatus, + ProvisioningState, ResourceIdentityType, RunScheduledScan, ScanType, @@ -83,8 +83,8 @@ 'ConfigurationProfilePreferenceUpdate', 'ConfigurationProfilePreferenceVmBackup', 'ErrorAdditionalInfo', + 'ErrorDetail', 'ErrorResponse', - 'ErrorResponseError', 'Operation', 'OperationDisplay', 'OperationList', @@ -94,7 +94,7 @@ 'UpdateResource', 'ConfigurationProfile', 'EnableRealTimeProtection', - 'ProvisioningStatus', + 'ProvisioningState', 'ResourceIdentityType', 'RunScheduledScan', 'ScanType', diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_automanage_client_enums.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_automanage_client_enums.py index 79304db864cd..07ff6e71f9bb 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_automanage_client_enums.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_automanage_client_enums.py @@ -6,56 +6,74 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum +from enum import Enum, EnumMeta +from six import with_metaclass -class ConfigurationProfile(str, Enum): +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class ConfigurationProfile(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): """A value indicating configuration profile. """ - azure_virtual_machine_best_practices_dev_test = "Azure virtual machine best practices – Dev/Test" - azure_virtual_machine_best_practices_production = "Azure virtual machine best practices – Production" + AZURE_VIRTUAL_MACHINE_BEST_PRACTICES_DEV_TEST = "Azure virtual machine best practices – Dev/Test" + AZURE_VIRTUAL_MACHINE_BEST_PRACTICES_PRODUCTION = "Azure virtual machine best practices – Production" -class EnableRealTimeProtection(str, Enum): +class EnableRealTimeProtection(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): """Enables or disables Real Time Protection """ - true = "True" - false = "False" + TRUE = "True" + FALSE = "False" -class ProvisioningStatus(str, Enum): +class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): """The state of onboarding, which only appears in the response. """ - succeeded = "Succeeded" - failed = "Failed" - created = "Created" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CREATED = "Created" -class ResourceIdentityType(str, Enum): +class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): """The type of identity used for the Automanage account. Currently, the only supported type is 'SystemAssigned', which implicitly creates an identity. """ - system_assigned = "SystemAssigned" - none = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + NONE = "None" -class RunScheduledScan(str, Enum): +class RunScheduledScan(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): """Enables or disables a periodic scan for antimalware """ - true = "True" - false = "False" + TRUE = "True" + FALSE = "False" -class ScanType(str, Enum): +class ScanType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): """Type of scheduled scan """ - quick = "Quick" - full = "Full" + QUICK = "Quick" + FULL = "Full" -class UpdateStatus(str, Enum): +class UpdateStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): """The state of compliance, which only appears in the response. """ - succeeded = "Succeeded" - failed = "Failed" - created = "Created" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CREATED = "Created" diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models.py index 4a02132654d4..eaf6de6d0205 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models.py @@ -11,17 +11,17 @@ class Resource(msrest.serialization.Model): - """Resource. + """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str """ @@ -48,19 +48,19 @@ def __init__( class TrackedResource(Resource): - """The resource model definition for a ARM tracked top level resource. + """The resource model definition for an Azure Resource Manager tracked top level resource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str :param tags: A set of tags. Resource tags. :type tags: dict[str, str] @@ -99,13 +99,13 @@ class Account(TrackedResource): All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str :param tags: A set of tags. Resource tags. :type tags: dict[str, str] @@ -240,13 +240,13 @@ class ConfigurationProfileAssignment(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str :param properties: Properties of the configuration profile assignment. :type properties: ~automanage_client.models.ConfigurationProfileAssignmentProperties @@ -334,15 +334,15 @@ class ConfigurationProfileAssignmentProperties(msrest.serialization.Model): :param configuration_profile_preference_id: The configuration profile custom preferences ARM resource URI. :type configuration_profile_preference_id: str - :ivar provisioning_status: The state of onboarding, which only appears in the response. - Possible values include: "Succeeded", "Failed", "Created". - :vartype provisioning_status: str or ~automanage_client.models.ProvisioningStatus + :ivar provisioning_state: The state of onboarding, which only appears in the response. Possible + values include: "Succeeded", "Failed", "Created". + :vartype provisioning_state: str or ~automanage_client.models.ProvisioningState :param compliance: The configuration setting for the configuration profile. :type compliance: ~automanage_client.models.ConfigurationProfileAssignmentCompliance """ _validation = { - 'provisioning_status': {'readonly': True}, + 'provisioning_state': {'readonly': True}, } _attribute_map = { @@ -350,7 +350,7 @@ class ConfigurationProfileAssignmentProperties(msrest.serialization.Model): 'target_id': {'key': 'targetId', 'type': 'str'}, 'account_id': {'key': 'accountId', 'type': 'str'}, 'configuration_profile_preference_id': {'key': 'configurationProfilePreferenceId', 'type': 'str'}, - 'provisioning_status': {'key': 'provisioningStatus', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, 'compliance': {'key': 'compliance', 'type': 'ConfigurationProfileAssignmentCompliance'}, } @@ -363,7 +363,7 @@ def __init__( self.target_id = kwargs.get('target_id', None) self.account_id = kwargs.get('account_id', None) self.configuration_profile_preference_id = kwargs.get('configuration_profile_preference_id', None) - self.provisioning_status = None + self.provisioning_state = None self.compliance = kwargs.get('compliance', None) @@ -374,13 +374,13 @@ class ConfigurationProfilePreference(TrackedResource): All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str :param tags: A set of tags. Resource tags. :type tags: dict[str, str] @@ -580,27 +580,8 @@ def __init__( self.info = None -class ErrorResponse(msrest.serialization.Model): - """The resource management error response. - - :param error: The error object. - :type error: ~automanage_client.models.ErrorResponseError - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ErrorResponseError(msrest.serialization.Model): - """The error object. +class ErrorDetail(msrest.serialization.Model): + """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -611,7 +592,7 @@ class ErrorResponseError(msrest.serialization.Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: list[~automanage_client.models.ErrorResponse] + :vartype details: list[~automanage_client.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~automanage_client.models.ErrorAdditionalInfo] """ @@ -628,7 +609,7 @@ class ErrorResponseError(msrest.serialization.Model): 'code': {'key': 'code', 'type': 'str'}, 'message': {'key': 'message', 'type': 'str'}, 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, + 'details': {'key': 'details', 'type': '[ErrorDetail]'}, 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } @@ -636,7 +617,7 @@ def __init__( self, **kwargs ): - super(ErrorResponseError, self).__init__(**kwargs) + super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None self.target = None @@ -644,6 +625,25 @@ def __init__( self.additional_info = None +class ErrorResponse(msrest.serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + :param error: The error object. + :type error: ~automanage_client.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + class Operation(msrest.serialization.Model): """Automanage REST API operation. @@ -727,17 +727,17 @@ def __init__( class ProxyResource(Resource): - """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. + """The resource model definition for an Azure Resource Manager proxy resource. It will have everything other than required location and tags. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str """ diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models_py3.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models_py3.py index 733188416af6..352faa43a2b8 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models_py3.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models_py3.py @@ -15,17 +15,17 @@ class Resource(msrest.serialization.Model): - """Resource. + """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str """ @@ -52,19 +52,19 @@ def __init__( class TrackedResource(Resource): - """The resource model definition for a ARM tracked top level resource. + """The resource model definition for an Azure Resource Manager tracked top level resource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str :param tags: A set of tags. Resource tags. :type tags: dict[str, str] @@ -106,13 +106,13 @@ class Account(TrackedResource): All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str :param tags: A set of tags. Resource tags. :type tags: dict[str, str] @@ -260,13 +260,13 @@ class ConfigurationProfileAssignment(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str :param properties: Properties of the configuration profile assignment. :type properties: ~automanage_client.models.ConfigurationProfileAssignmentProperties @@ -358,15 +358,15 @@ class ConfigurationProfileAssignmentProperties(msrest.serialization.Model): :param configuration_profile_preference_id: The configuration profile custom preferences ARM resource URI. :type configuration_profile_preference_id: str - :ivar provisioning_status: The state of onboarding, which only appears in the response. - Possible values include: "Succeeded", "Failed", "Created". - :vartype provisioning_status: str or ~automanage_client.models.ProvisioningStatus + :ivar provisioning_state: The state of onboarding, which only appears in the response. Possible + values include: "Succeeded", "Failed", "Created". + :vartype provisioning_state: str or ~automanage_client.models.ProvisioningState :param compliance: The configuration setting for the configuration profile. :type compliance: ~automanage_client.models.ConfigurationProfileAssignmentCompliance """ _validation = { - 'provisioning_status': {'readonly': True}, + 'provisioning_state': {'readonly': True}, } _attribute_map = { @@ -374,7 +374,7 @@ class ConfigurationProfileAssignmentProperties(msrest.serialization.Model): 'target_id': {'key': 'targetId', 'type': 'str'}, 'account_id': {'key': 'accountId', 'type': 'str'}, 'configuration_profile_preference_id': {'key': 'configurationProfilePreferenceId', 'type': 'str'}, - 'provisioning_status': {'key': 'provisioningStatus', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, 'compliance': {'key': 'compliance', 'type': 'ConfigurationProfileAssignmentCompliance'}, } @@ -393,7 +393,7 @@ def __init__( self.target_id = target_id self.account_id = account_id self.configuration_profile_preference_id = configuration_profile_preference_id - self.provisioning_status = None + self.provisioning_state = None self.compliance = compliance @@ -404,13 +404,13 @@ class ConfigurationProfilePreference(TrackedResource): All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str :param tags: A set of tags. Resource tags. :type tags: dict[str, str] @@ -634,29 +634,8 @@ def __init__( self.info = None -class ErrorResponse(msrest.serialization.Model): - """The resource management error response. - - :param error: The error object. - :type error: ~automanage_client.models.ErrorResponseError - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, - } - - def __init__( - self, - *, - error: Optional["ErrorResponseError"] = None, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = error - - -class ErrorResponseError(msrest.serialization.Model): - """The error object. +class ErrorDetail(msrest.serialization.Model): + """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -667,7 +646,7 @@ class ErrorResponseError(msrest.serialization.Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: list[~automanage_client.models.ErrorResponse] + :vartype details: list[~automanage_client.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~automanage_client.models.ErrorAdditionalInfo] """ @@ -684,7 +663,7 @@ class ErrorResponseError(msrest.serialization.Model): 'code': {'key': 'code', 'type': 'str'}, 'message': {'key': 'message', 'type': 'str'}, 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, + 'details': {'key': 'details', 'type': '[ErrorDetail]'}, 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } @@ -692,7 +671,7 @@ def __init__( self, **kwargs ): - super(ErrorResponseError, self).__init__(**kwargs) + super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None self.target = None @@ -700,6 +679,27 @@ def __init__( self.additional_info = None +class ErrorResponse(msrest.serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + :param error: The error object. + :type error: ~automanage_client.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDetail"] = None, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + class Operation(msrest.serialization.Model): """Automanage REST API operation. @@ -795,17 +795,17 @@ def __init__( class ProxyResource(Resource): - """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. + """The resource model definition for an Azure Resource Manager proxy resource. It will have everything other than required location and tags. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource Id for the resource. Ex - + :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str """ diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_accounts_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_accounts_operations.py index d97b79a4a8b1..75b6603431cd 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_accounts_operations.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_accounts_operations.py @@ -8,13 +8,13 @@ from typing import TYPE_CHECKING import warnings -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 +from .. import models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -37,7 +37,7 @@ class AccountsOperations(object): :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): self._client = client @@ -49,10 +49,10 @@ def create_or_update( self, account_name, # type: str resource_group_name, # type: str - parameters, # type: "models.Account" + parameters, # type: "_models.Account" **kwargs # type: Any ): - # type: (...) -> "models.Account" + # type: (...) -> "_models.Account" """Creates an Automanage Account. :param account_name: Name of the Automanage account. @@ -66,11 +66,14 @@ def create_or_update( :rtype: ~automanage_client.models.Account :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Account"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-06-30-preview" content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL url = self.create_or_update.metadata['url'] # type: ignore @@ -88,19 +91,18 @@ def create_or_update( # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'Account') body_content_kwargs['content'] = body_content request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -121,7 +123,7 @@ def get( resource_group_name, # type: str **kwargs # type: Any ): - # type: (...) -> "models.Account" + # type: (...) -> "_models.Account" """Get information about a Automanage account. :param account_name: The Automanage account name. @@ -133,10 +135,13 @@ def get( :rtype: ~automanage_client.models.Account :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Account"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-06-30-preview" + accept = "application/json" # Construct URL url = self.get.metadata['url'] # type: ignore @@ -153,7 +158,7 @@ def get( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) @@ -161,7 +166,7 @@ def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Account', pipeline_response) @@ -191,9 +196,12 @@ def delete( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-06-30-preview" + accept = "application/json" # Construct URL url = self.delete.metadata['url'] # type: ignore @@ -210,6 +218,7 @@ def delete( # 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 = self._client._pipeline.run(request, stream=False, **kwargs) @@ -217,7 +226,7 @@ def delete( if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -229,10 +238,10 @@ def update( self, account_name, # type: str resource_group_name, # type: str - parameters, # type: "models.AccountUpdate" + parameters, # type: "_models.AccountUpdate" **kwargs # type: Any ): - # type: (...) -> "models.Account" + # type: (...) -> "_models.Account" """Updates an Automanage Account. :param account_name: Name of the Automanage account. @@ -246,11 +255,14 @@ def update( :rtype: ~automanage_client.models.Account :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Account"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-06-30-preview" content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL url = self.update.metadata['url'] # type: ignore @@ -268,19 +280,18 @@ def update( # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'AccountUpdate') body_content_kwargs['content'] = body_content request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Account', pipeline_response) @@ -296,7 +307,7 @@ def list_by_resource_group( resource_group_name, # type: str **kwargs # type: Any ): - # type: (...) -> Iterable["models.AccountList"] + # type: (...) -> Iterable["_models.AccountList"] """Retrieve a list of Automanage accounts within a given resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -306,15 +317,18 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.AccountList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.AccountList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccountList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-06-30-preview" + accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL @@ -349,7 +363,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -364,7 +378,7 @@ def list_by_subscription( self, **kwargs # type: Any ): - # type: (...) -> Iterable["models.AccountList"] + # type: (...) -> Iterable["_models.AccountList"] """Retrieve a list of Automanage accounts within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -372,15 +386,18 @@ def list_by_subscription( :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.AccountList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.AccountList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccountList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-06-30-preview" + accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL @@ -414,7 +431,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_assignments_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_assignments_operations.py index 3ce28d9f8d6f..ade8c8f4b980 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_assignments_operations.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_assignments_operations.py @@ -8,7 +8,7 @@ from typing import TYPE_CHECKING import warnings -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 @@ -16,7 +16,7 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from .. import models +from .. import models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -39,7 +39,7 @@ class ConfigurationProfileAssignmentsOperations(object): :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): self._client = client @@ -52,15 +52,18 @@ def _create_or_update_initial( configuration_profile_assignment_name, # type: str resource_group_name, # type: str vm_name, # type: str - parameters, # type: "models.ConfigurationProfileAssignment" + parameters, # type: "_models.ConfigurationProfileAssignment" **kwargs # type: Any ): - # type: (...) -> "models.ConfigurationProfileAssignment" - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignment"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + # type: (...) -> "_models.ConfigurationProfileAssignment" + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-06-30-preview" content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL url = self._create_or_update_initial.metadata['url'] # type: ignore @@ -79,19 +82,18 @@ def _create_or_update_initial( # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'ConfigurationProfileAssignment') body_content_kwargs['content'] = body_content request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -111,21 +113,21 @@ def begin_create_or_update( configuration_profile_assignment_name, # type: str resource_group_name, # type: str vm_name, # type: str - parameters, # type: "models.ConfigurationProfileAssignment" + parameters, # type: "_models.ConfigurationProfileAssignment" **kwargs # type: Any ): - # type: (...) -> LROPoller["models.ConfigurationProfileAssignment"] + # type: (...) -> LROPoller["_models.ConfigurationProfileAssignment"] """Creates an association between a VM and Automanage configuration profile. :param configuration_profile_assignment_name: Name of the configuration profile assignment. - Only default is supported. + Only default is supported. :type configuration_profile_assignment_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str :param parameters: Parameters supplied to the create or update configuration profile - assignment. + assignment. :type parameters: ~automanage_client.models.ConfigurationProfileAssignment :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. @@ -138,7 +140,7 @@ def begin_create_or_update( :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignment"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignment"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval @@ -164,7 +166,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + path_format_arguments = { + 'configurationProfileAssignmentName': self._serialize.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'vmName': self._serialize.url("vm_name", vm_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -185,7 +194,7 @@ def get( vm_name, # type: str **kwargs # type: Any ): - # type: (...) -> "models.ConfigurationProfileAssignment" + # type: (...) -> "_models.ConfigurationProfileAssignment" """Get information about a configuration profile assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -199,10 +208,13 @@ def get( :rtype: ~automanage_client.models.ConfigurationProfileAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignment"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-06-30-preview" + accept = "application/json" # Construct URL url = self.get.metadata['url'] # type: ignore @@ -220,7 +232,7 @@ def get( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) @@ -228,7 +240,7 @@ def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) @@ -261,9 +273,12 @@ def delete( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-06-30-preview" + accept = "application/json" # Construct URL url = self.delete.metadata['url'] # type: ignore @@ -281,6 +296,7 @@ def delete( # 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 = self._client._pipeline.run(request, stream=False, **kwargs) @@ -288,7 +304,7 @@ def delete( if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -301,7 +317,7 @@ def list( resource_group_name, # type: str **kwargs # type: Any ): - # type: (...) -> Iterable["models.ConfigurationProfileAssignmentList"] + # type: (...) -> Iterable["_models.ConfigurationProfileAssignmentList"] """Get list of configuration profile assignments. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -311,15 +327,18 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.ConfigurationProfileAssignmentList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignmentList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignmentList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-06-30-preview" + accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL @@ -354,7 +373,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -369,7 +388,7 @@ def list_by_subscription( self, **kwargs # type: Any ): - # type: (...) -> Iterable["models.ConfigurationProfileAssignmentList"] + # type: (...) -> Iterable["_models.ConfigurationProfileAssignmentList"] """Get list of configuration profile assignments under a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -377,15 +396,18 @@ def list_by_subscription( :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.ConfigurationProfileAssignmentList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignmentList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignmentList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-06-30-preview" + accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL @@ -419,7 +441,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_preferences_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_preferences_operations.py index 094cc67131d5..4539daa555ca 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_preferences_operations.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_preferences_operations.py @@ -8,13 +8,13 @@ from typing import TYPE_CHECKING import warnings -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 +from .. import models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -37,7 +37,7 @@ class ConfigurationProfilePreferencesOperations(object): :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): self._client = client @@ -49,10 +49,10 @@ def create_or_update( self, configuration_profile_preference_name, # type: str resource_group_name, # type: str - parameters, # type: "models.ConfigurationProfilePreference" + parameters, # type: "_models.ConfigurationProfilePreference" **kwargs # type: Any ): - # type: (...) -> "models.ConfigurationProfilePreference" + # type: (...) -> "_models.ConfigurationProfilePreference" """Creates a configuration profile preference. :param configuration_profile_preference_name: Name of the configuration profile preference. @@ -66,11 +66,14 @@ def create_or_update( :rtype: ~automanage_client.models.ConfigurationProfilePreference :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreference"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfilePreference"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-06-30-preview" content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL url = self.create_or_update.metadata['url'] # type: ignore @@ -88,19 +91,18 @@ def create_or_update( # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'ConfigurationProfilePreference') body_content_kwargs['content'] = body_content request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -121,7 +123,7 @@ def get( resource_group_name, # type: str **kwargs # type: Any ): - # type: (...) -> "models.ConfigurationProfilePreference" + # type: (...) -> "_models.ConfigurationProfilePreference" """Get information about a configuration profile preference. :param configuration_profile_preference_name: The configuration profile preference name. @@ -133,10 +135,13 @@ def get( :rtype: ~automanage_client.models.ConfigurationProfilePreference :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreference"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfilePreference"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-06-30-preview" + accept = "application/json" # Construct URL url = self.get.metadata['url'] # type: ignore @@ -153,7 +158,7 @@ def get( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) @@ -161,7 +166,7 @@ def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigurationProfilePreference', pipeline_response) @@ -191,9 +196,12 @@ def delete( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-06-30-preview" + accept = "application/json" # Construct URL url = self.delete.metadata['url'] # type: ignore @@ -210,6 +218,7 @@ def delete( # 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 = self._client._pipeline.run(request, stream=False, **kwargs) @@ -217,7 +226,7 @@ def delete( if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -229,10 +238,10 @@ def update( self, configuration_profile_preference_name, # type: str resource_group_name, # type: str - parameters, # type: "models.ConfigurationProfilePreferenceUpdate" + parameters, # type: "_models.ConfigurationProfilePreferenceUpdate" **kwargs # type: Any ): - # type: (...) -> "models.ConfigurationProfilePreference" + # type: (...) -> "_models.ConfigurationProfilePreference" """Updates a configuration profile preference. :param configuration_profile_preference_name: Name of the configuration profile preference. @@ -246,11 +255,14 @@ def update( :rtype: ~automanage_client.models.ConfigurationProfilePreference :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreference"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfilePreference"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-06-30-preview" content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL url = self.update.metadata['url'] # type: ignore @@ -268,19 +280,18 @@ def update( # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'ConfigurationProfilePreferenceUpdate') body_content_kwargs['content'] = body_content request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigurationProfilePreference', pipeline_response) @@ -296,7 +307,7 @@ def list_by_resource_group( resource_group_name, # type: str **kwargs # type: Any ): - # type: (...) -> Iterable["models.ConfigurationProfilePreferenceList"] + # type: (...) -> Iterable["_models.ConfigurationProfilePreferenceList"] """Retrieve a list of configuration profile preferences within a given resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -306,15 +317,18 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.ConfigurationProfilePreferenceList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreferenceList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfilePreferenceList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-06-30-preview" + accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL @@ -349,7 +363,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -364,7 +378,7 @@ def list_by_subscription( self, **kwargs # type: Any ): - # type: (...) -> Iterable["models.ConfigurationProfilePreferenceList"] + # type: (...) -> Iterable["_models.ConfigurationProfilePreferenceList"] """Retrieve a list of configuration profile preferences within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -372,15 +386,18 @@ def list_by_subscription( :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.ConfigurationProfilePreferenceList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreferenceList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfilePreferenceList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-06-30-preview" + accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL @@ -414,7 +431,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_operations.py index 7aac97cd377a..7c22ef9e48a4 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_operations.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_operations.py @@ -8,13 +8,13 @@ from typing import TYPE_CHECKING import warnings -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 +from .. import models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -37,7 +37,7 @@ class Operations(object): :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): self._client = client @@ -49,7 +49,7 @@ def list( self, **kwargs # type: Any ): - # type: (...) -> Iterable["models.OperationList"] + # type: (...) -> Iterable["_models.OperationList"] """Lists all of the available Automanage REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -57,15 +57,18 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.OperationList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.OperationList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-06-30-preview" + accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL @@ -95,7 +98,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)