diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/_meta.json b/sdk/deviceupdate/azure-mgmt-deviceupdate/_meta.json index 8c76729e5d66..f922d7211572 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/_meta.json +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/_meta.json @@ -1,11 +1,11 @@ { "autorest": "3.7.2", "use": [ - "@autorest/python@5.13.0", + "@autorest/python@5.16.0", "@autorest/modelerfour@4.19.3" ], - "commit": "d55b8005f05b040b852c15e74a0f3e36494a15e1", + "commit": "0e0473b5bd5590db2e44d0e702e44425b8195f79", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/deviceupdate/resource-manager/readme.md --multiapi --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/deviceupdate/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/deviceupdate/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/__init__.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/__init__.py index 9413c737f240..1e70f63a995f 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/__init__.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['DeviceUpdate'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/_configuration.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/_configuration.py index 410cbdee0bae..94eb366d2828 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/_configuration.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/_configuration.py @@ -29,8 +29,8 @@ class DeviceUpdateConfiguration(Configuration): # pylint: disable=too-many-inst :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The Azure subscription ID. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-04-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2022-10-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ @@ -41,7 +41,7 @@ def __init__( **kwargs: Any ) -> None: super(DeviceUpdateConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + api_version = kwargs.pop('api_version', "2022-10-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/_device_update.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/_device_update.py index 9464813bae2b..d764578a1583 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/_device_update.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/_device_update.py @@ -46,8 +46,8 @@ class DeviceUpdate(DeviceUpdateOperationsMixin): # pylint: disable=too-many-i :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2022-04-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2022-10-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -67,12 +67,24 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.accounts = AccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.instances = InstancesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connection_proxies = PrivateEndpointConnectionProxiesOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.accounts = AccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.instances = InstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connection_proxies = PrivateEndpointConnectionProxiesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/_vendor.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/_vendor.py index 138f663c53a4..9a7990533414 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/_vendor.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/_vendor.py @@ -5,8 +5,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from abc import ABC +from typing import TYPE_CHECKING + from azure.core.pipeline.transport import HttpRequest +from ._configuration import DeviceUpdateConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import PipelineClient + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -25,3 +36,10 @@ def _format_url_section(template, **kwargs): c for c in formatted_components if "{}".format(key.args[0]) not in c ] template = "/".join(components) + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "PipelineClient" + _config: DeviceUpdateConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/_version.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/_version.py index 8d50297ac8eb..e5754a47ce68 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/_version.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b4" +VERSION = "1.0.0b1" diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/__init__.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/__init__.py index f194c8d69716..505aa8b9aa67 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/__init__.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._device_update import DeviceUpdate + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['DeviceUpdate'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/_configuration.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/_configuration.py index 7c2cd96d157b..540a888aaad9 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/_configuration.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/_configuration.py @@ -29,8 +29,8 @@ class DeviceUpdateConfiguration(Configuration): # pylint: disable=too-many-inst :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The Azure subscription ID. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-04-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2022-10-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ @@ -41,7 +41,7 @@ def __init__( **kwargs: Any ) -> None: super(DeviceUpdateConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + api_version = kwargs.pop('api_version', "2022-10-01") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/_device_update.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/_device_update.py index 0944c47612be..76bf3996ae67 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/_device_update.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/_device_update.py @@ -46,8 +46,8 @@ class DeviceUpdate(DeviceUpdateOperationsMixin): # pylint: disable=too-many-i :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2022-04-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2022-10-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -67,12 +67,24 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.accounts = AccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.instances = InstancesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connection_proxies = PrivateEndpointConnectionProxiesOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.accounts = AccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.instances = InstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connection_proxies = PrivateEndpointConnectionProxiesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/_vendor.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/_vendor.py new file mode 100644 index 000000000000..2e632115bbf2 --- /dev/null +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import DeviceUpdateConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import AsyncPipelineClient + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "AsyncPipelineClient" + _config: DeviceUpdateConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/__init__.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/__init__.py index 39c22b434362..fcfbd4b1f52e 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/__init__.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/__init__.py @@ -14,6 +14,9 @@ from ._private_endpoint_connection_proxies_operations import PrivateEndpointConnectionProxiesOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'DeviceUpdateOperationsMixin', 'AccountsOperations', @@ -23,3 +26,5 @@ 'PrivateEndpointConnectionProxiesOperations', 'Operations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_accounts_operations.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_accounts_operations.py index b7a7d7d57d79..f1e8dcedade1 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_accounts_operations.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_accounts_operations.py @@ -6,7 +6,7 @@ # 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, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,42 +16,42 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request from ...operations._accounts_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_head_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request_initial +from .._vendor import MixinABC 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. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~device_update.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~device_update.aio.DeviceUpdate`'s + :attr:`accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.AccountList"]: + ) -> AsyncIterable[_models.AccountList]: """Returns list of Accounts. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,13 +59,16 @@ def list_by_subscription( :rtype: ~azure.core.async_paging.AsyncItemPaged[~device_update.models.AccountList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccountList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccountList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -73,9 +76,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -83,9 +88,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,7 +131,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AccountList"]: + ) -> AsyncIterable[_models.AccountList]: """Returns list of Accounts. :param resource_group_name: The resource group name. @@ -134,13 +141,16 @@ def list_by_resource_group( :rtype: ~azure.core.async_paging.AsyncItemPaged[~device_update.models.AccountList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccountList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccountList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -149,9 +159,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -160,9 +172,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -202,7 +216,7 @@ async def get( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.Account": + ) -> _models.Account: """Returns account details for the given account name. :param resource_group_name: The resource group name. @@ -214,13 +228,16 @@ async def get( :rtype: ~device_update.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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Account] request = build_get_request( @@ -229,11 +246,13 @@ async def get( account_name=account_name, api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -273,13 +292,16 @@ async def head( :rtype: bool :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_head_request( @@ -288,11 +310,13 @@ async def head( account_name=account_name, api_version=api_version, template_url=self.head.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -315,17 +339,20 @@ async def _create_initial( self, resource_group_name: str, account_name: str, - account: "_models.Account", + account: _models.Account, **kwargs: Any - ) -> "_models.Account": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] + ) -> _models.Account: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Account] _json = self._serialize.body(account, 'Account') @@ -337,11 +364,13 @@ async def _create_initial( content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -367,9 +396,9 @@ async def begin_create( self, resource_group_name: str, account_name: str, - account: "_models.Account", + account: _models.Account, **kwargs: Any - ) -> AsyncLROPoller["_models.Account"]: + ) -> AsyncLROPoller[_models.Account]: """Creates or updates Account. :param resource_group_name: The resource group name. @@ -391,37 +420,47 @@ async def begin_create( :rtype: ~azure.core.polling.AsyncLROPoller[~device_update.models.Account] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Account] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, account=account, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('Account', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -440,13 +479,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -455,11 +497,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements account_name=account_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -501,20 +545,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -524,8 +573,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -542,17 +597,20 @@ async def _update_initial( self, resource_group_name: str, account_name: str, - account_update_payload: "_models.AccountUpdate", + account_update_payload: _models.AccountUpdate, **kwargs: Any - ) -> "_models.Account": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] + ) -> _models.Account: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Account] _json = self._serialize.body(account_update_payload, 'AccountUpdate') @@ -564,11 +622,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -598,9 +658,9 @@ async def begin_update( self, resource_group_name: str, account_name: str, - account_update_payload: "_models.AccountUpdate", + account_update_payload: _models.AccountUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Account"]: + ) -> AsyncLROPoller[_models.Account]: """Updates account's patchable properties. :param resource_group_name: The resource group name. @@ -622,37 +682,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~device_update.models.Account] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Account] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, account_update_payload=account_update_payload, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('Account', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_device_update_operations.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_device_update_operations.py index f12d4dc6169e..5e68e629bfb3 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_device_update_operations.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_device_update_operations.py @@ -13,22 +13,24 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._device_update_operations import build_check_name_availability_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DeviceUpdateOperationsMixin: +class DeviceUpdateOperationsMixin(MixinABC): @distributed_trace_async async def check_name_availability( self, - request: "_models.CheckNameAvailabilityRequest", + request: _models.CheckNameAvailabilityRequest, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResponse": + ) -> _models.CheckNameAvailabilityResponse: """Checks ADU resource name availability. :param request: Check Name Availability Request. @@ -38,14 +40,17 @@ async def check_name_availability( :rtype: ~device_update.models.CheckNameAvailabilityResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResponse] _json = self._serialize.body(request, 'CheckNameAvailabilityRequest') @@ -55,11 +60,13 @@ async def check_name_availability( content_type=content_type, json=_json, template_url=self.check_name_availability.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_instances_operations.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_instances_operations.py index 75109d90a1fd..ab22f0ec3678 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_instances_operations.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_instances_operations.py @@ -6,7 +6,7 @@ # 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, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,36 +16,36 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request from ...operations._instances_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_head_request, build_list_by_account_request, build_update_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class InstancesOperations: - """InstancesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~device_update.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~device_update.aio.DeviceUpdate`'s + :attr:`instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_account( @@ -53,7 +53,7 @@ def list_by_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.InstanceList"]: + ) -> AsyncIterable[_models.InstanceList]: """Returns instances for the given account name. :param resource_group_name: The resource group name. @@ -65,13 +65,16 @@ def list_by_account( :rtype: ~azure.core.async_paging.AsyncItemPaged[~device_update.models.InstanceList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.InstanceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.InstanceList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -81,9 +84,11 @@ def prepare_request(next_link=None): account_name=account_name, api_version=api_version, template_url=self.list_by_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -93,9 +98,11 @@ def prepare_request(next_link=None): account_name=account_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -136,7 +143,7 @@ async def get( account_name: str, instance_name: str, **kwargs: Any - ) -> "_models.Instance": + ) -> _models.Instance: """Returns instance details for the given instance and account name. :param resource_group_name: The resource group name. @@ -150,13 +157,16 @@ async def get( :rtype: ~device_update.models.Instance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Instance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Instance] request = build_get_request( @@ -166,11 +176,13 @@ async def get( instance_name=instance_name, api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -213,13 +225,16 @@ async def head( :rtype: bool :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_head_request( @@ -229,11 +244,13 @@ async def head( instance_name=instance_name, api_version=api_version, template_url=self.head.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -257,17 +274,20 @@ async def _create_initial( resource_group_name: str, account_name: str, instance_name: str, - instance: "_models.Instance", + instance: _models.Instance, **kwargs: Any - ) -> "_models.Instance": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Instance"] + ) -> _models.Instance: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Instance] _json = self._serialize.body(instance, 'Instance') @@ -280,11 +300,13 @@ async def _create_initial( content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,9 +333,9 @@ async def begin_create( resource_group_name: str, account_name: str, instance_name: str, - instance: "_models.Instance", + instance: _models.Instance, **kwargs: Any - ) -> AsyncLROPoller["_models.Instance"]: + ) -> AsyncLROPoller[_models.Instance]: """Creates or updates instance. :param resource_group_name: The resource group name. @@ -337,17 +359,20 @@ async def begin_create( :rtype: ~azure.core.polling.AsyncLROPoller[~device_update.models.Instance] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Instance] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Instance"] 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, instance_name=instance_name, @@ -355,20 +380,27 @@ async def begin_create( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('Instance', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -388,13 +420,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements instance_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -404,11 +439,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements instance_name=instance_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -453,21 +490,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, instance_name=instance_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -477,8 +519,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -497,9 +545,9 @@ async def update( resource_group_name: str, account_name: str, instance_name: str, - tag_update_payload: "_models.TagUpdate", + tag_update_payload: _models.TagUpdate, **kwargs: Any - ) -> "_models.Instance": + ) -> _models.Instance: """Updates instance's tags. :param resource_group_name: The resource group name. @@ -515,14 +563,17 @@ async def update( :rtype: ~device_update.models.Instance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Instance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Instance] _json = self._serialize.body(tag_update_payload, 'TagUpdate') @@ -535,11 +586,13 @@ async def update( content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_operations.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_operations.py index a36617969824..5ae29280ce21 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_operations.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_operations.py @@ -14,41 +14,41 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~device_update.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~device_update.aio.DeviceUpdate`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """Returns list of operations for Microsoft.DeviceUpdate resource provider. :keyword callable cls: A custom type or function that will be passed the direct response @@ -56,31 +56,38 @@ def list( :rtype: ~azure.core.async_paging.AsyncItemPaged[~device_update.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_patch.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_private_endpoint_connection_proxies_operations.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_private_endpoint_connection_proxies_operations.py index ab57fe5de3c7..bfcab42d3280 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_private_endpoint_connection_proxies_operations.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_private_endpoint_connection_proxies_operations.py @@ -6,7 +6,7 @@ # 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, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,36 +16,36 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request from ...operations._private_endpoint_connection_proxies_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_account_request, build_update_private_endpoint_properties_request, build_validate_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateEndpointConnectionProxiesOperations: - """PrivateEndpointConnectionProxiesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~device_update.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~device_update.aio.DeviceUpdate`'s + :attr:`private_endpoint_connection_proxies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_account( @@ -53,7 +53,7 @@ def list_by_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionProxyListResult"]: + ) -> AsyncIterable[_models.PrivateEndpointConnectionProxyListResult]: """(INTERNAL - DO NOT USE) List all private endpoint connection proxies in a device update account. @@ -68,13 +68,16 @@ def list_by_account( ~azure.core.async_paging.AsyncItemPaged[~device_update.models.PrivateEndpointConnectionProxyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionProxyListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionProxyListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -84,9 +87,11 @@ def prepare_request(next_link=None): account_name=account_name, api_version=api_version, template_url=self.list_by_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -96,9 +101,11 @@ def prepare_request(next_link=None): account_name=account_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -138,7 +145,7 @@ async def validate( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, private_endpoint_connection_proxy_id: str, - private_endpoint_connection_proxy: "_models.PrivateEndpointConnectionProxy", + private_endpoint_connection_proxy: _models.PrivateEndpointConnectionProxy, **kwargs: Any ) -> None: """(INTERNAL - DO NOT USE) Validates a private endpoint connection proxy object. @@ -158,14 +165,17 @@ async def validate( # pylint: disable=inconsistent-return-statements :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(private_endpoint_connection_proxy, 'PrivateEndpointConnectionProxy') @@ -178,11 +188,13 @@ async def validate( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self.validate.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -206,7 +218,7 @@ async def update_private_endpoint_properties( # pylint: disable=inconsistent-re resource_group_name: str, account_name: str, private_endpoint_connection_proxy_id: str, - private_endpoint_update: "_models.PrivateEndpointUpdate", + private_endpoint_update: _models.PrivateEndpointUpdate, **kwargs: Any ) -> None: """(INTERNAL - DO NOT USE) Updates a private endpoint inside the private endpoint connection proxy @@ -227,14 +239,17 @@ async def update_private_endpoint_properties( # pylint: disable=inconsistent-re :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(private_endpoint_update, 'PrivateEndpointUpdate') @@ -247,11 +262,13 @@ async def update_private_endpoint_properties( # pylint: disable=inconsistent-re content_type=content_type, json=_json, template_url=self.update_private_endpoint_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -276,7 +293,7 @@ async def get( account_name: str, private_endpoint_connection_proxy_id: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnectionProxy": + ) -> _models.PrivateEndpointConnectionProxy: """(INTERNAL - DO NOT USE) Get the specified private endpoint connection proxy associated with the device update account. @@ -292,13 +309,16 @@ async def get( :rtype: ~device_update.models.PrivateEndpointConnectionProxy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionProxy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionProxy] request = build_get_request( @@ -308,11 +328,13 @@ async def get( private_endpoint_connection_proxy_id=private_endpoint_connection_proxy_id, api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -339,17 +361,20 @@ async def _create_or_update_initial( resource_group_name: str, account_name: str, private_endpoint_connection_proxy_id: str, - private_endpoint_connection_proxy: "_models.PrivateEndpointConnectionProxy", + private_endpoint_connection_proxy: _models.PrivateEndpointConnectionProxy, **kwargs: Any - ) -> "_models.PrivateEndpointConnectionProxy": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionProxy"] + ) -> _models.PrivateEndpointConnectionProxy: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionProxy] _json = self._serialize.body(private_endpoint_connection_proxy, 'PrivateEndpointConnectionProxy') @@ -362,11 +387,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -393,9 +420,9 @@ async def begin_create_or_update( resource_group_name: str, account_name: str, private_endpoint_connection_proxy_id: str, - private_endpoint_connection_proxy: "_models.PrivateEndpointConnectionProxy", + private_endpoint_connection_proxy: _models.PrivateEndpointConnectionProxy, **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnectionProxy"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnectionProxy]: """(INTERNAL - DO NOT USE) Creates or updates the specified private endpoint connection proxy resource associated with the device update account. @@ -423,17 +450,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~device_update.models.PrivateEndpointConnectionProxy] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionProxy] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionProxy"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_proxy_id=private_endpoint_connection_proxy_id, @@ -441,20 +471,27 @@ async def begin_create_or_update( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnectionProxy', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -474,13 +511,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements private_endpoint_connection_proxy_id: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -490,11 +530,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements private_endpoint_connection_proxy_id=private_endpoint_connection_proxy_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -541,21 +583,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_proxy_id=private_endpoint_connection_proxy_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -565,8 +612,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_private_endpoint_connections_operations.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_private_endpoint_connections_operations.py index e5fe377adbf0..665bfa116caf 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_private_endpoint_connections_operations.py @@ -6,7 +6,7 @@ # 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, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,36 +16,36 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request from ...operations._private_endpoint_connections_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_account_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~device_update.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~device_update.aio.DeviceUpdate`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_account( @@ -53,7 +53,7 @@ def list_by_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: """List all private endpoint connections in a device update account. :param resource_group_name: The resource group name. @@ -67,13 +67,16 @@ def list_by_account( ~azure.core.async_paging.AsyncItemPaged[~device_update.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -83,9 +86,11 @@ def prepare_request(next_link=None): account_name=account_name, api_version=api_version, template_url=self.list_by_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -95,9 +100,11 @@ def prepare_request(next_link=None): account_name=account_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -138,7 +145,7 @@ async def get( account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Get the specified private endpoint connection associated with the device update account. :param resource_group_name: The resource group name. @@ -153,13 +160,16 @@ async def get( :rtype: ~device_update.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -169,11 +179,13 @@ async def get( private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -200,17 +212,20 @@ async def _create_or_update_initial( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') @@ -223,11 +238,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -254,9 +271,9 @@ async def begin_create_or_update( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the device update account. @@ -282,17 +299,20 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~device_update.models.PrivateEndpointConnection] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -300,20 +320,27 @@ async def begin_create_or_update( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -333,13 +360,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -349,11 +379,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -399,21 +431,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -423,8 +460,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_private_link_resources_operations.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_private_link_resources_operations.py index 45f5b36541ba..5e3b55bb98e9 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_private_link_resources_operations.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/aio/operations/_private_link_resources_operations.py @@ -15,35 +15,35 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request, build_list_by_account_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateLinkResourcesOperations: - """PrivateLinkResourcesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~device_update.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~device_update.aio.DeviceUpdate`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_account( @@ -51,7 +51,7 @@ def list_by_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResourceListResult"]: + ) -> AsyncIterable[_models.PrivateLinkResourceListResult]: """List all private link resources in a device update account. :param resource_group_name: The resource group name. @@ -65,13 +65,16 @@ def list_by_account( ~azure.core.async_paging.AsyncItemPaged[~device_update.models.PrivateLinkResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -81,9 +84,11 @@ def prepare_request(next_link=None): account_name=account_name, api_version=api_version, template_url=self.list_by_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -93,9 +98,11 @@ def prepare_request(next_link=None): account_name=account_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -136,7 +143,7 @@ async def get( account_name: str, group_id: str, **kwargs: Any - ) -> "_models.GroupInformation": + ) -> _models.GroupInformation: """Get the specified private link resource associated with the device update account. :param resource_group_name: The resource group name. @@ -150,13 +157,16 @@ async def get( :rtype: ~device_update.models.GroupInformation :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupInformation"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GroupInformation] request = build_get_request( @@ -166,11 +176,13 @@ async def get( group_id=group_id, api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/models/__init__.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/models/__init__.py index 8a44b8101618..4e8f3bee038b 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/models/__init__.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/models/__init__.py @@ -66,7 +66,9 @@ Role, SKU, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Account', 'AccountList', @@ -125,3 +127,5 @@ 'Role', 'SKU', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/models/_device_update_enums.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/models/_device_update_enums.py index 12b3a1e33399..23df01abfbe2 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/models/_device_update_enums.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/models/_device_update_enums.py @@ -7,30 +7,29 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. """ INTERNAL = "Internal" -class AuthenticationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Authentication Type """ KEY_BASED = "KeyBased" -class CheckNameAvailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CheckNameAvailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason why the given name is not available. """ INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource. """ @@ -39,7 +38,7 @@ class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class GroupIdProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GroupIdProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state of private link group ID. """ @@ -47,7 +46,7 @@ class GroupIdProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum FAILED = "Failed" CANCELED = "Canceled" -class ManagedServiceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). """ @@ -57,7 +56,7 @@ class ManagedServiceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, En USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" -class Origin(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" """ @@ -66,7 +65,7 @@ class Origin(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM = "system" USER_SYSTEM = "user,system" -class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state. """ @@ -75,7 +74,7 @@ class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveE DELETING = "Deleting" FAILED = "Failed" -class PrivateEndpointConnectionProxyProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProxyProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state. """ @@ -84,7 +83,7 @@ class PrivateEndpointConnectionProxyProvisioningState(with_metaclass(CaseInsensi DELETING = "Deleting" FAILED = "Failed" -class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The private endpoint connection status. """ @@ -92,7 +91,7 @@ class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumM APPROVED = "Approved" REJECTED = "Rejected" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning state. """ @@ -103,21 +102,21 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ACCEPTED = "Accepted" CREATING = "Creating" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Whether or not public network access is allowed for the account. """ ENABLED = "Enabled" DISABLED = "Disabled" -class Role(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Role(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Whether the location is primary or failover """ PRIMARY = "Primary" FAILOVER = "Failover" -class SKU(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SKU(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Device Update Sku """ diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/models/_models_py3.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/models/_models_py3.py index b08d5a5ca708..a357038dcc1e 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/models/_models_py3.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/models/_models_py3.py @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._device_update_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class Resource(msrest.serialization.Model): @@ -143,19 +145,18 @@ class Account(TrackedResource): :vartype location: str :ivar identity: The type of identity used for the resource. :vartype identity: ~device_update.models.ManagedServiceIdentity - :ivar provisioning_state: Provisioning state. Possible values include: "Succeeded", "Deleted", + :ivar provisioning_state: Provisioning state. Known values are: "Succeeded", "Deleted", "Failed", "Canceled", "Accepted", "Creating". :vartype provisioning_state: str or ~device_update.models.ProvisioningState :ivar host_name: API host name. :vartype host_name: str :ivar public_network_access: Whether or not public network access is allowed for the account. - Possible values include: "Enabled", "Disabled". Default value: "Enabled". + Known values are: "Enabled", "Disabled". Default value: "Enabled". :vartype public_network_access: str or ~device_update.models.PublicNetworkAccess :ivar private_endpoint_connections: List of private endpoint connections associated with the account. :vartype private_endpoint_connections: list[~device_update.models.PrivateEndpointConnection] - :ivar sku: Device Update Sku. Possible values include: "Free", "Standard". Default value: - "Standard". + :ivar sku: Device Update Sku. Known values are: "Free", "Standard". Default value: "Standard". :vartype sku: str or ~device_update.models.SKU :ivar locations: Device Update account primary and failover location details. :vartype locations: list[~device_update.models.Location] @@ -193,10 +194,10 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["ManagedServiceIdentity"] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = "Enabled", - private_endpoint_connections: Optional[List["PrivateEndpointConnection"]] = None, - sku: Optional[Union[str, "SKU"]] = "Standard", + identity: Optional["_models.ManagedServiceIdentity"] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = "Enabled", + private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None, + sku: Optional[Union[str, "_models.SKU"]] = "Standard", **kwargs ): """ @@ -207,12 +208,12 @@ def __init__( :keyword identity: The type of identity used for the resource. :paramtype identity: ~device_update.models.ManagedServiceIdentity :keyword public_network_access: Whether or not public network access is allowed for the - account. Possible values include: "Enabled", "Disabled". Default value: "Enabled". + account. Known values are: "Enabled", "Disabled". Default value: "Enabled". :paramtype public_network_access: str or ~device_update.models.PublicNetworkAccess :keyword private_endpoint_connections: List of private endpoint connections associated with the account. :paramtype private_endpoint_connections: list[~device_update.models.PrivateEndpointConnection] - :keyword sku: Device Update Sku. Possible values include: "Free", "Standard". Default value: + :keyword sku: Device Update Sku. Known values are: "Free", "Standard". Default value: "Standard". :paramtype sku: str or ~device_update.models.SKU """ @@ -244,7 +245,7 @@ def __init__( self, *, next_link: Optional[str] = None, - value: Optional[List["Account"]] = None, + value: Optional[List["_models.Account"]] = None, **kwargs ): """ @@ -307,7 +308,7 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - identity: Optional["ManagedServiceIdentity"] = None, + identity: Optional["_models.ManagedServiceIdentity"] = None, location: Optional[str] = None, **kwargs ): @@ -362,8 +363,8 @@ class CheckNameAvailabilityResponse(msrest.serialization.Model): :ivar name_available: Indicates if the resource name is available. :vartype name_available: bool - :ivar reason: The reason why the given name is not available. Possible values include: - "Invalid", "AlreadyExists". + :ivar reason: The reason why the given name is not available. Known values are: "Invalid", + "AlreadyExists". :vartype reason: str or ~device_update.models.CheckNameAvailabilityReason :ivar message: Detailed reason why the given name is available. :vartype message: str @@ -379,15 +380,15 @@ def __init__( self, *, name_available: Optional[bool] = None, - reason: Optional[Union[str, "CheckNameAvailabilityReason"]] = None, + reason: Optional[Union[str, "_models.CheckNameAvailabilityReason"]] = None, message: Optional[str] = None, **kwargs ): """ :keyword name_available: Indicates if the resource name is available. :paramtype name_available: bool - :keyword reason: The reason why the given name is not available. Possible values include: - "Invalid", "AlreadyExists". + :keyword reason: The reason why the given name is not available. Known values are: "Invalid", + "AlreadyExists". :paramtype reason: str or ~device_update.models.CheckNameAvailabilityReason :keyword message: Detailed reason why the given name is available. :paramtype message: str @@ -450,7 +451,7 @@ class DiagnosticStorageProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar authentication_type: Required. Authentication Type. Possible values include: "KeyBased". + :ivar authentication_type: Required. Authentication Type. Known values are: "KeyBased". :vartype authentication_type: str or ~device_update.models.AuthenticationType :ivar connection_string: ConnectionString of the diagnostic storage account. :vartype connection_string: str @@ -472,14 +473,13 @@ class DiagnosticStorageProperties(msrest.serialization.Model): def __init__( self, *, - authentication_type: Union[str, "AuthenticationType"], + authentication_type: Union[str, "_models.AuthenticationType"], resource_id: str, connection_string: Optional[str] = None, **kwargs ): """ - :keyword authentication_type: Required. Authentication Type. Possible values include: - "KeyBased". + :keyword authentication_type: Required. Authentication Type. Known values are: "KeyBased". :paramtype authentication_type: str or ~device_update.models.AuthenticationType :keyword connection_string: ConnectionString of the diagnostic storage account. :paramtype connection_string: str @@ -585,7 +585,7 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorDetail"] = None, + error: Optional["_models.ErrorDetail"] = None, **kwargs ): """ @@ -718,8 +718,8 @@ class GroupInformation(ProxyResource): :vartype required_members: list[str] :ivar required_zone_names: The private link resource Private link DNS zone name. :vartype required_zone_names: list[str] - :ivar provisioning_state: The provisioning state of private link group ID. Possible values - include: "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of private link group ID. Known values are: + "Succeeded", "Failed", "Canceled". :vartype provisioning_state: str or ~device_update.models.GroupIdProvisioningState """ @@ -812,8 +812,8 @@ class GroupInformationProperties(PrivateLinkResourceProperties): :vartype required_members: list[str] :ivar required_zone_names: The private link resource Private link DNS zone name. :vartype required_zone_names: list[str] - :ivar provisioning_state: The provisioning state of private link group ID. Possible values - include: "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: The provisioning state of private link group ID. Known values are: + "Succeeded", "Failed", "Canceled". :vartype provisioning_state: str or ~device_update.models.GroupIdProvisioningState """ @@ -866,7 +866,7 @@ class Instance(TrackedResource): :vartype tags: dict[str, str] :ivar location: Required. The geo-location where the resource lives. :vartype location: str - :ivar provisioning_state: Provisioning state. Possible values include: "Succeeded", "Deleted", + :ivar provisioning_state: Provisioning state. Known values are: "Succeeded", "Deleted", "Failed", "Canceled", "Accepted", "Creating". :vartype provisioning_state: str or ~device_update.models.ProvisioningState :ivar account_name: Parent Device Update Account name which Instance belongs to. @@ -909,9 +909,9 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - iot_hubs: Optional[List["IotHubSettings"]] = None, + iot_hubs: Optional[List["_models.IotHubSettings"]] = None, enable_diagnostics: Optional[bool] = None, - diagnostic_storage_properties: Optional["DiagnosticStorageProperties"] = None, + diagnostic_storage_properties: Optional["_models.DiagnosticStorageProperties"] = None, **kwargs ): """ @@ -953,7 +953,7 @@ def __init__( self, *, next_link: Optional[str] = None, - value: Optional[List["Instance"]] = None, + value: Optional[List["_models.Instance"]] = None, **kwargs ): """ @@ -1003,7 +1003,7 @@ class Location(msrest.serialization.Model): :ivar name: :vartype name: str - :ivar role: Whether the location is primary or failover. Possible values include: "Primary", + :ivar role: Whether the location is primary or failover. Known values are: "Primary", "Failover". Default value: "Primary". :vartype role: str or ~device_update.models.Role """ @@ -1017,13 +1017,13 @@ def __init__( self, *, name: Optional[str] = None, - role: Optional[Union[str, "Role"]] = "Primary", + role: Optional[Union[str, "_models.Role"]] = "Primary", **kwargs ): """ :keyword name: :paramtype name: str - :keyword role: Whether the location is primary or failover. Possible values include: "Primary", + :keyword role: Whether the location is primary or failover. Known values are: "Primary", "Failover". Default value: "Primary". :paramtype role: str or ~device_update.models.Role """ @@ -1046,8 +1046,8 @@ class ManagedServiceIdentity(msrest.serialization.Model): provided for a system assigned identity. :vartype tenant_id: str :ivar type: Required. Type of managed service identity (where both SystemAssigned and - UserAssigned types are allowed). Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + UserAssigned types are allowed). Known values are: "None", "SystemAssigned", "UserAssigned", + "SystemAssigned,UserAssigned". :vartype type: str or ~device_update.models.ManagedServiceIdentityType :ivar user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: @@ -1072,14 +1072,14 @@ class ManagedServiceIdentity(msrest.serialization.Model): def __init__( self, *, - type: Union[str, "ManagedServiceIdentityType"], - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, + type: Union[str, "_models.ManagedServiceIdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, **kwargs ): """ :keyword type: Required. Type of managed service identity (where both SystemAssigned and - UserAssigned types are allowed). Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + UserAssigned types are allowed). Known values are: "None", "SystemAssigned", "UserAssigned", + "SystemAssigned,UserAssigned". :paramtype type: str or ~device_update.models.ManagedServiceIdentityType :keyword user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: @@ -1108,11 +1108,11 @@ class Operation(msrest.serialization.Model): :ivar display: Localized display information for this particular operation. :vartype display: ~device_update.models.OperationDisplay :ivar origin: The intended executor of the operation; as in Resource Based Access Control - (RBAC) and audit logs UX. Default value is "user,system". Possible values include: "user", - "system", "user,system". + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + "user,system". :vartype origin: str or ~device_update.models.Origin :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for - internal only APIs. Possible values include: "Internal". + internal only APIs. Known values are: "Internal". :vartype action_type: str or ~device_update.models.ActionType """ @@ -1134,7 +1134,7 @@ class Operation(msrest.serialization.Model): def __init__( self, *, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, **kwargs ): """ @@ -1281,7 +1281,7 @@ class PrivateEndpointConnection(Resource): :ivar group_ids: Array of group IDs. :vartype group_ids: list[str] :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Possible values include: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", "Failed". :vartype provisioning_state: str or ~device_update.models.PrivateEndpointConnectionProvisioningState """ @@ -1309,8 +1309,8 @@ class PrivateEndpointConnection(Resource): def __init__( self, *, - private_link_service_connection_state: "PrivateLinkServiceConnectionState", - private_endpoint: Optional["PrivateEndpoint"] = None, + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState", + private_endpoint: Optional["_models.PrivateEndpoint"] = None, group_ids: Optional[List[str]] = None, **kwargs ): @@ -1345,7 +1345,7 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs ): """ @@ -1382,7 +1382,7 @@ class PrivateEndpointConnectionProxyProperties(msrest.serialization.Model): def __init__( self, *, - remote_private_endpoint: Optional["RemotePrivateEndpoint"] = None, + remote_private_endpoint: Optional["_models.RemotePrivateEndpoint"] = None, status: Optional[str] = None, **kwargs ): @@ -1421,7 +1421,7 @@ class PrivateEndpointConnectionProxy(ProxyResource, PrivateEndpointConnectionPro information. :vartype system_data: ~device_update.models.SystemData :ivar provisioning_state: The provisioning state of the private endpoint connection proxy - resource. Possible values include: "Succeeded", "Creating", "Deleting", "Failed". + resource. Known values are: "Succeeded", "Creating", "Deleting", "Failed". :vartype provisioning_state: str or ~device_update.models.PrivateEndpointConnectionProxyProvisioningState """ @@ -1449,7 +1449,7 @@ class PrivateEndpointConnectionProxy(ProxyResource, PrivateEndpointConnectionPro def __init__( self, *, - remote_private_endpoint: Optional["RemotePrivateEndpoint"] = None, + remote_private_endpoint: Optional["_models.RemotePrivateEndpoint"] = None, status: Optional[str] = None, **kwargs ): @@ -1488,7 +1488,7 @@ class PrivateEndpointConnectionProxyListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateEndpointConnectionProxy"]] = None, + value: Optional[List["_models.PrivateEndpointConnectionProxy"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -1574,7 +1574,7 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["GroupInformation"]] = None, + value: Optional[List["_models.GroupInformation"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -1633,7 +1633,7 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """A collection of information about the state of the connection between service consumer and provider. :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Possible values include: "Pending", "Approved", "Rejected". + of the service. Known values are: "Pending", "Approved", "Rejected". :vartype status: str or ~device_update.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. :vartype description: str @@ -1651,14 +1651,14 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): def __init__( self, *, - status: Optional[Union[str, "PrivateEndpointServiceConnectionStatus"]] = None, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, description: Optional[str] = None, actions_required: Optional[str] = None, **kwargs ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Possible values include: "Pending", "Approved", "Rejected". + owner of the service. Known values are: "Pending", "Approved", "Rejected". :paramtype status: str or ~device_update.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. :paramtype description: str @@ -1700,9 +1700,9 @@ def __init__( self, *, id: Optional[str] = None, - remote_private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, - remote_private_endpoint_connection: Optional["PrivateLinkServiceProxyRemotePrivateEndpointConnection"] = None, - group_connectivity_information: Optional[List["GroupConnectivityInformation"]] = None, + remote_private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, + remote_private_endpoint_connection: Optional["_models.PrivateLinkServiceProxyRemotePrivateEndpointConnection"] = None, + group_connectivity_information: Optional[List["_models.GroupConnectivityInformation"]] = None, **kwargs ): """ @@ -1826,10 +1826,10 @@ def __init__( immutable_subscription_id: Optional[str] = None, immutable_resource_id: Optional[str] = None, vnet_traffic_tag: Optional[str] = None, - manual_private_link_service_connections: Optional[List["PrivateLinkServiceConnection"]] = None, - private_link_service_connections: Optional[List["PrivateLinkServiceConnection"]] = None, - private_link_service_proxies: Optional[List["PrivateLinkServiceProxy"]] = None, - connection_details: Optional[List["ConnectionDetails"]] = None, + manual_private_link_service_connections: Optional[List["_models.PrivateLinkServiceConnection"]] = None, + private_link_service_connections: Optional[List["_models.PrivateLinkServiceConnection"]] = None, + private_link_service_proxies: Optional[List["_models.PrivateLinkServiceProxy"]] = None, + connection_details: Optional[List["_models.ConnectionDetails"]] = None, **kwargs ): """ @@ -1873,15 +1873,15 @@ class SystemData(msrest.serialization.Model): :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". :vartype created_by_type: str or ~device_update.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". :vartype last_modified_by_type: str or ~device_update.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime @@ -1900,25 +1900,25 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". :paramtype created_by_type: str or ~device_update.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". :paramtype last_modified_by_type: str or ~device_update.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/models/_patch.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/__init__.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/__init__.py index 39c22b434362..fcfbd4b1f52e 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/__init__.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/__init__.py @@ -14,6 +14,9 @@ from ._private_endpoint_connection_proxies_operations import PrivateEndpointConnectionProxiesOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'DeviceUpdateOperationsMixin', 'AccountsOperations', @@ -23,3 +26,5 @@ 'PrivateEndpointConnectionProxiesOperations', 'Operations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_accounts_operations.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_accounts_operations.py index c7089cccd5c7..029593a4f2be 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_accounts_operations.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_accounts_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,9 +33,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DeviceUpdate/accounts") path_format_arguments = { @@ -45,18 +48,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -66,9 +67,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts") # pylint: disable=line-too-long path_format_arguments = { @@ -79,18 +83,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -101,9 +103,12 @@ def build_get_request( account_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { @@ -115,18 +120,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -137,9 +140,12 @@ def build_head_request( account_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { @@ -151,18 +157,16 @@ def build_head_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -172,14 +176,17 @@ def build_create_request_initial( subscription_id: str, account_name: str, *, - json: JSONType = None, + json: Optional[_models.Account] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { @@ -191,20 +198,18 @@ def build_create_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -217,9 +222,12 @@ def build_delete_request_initial( account_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { @@ -231,18 +239,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -252,14 +258,17 @@ def build_update_request_initial( subscription_id: str, account_name: str, *, - json: JSONType = None, + json: Optional[_models.AccountUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { @@ -271,52 +280,48 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class AccountsOperations(object): - """AccountsOperations 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. +class AccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~device_update.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~device_update.DeviceUpdate`'s + :attr:`accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.AccountList"]: + ) -> Iterable[_models.AccountList]: """Returns list of Accounts. :keyword callable cls: A custom type or function that will be passed the direct response @@ -324,13 +329,16 @@ def list_by_subscription( :rtype: ~azure.core.paging.ItemPaged[~device_update.models.AccountList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccountList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccountList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -338,9 +346,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -348,9 +358,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -389,7 +401,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AccountList"]: + ) -> Iterable[_models.AccountList]: """Returns list of Accounts. :param resource_group_name: The resource group name. @@ -399,13 +411,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~device_update.models.AccountList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccountList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccountList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -414,9 +429,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -425,9 +442,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -467,7 +486,7 @@ def get( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.Account": + ) -> _models.Account: """Returns account details for the given account name. :param resource_group_name: The resource group name. @@ -479,13 +498,16 @@ def get( :rtype: ~device_update.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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Account] request = build_get_request( @@ -494,11 +516,13 @@ def get( account_name=account_name, api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -538,13 +562,16 @@ def head( :rtype: bool :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_head_request( @@ -553,11 +580,13 @@ def head( account_name=account_name, api_version=api_version, template_url=self.head.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -580,17 +609,20 @@ def _create_initial( self, resource_group_name: str, account_name: str, - account: "_models.Account", + account: _models.Account, **kwargs: Any - ) -> "_models.Account": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] + ) -> _models.Account: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Account] _json = self._serialize.body(account, 'Account') @@ -602,11 +634,13 @@ def _create_initial( content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -632,9 +666,9 @@ def begin_create( self, resource_group_name: str, account_name: str, - account: "_models.Account", + account: _models.Account, **kwargs: Any - ) -> LROPoller["_models.Account"]: + ) -> LROPoller[_models.Account]: """Creates or updates Account. :param resource_group_name: The resource group name. @@ -655,37 +689,47 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~device_update.models.Account] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Account] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, account=account, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('Account', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -704,13 +748,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -719,11 +766,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements account_name=account_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -765,20 +814,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -788,8 +842,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -806,17 +866,20 @@ def _update_initial( self, resource_group_name: str, account_name: str, - account_update_payload: "_models.AccountUpdate", + account_update_payload: _models.AccountUpdate, **kwargs: Any - ) -> "_models.Account": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] + ) -> _models.Account: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Account] _json = self._serialize.body(account_update_payload, 'AccountUpdate') @@ -828,11 +891,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -862,9 +927,9 @@ def begin_update( self, resource_group_name: str, account_name: str, - account_update_payload: "_models.AccountUpdate", + account_update_payload: _models.AccountUpdate, **kwargs: Any - ) -> LROPoller["_models.Account"]: + ) -> LROPoller[_models.Account]: """Updates account's patchable properties. :param resource_group_name: The resource group name. @@ -885,37 +950,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~device_update.models.Account] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Account] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, account_update_payload=account_update_payload, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('Account', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_device_update_operations.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_device_update_operations.py index 5da88a3f29b7..f3dcf5892a4a 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_device_update_operations.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_device_update_operations.py @@ -15,12 +15,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -29,14 +29,17 @@ def build_check_name_availability_request( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CheckNameAvailabilityRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.DeviceUpdate/checknameavailability") # pylint: disable=line-too-long path_format_arguments = { @@ -46,33 +49,31 @@ def build_check_name_availability_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class DeviceUpdateOperationsMixin(object): +class DeviceUpdateOperationsMixin(MixinABC): @distributed_trace def check_name_availability( self, - request: "_models.CheckNameAvailabilityRequest", + request: _models.CheckNameAvailabilityRequest, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResponse": + ) -> _models.CheckNameAvailabilityResponse: """Checks ADU resource name availability. :param request: Check Name Availability Request. @@ -82,14 +83,17 @@ def check_name_availability( :rtype: ~device_update.models.CheckNameAvailabilityResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResponse] _json = self._serialize.body(request, 'CheckNameAvailabilityRequest') @@ -99,11 +103,13 @@ def check_name_availability( content_type=content_type, json=_json, template_url=self.check_name_availability.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_instances_operations.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_instances_operations.py index cb4b9eb25a2d..b1d5ce09d897 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_instances_operations.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_instances_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -35,9 +35,12 @@ def build_list_by_account_request( account_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}/instances") # pylint: disable=line-too-long path_format_arguments = { @@ -49,18 +52,16 @@ def build_list_by_account_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -72,9 +73,12 @@ def build_get_request( instance_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}/instances/{instanceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -87,18 +91,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -110,9 +112,12 @@ def build_head_request( instance_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}/instances/{instanceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -125,18 +130,16 @@ def build_head_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="HEAD", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -147,14 +150,17 @@ def build_create_request_initial( account_name: str, instance_name: str, *, - json: JSONType = None, + json: Optional[_models.Instance] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}/instances/{instanceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -167,20 +173,18 @@ def build_create_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -194,9 +198,12 @@ def build_delete_request_initial( instance_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}/instances/{instanceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -209,18 +216,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -231,14 +236,17 @@ def build_update_request( account_name: str, instance_name: str, *, - json: JSONType = None, + json: Optional[_models.TagUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}/instances/{instanceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -251,46 +259,42 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class InstancesOperations(object): - """InstancesOperations 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. +class InstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~device_update.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~device_update.DeviceUpdate`'s + :attr:`instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_account( @@ -298,7 +302,7 @@ def list_by_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.InstanceList"]: + ) -> Iterable[_models.InstanceList]: """Returns instances for the given account name. :param resource_group_name: The resource group name. @@ -310,13 +314,16 @@ def list_by_account( :rtype: ~azure.core.paging.ItemPaged[~device_update.models.InstanceList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.InstanceList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.InstanceList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -326,9 +333,11 @@ def prepare_request(next_link=None): account_name=account_name, api_version=api_version, template_url=self.list_by_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -338,9 +347,11 @@ def prepare_request(next_link=None): account_name=account_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -381,7 +392,7 @@ def get( account_name: str, instance_name: str, **kwargs: Any - ) -> "_models.Instance": + ) -> _models.Instance: """Returns instance details for the given instance and account name. :param resource_group_name: The resource group name. @@ -395,13 +406,16 @@ def get( :rtype: ~device_update.models.Instance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Instance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Instance] request = build_get_request( @@ -411,11 +425,13 @@ def get( instance_name=instance_name, api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,13 +474,16 @@ def head( :rtype: bool :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_head_request( @@ -474,11 +493,13 @@ def head( instance_name=instance_name, api_version=api_version, template_url=self.head.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,17 +523,20 @@ def _create_initial( resource_group_name: str, account_name: str, instance_name: str, - instance: "_models.Instance", + instance: _models.Instance, **kwargs: Any - ) -> "_models.Instance": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Instance"] + ) -> _models.Instance: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Instance] _json = self._serialize.body(instance, 'Instance') @@ -525,11 +549,13 @@ def _create_initial( content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -556,9 +582,9 @@ def begin_create( resource_group_name: str, account_name: str, instance_name: str, - instance: "_models.Instance", + instance: _models.Instance, **kwargs: Any - ) -> LROPoller["_models.Instance"]: + ) -> LROPoller[_models.Instance]: """Creates or updates instance. :param resource_group_name: The resource group name. @@ -581,17 +607,20 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~device_update.models.Instance] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Instance] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Instance"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, instance_name=instance_name, @@ -599,20 +628,27 @@ def begin_create( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('Instance', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -632,13 +668,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements instance_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -648,11 +687,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements instance_name=instance_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -697,21 +738,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, instance_name=instance_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -721,8 +767,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -741,9 +793,9 @@ def update( resource_group_name: str, account_name: str, instance_name: str, - tag_update_payload: "_models.TagUpdate", + tag_update_payload: _models.TagUpdate, **kwargs: Any - ) -> "_models.Instance": + ) -> _models.Instance: """Updates instance's tags. :param resource_group_name: The resource group name. @@ -759,14 +811,17 @@ def update( :rtype: ~device_update.models.Instance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Instance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Instance] _json = self._serialize.body(tag_update_payload, 'TagUpdate') @@ -779,11 +834,13 @@ def update( content_type=content_type, json=_json, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_operations.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_operations.py index 7aa4f50d5fd1..cfe8fd2665d9 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_operations.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_operations.py @@ -16,10 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._vendor import _convert_request +from .._vendor import MixinABC, _convert_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -29,55 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.DeviceUpdate/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class Operations(object): - """Operations 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. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~device_update.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~device_update.DeviceUpdate`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> Iterable[_models.OperationListResult]: """Returns list of operations for Microsoft.DeviceUpdate resource provider. :keyword callable cls: A custom type or function that will be passed the direct response @@ -85,31 +85,38 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~device_update.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_patch.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_private_endpoint_connection_proxies_operations.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_private_endpoint_connection_proxies_operations.py index 9a276ef6387c..a0dea551d835 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_private_endpoint_connection_proxies_operations.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_private_endpoint_connection_proxies_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -35,9 +35,12 @@ def build_list_by_account_request( account_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}/privateEndpointConnectionProxies") # pylint: disable=line-too-long path_format_arguments = { @@ -49,18 +52,16 @@ def build_list_by_account_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -71,14 +72,17 @@ def build_validate_request( account_name: str, private_endpoint_connection_proxy_id: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointConnectionProxy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}/privateEndpointConnectionProxies/{privateEndpointConnectionProxyId}/validate") # pylint: disable=line-too-long path_format_arguments = { @@ -91,20 +95,18 @@ def build_validate_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -117,14 +119,17 @@ def build_update_private_endpoint_properties_request( account_name: str, private_endpoint_connection_proxy_id: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}/privateEndpointConnectionProxies/{privateEndpointConnectionProxyId}/updatePrivateEndpointProperties") # pylint: disable=line-too-long path_format_arguments = { @@ -137,20 +142,18 @@ def build_update_private_endpoint_properties_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -164,9 +167,12 @@ def build_get_request( private_endpoint_connection_proxy_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}/privateEndpointConnectionProxies/{privateEndpointConnectionProxyId}") # pylint: disable=line-too-long path_format_arguments = { @@ -179,18 +185,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -201,14 +205,17 @@ def build_create_or_update_request_initial( account_name: str, private_endpoint_connection_proxy_id: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointConnectionProxy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}/privateEndpointConnectionProxies/{privateEndpointConnectionProxyId}") # pylint: disable=line-too-long path_format_arguments = { @@ -221,20 +228,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -248,9 +253,12 @@ def build_delete_request_initial( private_endpoint_connection_proxy_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}/privateEndpointConnectionProxies/{privateEndpointConnectionProxyId}") # pylint: disable=line-too-long path_format_arguments = { @@ -263,42 +271,38 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class PrivateEndpointConnectionProxiesOperations(object): - """PrivateEndpointConnectionProxiesOperations 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. +class PrivateEndpointConnectionProxiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~device_update.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~device_update.DeviceUpdate`'s + :attr:`private_endpoint_connection_proxies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_account( @@ -306,7 +310,7 @@ def list_by_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionProxyListResult"]: + ) -> Iterable[_models.PrivateEndpointConnectionProxyListResult]: """(INTERNAL - DO NOT USE) List all private endpoint connection proxies in a device update account. @@ -321,13 +325,16 @@ def list_by_account( ~azure.core.paging.ItemPaged[~device_update.models.PrivateEndpointConnectionProxyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionProxyListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionProxyListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -337,9 +344,11 @@ def prepare_request(next_link=None): account_name=account_name, api_version=api_version, template_url=self.list_by_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -349,9 +358,11 @@ def prepare_request(next_link=None): account_name=account_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -391,7 +402,7 @@ def validate( # pylint: disable=inconsistent-return-statements resource_group_name: str, account_name: str, private_endpoint_connection_proxy_id: str, - private_endpoint_connection_proxy: "_models.PrivateEndpointConnectionProxy", + private_endpoint_connection_proxy: _models.PrivateEndpointConnectionProxy, **kwargs: Any ) -> None: """(INTERNAL - DO NOT USE) Validates a private endpoint connection proxy object. @@ -411,14 +422,17 @@ def validate( # pylint: disable=inconsistent-return-statements :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(private_endpoint_connection_proxy, 'PrivateEndpointConnectionProxy') @@ -431,11 +445,13 @@ def validate( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self.validate.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -459,7 +475,7 @@ def update_private_endpoint_properties( # pylint: disable=inconsistent-return-s resource_group_name: str, account_name: str, private_endpoint_connection_proxy_id: str, - private_endpoint_update: "_models.PrivateEndpointUpdate", + private_endpoint_update: _models.PrivateEndpointUpdate, **kwargs: Any ) -> None: """(INTERNAL - DO NOT USE) Updates a private endpoint inside the private endpoint connection proxy @@ -480,14 +496,17 @@ def update_private_endpoint_properties( # pylint: disable=inconsistent-return-s :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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(private_endpoint_update, 'PrivateEndpointUpdate') @@ -500,11 +519,13 @@ def update_private_endpoint_properties( # pylint: disable=inconsistent-return-s content_type=content_type, json=_json, template_url=self.update_private_endpoint_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -529,7 +550,7 @@ def get( account_name: str, private_endpoint_connection_proxy_id: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnectionProxy": + ) -> _models.PrivateEndpointConnectionProxy: """(INTERNAL - DO NOT USE) Get the specified private endpoint connection proxy associated with the device update account. @@ -545,13 +566,16 @@ def get( :rtype: ~device_update.models.PrivateEndpointConnectionProxy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionProxy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionProxy] request = build_get_request( @@ -561,11 +585,13 @@ def get( private_endpoint_connection_proxy_id=private_endpoint_connection_proxy_id, api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -592,17 +618,20 @@ def _create_or_update_initial( resource_group_name: str, account_name: str, private_endpoint_connection_proxy_id: str, - private_endpoint_connection_proxy: "_models.PrivateEndpointConnectionProxy", + private_endpoint_connection_proxy: _models.PrivateEndpointConnectionProxy, **kwargs: Any - ) -> "_models.PrivateEndpointConnectionProxy": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionProxy"] + ) -> _models.PrivateEndpointConnectionProxy: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionProxy] _json = self._serialize.body(private_endpoint_connection_proxy, 'PrivateEndpointConnectionProxy') @@ -615,11 +644,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -646,9 +677,9 @@ def begin_create_or_update( resource_group_name: str, account_name: str, private_endpoint_connection_proxy_id: str, - private_endpoint_connection_proxy: "_models.PrivateEndpointConnectionProxy", + private_endpoint_connection_proxy: _models.PrivateEndpointConnectionProxy, **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnectionProxy"]: + ) -> LROPoller[_models.PrivateEndpointConnectionProxy]: """(INTERNAL - DO NOT USE) Creates or updates the specified private endpoint connection proxy resource associated with the device update account. @@ -675,17 +706,20 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~device_update.models.PrivateEndpointConnectionProxy] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionProxy] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionProxy"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_proxy_id=private_endpoint_connection_proxy_id, @@ -693,20 +727,27 @@ def begin_create_or_update( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnectionProxy', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -726,13 +767,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements private_endpoint_connection_proxy_id: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -742,11 +786,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements private_endpoint_connection_proxy_id=private_endpoint_connection_proxy_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -793,21 +839,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_proxy_id=private_endpoint_connection_proxy_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -817,8 +868,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_private_endpoint_connections_operations.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_private_endpoint_connections_operations.py index 97c9b7ba2e15..a0ac0f142d4c 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_private_endpoint_connections_operations.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_private_endpoint_connections_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -35,9 +35,12 @@ def build_list_by_account_request( account_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}/privateEndpointConnections") # pylint: disable=line-too-long path_format_arguments = { @@ -49,18 +52,16 @@ def build_list_by_account_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -72,9 +73,12 @@ def build_get_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -87,18 +91,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -109,14 +111,17 @@ def build_create_or_update_request_initial( account_name: str, private_endpoint_connection_name: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointConnection] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -129,20 +134,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -156,9 +159,12 @@ def build_delete_request_initial( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -171,42 +177,38 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations 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. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~device_update.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~device_update.DeviceUpdate`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_account( @@ -214,7 +216,7 @@ def list_by_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + ) -> Iterable[_models.PrivateEndpointConnectionListResult]: """List all private endpoint connections in a device update account. :param resource_group_name: The resource group name. @@ -227,13 +229,16 @@ def list_by_account( :rtype: ~azure.core.paging.ItemPaged[~device_update.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -243,9 +248,11 @@ def prepare_request(next_link=None): account_name=account_name, api_version=api_version, template_url=self.list_by_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -255,9 +262,11 @@ def prepare_request(next_link=None): account_name=account_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -298,7 +307,7 @@ def get( account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Get the specified private endpoint connection associated with the device update account. :param resource_group_name: The resource group name. @@ -313,13 +322,16 @@ def get( :rtype: ~device_update.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -329,11 +341,13 @@ def get( private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -360,17 +374,20 @@ def _create_or_update_initial( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') @@ -383,11 +400,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -414,9 +433,9 @@ def begin_create_or_update( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Update the state of specified private endpoint connection associated with the device update account. @@ -442,17 +461,20 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~device_update.models.PrivateEndpointConnection] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -460,20 +482,27 @@ def begin_create_or_update( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -493,13 +522,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -509,11 +541,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -559,21 +593,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -583,8 +622,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_private_link_resources_operations.py b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_private_link_resources_operations.py index 2a06780fe5fc..db2199ec6605 100644 --- a/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_private_link_resources_operations.py +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/azure/mgmt/deviceupdate/operations/_private_link_resources_operations.py @@ -16,10 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -32,9 +33,12 @@ def build_list_by_account_request( account_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}/privateLinkResources") # pylint: disable=line-too-long path_format_arguments = { @@ -46,18 +50,16 @@ def build_list_by_account_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -69,9 +71,12 @@ def build_get_request( group_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DeviceUpdate/accounts/{accountName}/privateLinkResources/{groupId}") # pylint: disable=line-too-long path_format_arguments = { @@ -84,42 +89,38 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class PrivateLinkResourcesOperations(object): - """PrivateLinkResourcesOperations 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. +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~device_update.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~device_update.DeviceUpdate`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_account( @@ -127,7 +128,7 @@ def list_by_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateLinkResourceListResult"]: + ) -> Iterable[_models.PrivateLinkResourceListResult]: """List all private link resources in a device update account. :param resource_group_name: The resource group name. @@ -140,13 +141,16 @@ def list_by_account( :rtype: ~azure.core.paging.ItemPaged[~device_update.models.PrivateLinkResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -156,9 +160,11 @@ def prepare_request(next_link=None): account_name=account_name, api_version=api_version, template_url=self.list_by_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -168,9 +174,11 @@ def prepare_request(next_link=None): account_name=account_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -211,7 +219,7 @@ def get( account_name: str, group_id: str, **kwargs: Any - ) -> "_models.GroupInformation": + ) -> _models.GroupInformation: """Get the specified private link resource associated with the device update account. :param resource_group_name: The resource group name. @@ -225,13 +233,16 @@ def get( :rtype: ~device_update.models.GroupInformation :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupInformation"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-04-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GroupInformation] request = build_get_request( @@ -241,11 +252,13 @@ def get( group_id=group_id, api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs