diff --git a/sdk/batch/azure-mgmt-batch/_meta.json b/sdk/batch/azure-mgmt-batch/_meta.json index e58dbb95f578..d9038753528d 100644 --- a/sdk/batch/azure-mgmt-batch/_meta.json +++ b/sdk/batch/azure-mgmt-batch/_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": "5ee062ac3cc2df298ff47bdfc7792d257fd85bb8", + "commit": "63f4e39c20223c20941614e776d33e699c3e2777", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/batch/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/batch/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/batch/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/__init__.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/__init__.py index 21eada7ba672..bedacc697f79 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/__init__.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/__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__ = ['BatchManagementClient'] +__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/batch/azure-mgmt-batch/azure/mgmt/batch/_batch_management_client.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_batch_management_client.py index ce3f8284efbf..13182ae1e836 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_batch_management_client.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_batch_management_client.py @@ -72,15 +72,33 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.batch_account = BatchAccountOperations(self._client, self._config, self._serialize, self._deserialize) - self.application_package = ApplicationPackageOperations(self._client, self._config, self._serialize, self._deserialize) - self.application = ApplicationOperations(self._client, self._config, self._serialize, self._deserialize) - self.location = LocationOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.certificate = CertificateOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resource = PrivateLinkResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connection = PrivateEndpointConnectionOperations(self._client, self._config, self._serialize, self._deserialize) - self.pool = PoolOperations(self._client, self._config, self._serialize, self._deserialize) + self.batch_account = BatchAccountOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_package = ApplicationPackageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application = ApplicationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.location = LocationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.certificate = CertificateOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resource = PrivateLinkResourceOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connection = PrivateEndpointConnectionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.pool = PoolOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_metadata.json b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_metadata.json deleted file mode 100644 index 53ef74f54103..000000000000 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_metadata.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "chosen_version": "2022-06-01", - "total_api_version_list": ["2022-06-01"], - "client": { - "name": "BatchManagementClient", - "filename": "_batch_management_client", - "description": "Batch Client.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"BatchManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"BatchManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "batch_account": "BatchAccountOperations", - "application_package": "ApplicationPackageOperations", - "application": "ApplicationOperations", - "location": "LocationOperations", - "operations": "Operations", - "certificate": "CertificateOperations", - "private_link_resource": "PrivateLinkResourceOperations", - "private_endpoint_connection": "PrivateEndpointConnectionOperations", - "pool": "PoolOperations" - } -} \ No newline at end of file diff --git a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_version.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_version.py index 2ac18d10425f..c23f64adb662 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_version.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "16.2.0" +VERSION = "14.0.0b1" diff --git a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/__init__.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/__init__.py index 5220f1b3d0f1..9dc744dfcc3a 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/__init__.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._batch_management_client import BatchManagementClient + +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__ = ['BatchManagementClient'] +__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/batch/azure-mgmt-batch/azure/mgmt/batch/aio/_batch_management_client.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/_batch_management_client.py index 76d10a467aea..5817d523cb17 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/_batch_management_client.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/_batch_management_client.py @@ -72,15 +72,33 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.batch_account = BatchAccountOperations(self._client, self._config, self._serialize, self._deserialize) - self.application_package = ApplicationPackageOperations(self._client, self._config, self._serialize, self._deserialize) - self.application = ApplicationOperations(self._client, self._config, self._serialize, self._deserialize) - self.location = LocationOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.certificate = CertificateOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resource = PrivateLinkResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connection = PrivateEndpointConnectionOperations(self._client, self._config, self._serialize, self._deserialize) - self.pool = PoolOperations(self._client, self._config, self._serialize, self._deserialize) + self.batch_account = BatchAccountOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application_package = ApplicationPackageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.application = ApplicationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.location = LocationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.certificate = CertificateOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resource = PrivateLinkResourceOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connection = PrivateEndpointConnectionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.pool = PoolOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/__init__.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/__init__.py index c4a185c29107..bc56b670cd21 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/__init__.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/__init__.py @@ -16,6 +16,9 @@ from ._private_endpoint_connection_operations import PrivateEndpointConnectionOperations from ._pool_operations import PoolOperations +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__ = [ 'BatchAccountOperations', 'ApplicationPackageOperations', @@ -27,3 +30,5 @@ 'PrivateEndpointConnectionOperations', 'PoolOperations', ] +__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/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_application_operations.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_application_operations.py index 69a60adc2147..e1f308bcd172 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_application_operations.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_application_operations.py @@ -15,6 +15,7 @@ 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 @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApplicationOperations: - """ApplicationOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.batch.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.batch.aio.BatchManagementClient`'s + :attr:`application` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create( @@ -51,9 +50,9 @@ async def create( resource_group_name: str, account_name: str, application_name: str, - parameters: Optional["_models.Application"] = None, + parameters: Optional[_models.Application] = None, **kwargs: Any - ) -> "_models.Application": + ) -> _models.Application: """Adds an application to the specified Batch account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -69,14 +68,17 @@ async def create( :rtype: ~azure.mgmt.batch.models.Application :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] 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-06-01") # 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-06-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.Application] if parameters is not None: _json = self._serialize.body(parameters, 'Application') @@ -92,11 +94,13 @@ async def create( content_type=content_type, json=_json, template_url=self.create.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 @@ -138,13 +142,16 @@ async def delete( # 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-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -154,11 +161,13 @@ async def delete( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 @@ -182,7 +191,7 @@ async def get( account_name: str, application_name: str, **kwargs: Any - ) -> "_models.Application": + ) -> _models.Application: """Gets information about the specified application. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -196,13 +205,16 @@ async def get( :rtype: ~azure.mgmt.batch.models.Application :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] 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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] request = build_get_request( @@ -212,11 +224,13 @@ async def get( subscription_id=self._config.subscription_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 @@ -243,9 +257,9 @@ async def update( resource_group_name: str, account_name: str, application_name: str, - parameters: "_models.Application", + parameters: _models.Application, **kwargs: Any - ) -> "_models.Application": + ) -> _models.Application: """Updates settings for the specified application. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -261,14 +275,17 @@ async def update( :rtype: ~azure.mgmt.batch.models.Application :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] 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-06-01") # 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-06-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.Application] _json = self._serialize.body(parameters, 'Application') @@ -281,11 +298,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 @@ -313,7 +332,7 @@ def list( account_name: str, maxresults: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListApplicationsResult"]: + ) -> AsyncIterable[_models.ListApplicationsResult]: """Lists all of the applications in the specified account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -330,13 +349,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.ListApplicationsResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListApplicationsResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListApplicationsResult"] 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: @@ -347,9 +369,11 @@ def prepare_request(next_link=None): api_version=api_version, maxresults=maxresults, 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: @@ -360,9 +384,11 @@ def prepare_request(next_link=None): api_version=api_version, maxresults=maxresults, 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/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_application_package_operations.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_application_package_operations.py index 6d261d671fd4..a81346ce7dea 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_application_package_operations.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_application_package_operations.py @@ -15,6 +15,7 @@ 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 @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ApplicationPackageOperations: - """ApplicationPackageOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.batch.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.batch.aio.BatchManagementClient`'s + :attr:`application_package` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def activate( @@ -52,9 +51,9 @@ async def activate( account_name: str, application_name: str, version_name: str, - parameters: "_models.ActivateApplicationPackageParameters", + parameters: _models.ActivateApplicationPackageParameters, **kwargs: Any - ) -> "_models.ApplicationPackage": + ) -> _models.ApplicationPackage: """Activates the specified application package. This should be done after the ``ApplicationPackage`` was created and uploaded. This needs to be done before an ``ApplicationPackage`` can be used on Pools or Tasks. @@ -74,14 +73,17 @@ async def activate( :rtype: ~azure.mgmt.batch.models.ApplicationPackage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationPackage"] 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-06-01") # 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-06-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.ApplicationPackage] _json = self._serialize.body(parameters, 'ActivateApplicationPackageParameters') @@ -95,11 +97,13 @@ async def activate( content_type=content_type, json=_json, template_url=self.activate.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 @@ -127,9 +131,9 @@ async def create( account_name: str, application_name: str, version_name: str, - parameters: Optional["_models.ApplicationPackage"] = None, + parameters: Optional[_models.ApplicationPackage] = None, **kwargs: Any - ) -> "_models.ApplicationPackage": + ) -> _models.ApplicationPackage: """Creates an application package record. The record contains a storageUrl where the package should be uploaded to. Once it is uploaded the ``ApplicationPackage`` needs to be activated using ``ApplicationPackageActive`` before it can be used. If the auto storage account was @@ -150,14 +154,17 @@ async def create( :rtype: ~azure.mgmt.batch.models.ApplicationPackage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationPackage"] 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-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-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.ApplicationPackage] if parameters is not None: _json = self._serialize.body(parameters, 'ApplicationPackage') @@ -174,11 +181,13 @@ async def create( content_type=content_type, json=_json, template_url=self.create.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 @@ -223,13 +232,16 @@ async def delete( # 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 = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -240,11 +252,13 @@ async def delete( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 @@ -269,7 +283,7 @@ async def get( application_name: str, version_name: str, **kwargs: Any - ) -> "_models.ApplicationPackage": + ) -> _models.ApplicationPackage: """Gets information about the specified application package. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -285,13 +299,16 @@ async def get( :rtype: ~azure.mgmt.batch.models.ApplicationPackage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationPackage"] 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-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPackage] request = build_get_request( @@ -302,11 +319,13 @@ async def get( subscription_id=self._config.subscription_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 @@ -335,7 +354,7 @@ def list( application_name: str, maxresults: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListApplicationPackagesResult"]: + ) -> AsyncIterable[_models.ListApplicationPackagesResult]: """Lists all of the application packages in the specified application. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -354,13 +373,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.ListApplicationPackagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListApplicationPackagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListApplicationPackagesResult"] 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: @@ -372,9 +394,11 @@ def prepare_request(next_link=None): api_version=api_version, maxresults=maxresults, 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: @@ -386,9 +410,11 @@ def prepare_request(next_link=None): api_version=api_version, maxresults=maxresults, 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/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_batch_account_operations.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_batch_account_operations.py index 2ab82079ee46..471d0a9419d6 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_batch_account_operations.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_batch_account_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,6 +16,7 @@ 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 @@ -26,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BatchAccountOperations: - """BatchAccountOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.batch.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.batch.aio.BatchManagementClient`'s + :attr:`batch_account` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.BatchAccountCreateParameters", + parameters: _models.BatchAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.BatchAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BatchAccount"]] + ) -> Optional[_models.BatchAccount]: 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-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-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[Optional[_models.BatchAccount]] _json = self._serialize.body(parameters, 'BatchAccountCreateParameters') @@ -73,11 +75,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 @@ -111,9 +115,9 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.BatchAccountCreateParameters", + parameters: _models.BatchAccountCreateParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.BatchAccount"]: + ) -> AsyncLROPoller[_models.BatchAccount]: """Creates a new Batch account with the specified parameters. Existing accounts cannot be updated with this API and should instead be updated with the Update Batch Account API. @@ -140,37 +144,47 @@ async def begin_create( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.batch.models.BatchAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.BatchAccount] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BatchAccount"] 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, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('BatchAccount', 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': '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( @@ -188,9 +202,9 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: "_models.BatchAccountUpdateParameters", + parameters: _models.BatchAccountUpdateParameters, **kwargs: Any - ) -> "_models.BatchAccount": + ) -> _models.BatchAccount: """Updates the properties of an existing Batch account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -204,14 +218,17 @@ async def update( :rtype: ~azure.mgmt.batch.models.BatchAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BatchAccount"] 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-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-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.BatchAccount] _json = self._serialize.body(parameters, 'BatchAccountUpdateParameters') @@ -223,11 +240,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 @@ -254,13 +273,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 {}) - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -269,11 +291,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_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 @@ -321,20 +345,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-06-01") # 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-06-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) @@ -344,8 +373,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( @@ -364,7 +399,7 @@ async def get( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BatchAccount": + ) -> _models.BatchAccount: """Gets information about the specified Batch account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -376,13 +411,16 @@ async def get( :rtype: ~azure.mgmt.batch.models.BatchAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BatchAccount"] 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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BatchAccount] request = build_get_request( @@ -391,11 +429,13 @@ async def get( subscription_id=self._config.subscription_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 @@ -420,7 +460,7 @@ async def get( def list( self, **kwargs: Any - ) -> AsyncIterable["_models.BatchAccountListResult"]: + ) -> AsyncIterable[_models.BatchAccountListResult]: """Gets information about the Batch accounts associated with the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -430,13 +470,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.BatchAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BatchAccountListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BatchAccountListResult"] 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: @@ -444,9 +487,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -454,9 +499,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 @@ -494,7 +541,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.BatchAccountListResult"]: + ) -> AsyncIterable[_models.BatchAccountListResult]: """Gets information about the Batch accounts associated with the specified resource group. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -506,13 +553,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.BatchAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BatchAccountListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BatchAccountListResult"] 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: @@ -521,9 +571,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: @@ -532,9 +584,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 @@ -586,13 +640,16 @@ async def synchronize_auto_storage_keys( # pylint: disable=inconsistent-return- :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-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_synchronize_auto_storage_keys_request( @@ -601,11 +658,13 @@ async def synchronize_auto_storage_keys( # pylint: disable=inconsistent-return- subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.synchronize_auto_storage_keys.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 @@ -627,9 +686,9 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - parameters: "_models.BatchAccountRegenerateKeyParameters", + parameters: _models.BatchAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.BatchAccountKeys": + ) -> _models.BatchAccountKeys: """Regenerates the specified account key for the Batch account. This operation applies only to Batch accounts with allowedAuthenticationModes containing @@ -648,14 +707,17 @@ async def regenerate_key( :rtype: ~azure.mgmt.batch.models.BatchAccountKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BatchAccountKeys"] 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-06-01") # 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-06-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.BatchAccountKeys] _json = self._serialize.body(parameters, 'BatchAccountRegenerateKeyParameters') @@ -667,11 +729,13 @@ async def regenerate_key( content_type=content_type, json=_json, template_url=self.regenerate_key.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 @@ -698,7 +762,7 @@ async def get_keys( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BatchAccountKeys": + ) -> _models.BatchAccountKeys: """Gets the account keys for the specified Batch account. This operation applies only to Batch accounts with allowedAuthenticationModes containing @@ -715,13 +779,16 @@ async def get_keys( :rtype: ~azure.mgmt.batch.models.BatchAccountKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BatchAccountKeys"] 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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BatchAccountKeys] request = build_get_keys_request( @@ -730,11 +797,13 @@ async def get_keys( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_keys.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 @@ -761,7 +830,7 @@ def list_detectors( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DetectorListResult"]: + ) -> AsyncIterable[_models.DetectorListResult]: """Gets information about the detectors available for a given Batch account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -773,13 +842,16 @@ def list_detectors( :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.DetectorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DetectorListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DetectorListResult"] 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: @@ -789,9 +861,11 @@ def prepare_request(next_link=None): account_name=account_name, api_version=api_version, template_url=self.list_detectors.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: @@ -801,9 +875,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 @@ -843,7 +919,7 @@ async def get_detector( account_name: str, detector_id: str, **kwargs: Any - ) -> "_models.DetectorResponse": + ) -> _models.DetectorResponse: """Gets information about the given detector for a given Batch account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -857,13 +933,16 @@ async def get_detector( :rtype: ~azure.mgmt.batch.models.DetectorResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DetectorResponse"] 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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DetectorResponse] request = build_get_detector_request( @@ -873,11 +952,13 @@ async def get_detector( detector_id=detector_id, api_version=api_version, template_url=self.get_detector.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 @@ -904,13 +985,13 @@ def list_outbound_network_dependencies_endpoints( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.OutboundEnvironmentEndpointCollection"]: + ) -> AsyncIterable[_models.OutboundEnvironmentEndpointCollection]: """Lists the endpoints that a Batch Compute Node under this Batch Account may call as part of Batch service administration. If you are deploying a Pool inside of a virtual network that you specify, you must make sure your network allows outbound access to these endpoints. Failure to allow access to these endpoints may cause Batch to mark the affected nodes as unusable. For more information about creating a pool inside of a virtual network, see - https://docs.microsoft.com/en-us/azure/batch/batch-virtual-network. + https://docs.microsoft.com/azure/batch/batch-virtual-network. :param resource_group_name: The name of the resource group that contains the Batch account. :type resource_group_name: str @@ -923,13 +1004,16 @@ def list_outbound_network_dependencies_endpoints( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.OutboundEnvironmentEndpointCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OutboundEnvironmentEndpointCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundEnvironmentEndpointCollection"] 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: @@ -939,9 +1023,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_outbound_network_dependencies_endpoints.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: @@ -951,9 +1037,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 diff --git a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_certificate_operations.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_certificate_operations.py index 644cd1d5a4db..0b64f861d983 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_certificate_operations.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_certificate_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,6 +16,7 @@ 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 @@ -26,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CertificateOperations: - """CertificateOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.batch.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.batch.aio.BatchManagementClient`'s + :attr:`certificate` 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_batch_account( @@ -56,7 +55,7 @@ def list_by_batch_account( select: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListCertificatesResult"]: + ) -> AsyncIterable[_models.ListCertificatesResult]: """Lists all of the certificates in the specified account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -81,13 +80,16 @@ def list_by_batch_account( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.ListCertificatesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListCertificatesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListCertificatesResult"] 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: @@ -100,9 +102,11 @@ def prepare_request(next_link=None): select=select, filter=filter, template_url=self.list_by_batch_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: @@ -115,9 +119,11 @@ def prepare_request(next_link=None): select=select, filter=filter, 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 @@ -156,11 +162,11 @@ async def create( resource_group_name: str, account_name: str, certificate_name: str, - parameters: "_models.CertificateCreateOrUpdateParameters", + parameters: _models.CertificateCreateOrUpdateParameters, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> "_models.Certificate": + ) -> _models.Certificate: """Creates a new certificate inside the specified account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -185,14 +191,17 @@ async def create( :rtype: ~azure.mgmt.batch.models.Certificate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Certificate"] 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-06-01") # 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-06-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.Certificate] _json = self._serialize.body(parameters, 'CertificateCreateOrUpdateParameters') @@ -207,11 +216,13 @@ async def create( if_match=if_match, if_none_match=if_none_match, template_url=self.create.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 @@ -241,10 +252,10 @@ async def update( resource_group_name: str, account_name: str, certificate_name: str, - parameters: "_models.CertificateCreateOrUpdateParameters", + parameters: _models.CertificateCreateOrUpdateParameters, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.Certificate": + ) -> _models.Certificate: """Updates the properties of an existing certificate. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -265,14 +276,17 @@ async def update( :rtype: ~azure.mgmt.batch.models.Certificate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Certificate"] 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-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-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.Certificate] _json = self._serialize.body(parameters, 'CertificateCreateOrUpdateParameters') @@ -286,11 +300,13 @@ async def update( json=_json, if_match=if_match, 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 @@ -321,13 +337,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements certificate_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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -337,11 +356,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_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 @@ -394,21 +415,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-06-01") # 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-06-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, certificate_name=certificate_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -418,8 +444,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( @@ -439,7 +471,7 @@ async def get( account_name: str, certificate_name: str, **kwargs: Any - ) -> "_models.Certificate": + ) -> _models.Certificate: """Gets information about the specified certificate. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -455,13 +487,16 @@ async def get( :rtype: ~azure.mgmt.batch.models.Certificate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Certificate"] 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-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Certificate] request = build_get_request( @@ -471,11 +506,13 @@ async def get( subscription_id=self._config.subscription_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 @@ -506,7 +543,7 @@ async def cancel_deletion( account_name: str, certificate_name: str, **kwargs: Any - ) -> "_models.Certificate": + ) -> _models.Certificate: """Cancels a failed deletion of a certificate from the specified account. If you try to delete a certificate that is being used by a pool or compute node, the status of @@ -529,13 +566,16 @@ async def cancel_deletion( :rtype: ~azure.mgmt.batch.models.Certificate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Certificate"] 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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Certificate] request = build_cancel_deletion_request( @@ -545,11 +585,13 @@ async def cancel_deletion( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.cancel_deletion.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/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_location_operations.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_location_operations.py index dc40d2bf7e64..321e26aa1413 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_location_operations.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_location_operations.py @@ -15,6 +15,7 @@ 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 @@ -24,33 +25,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LocationOperations: - """LocationOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.batch.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.batch.aio.BatchManagementClient`'s + :attr:`location` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get_quotas( self, location_name: str, **kwargs: Any - ) -> "_models.BatchLocationQuota": + ) -> _models.BatchLocationQuota: """Gets the Batch service quotas for the specified subscription at the given location. :param location_name: The region for which to retrieve Batch service quotas. @@ -60,13 +59,16 @@ async def get_quotas( :rtype: ~azure.mgmt.batch.models.BatchLocationQuota :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BatchLocationQuota"] 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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BatchLocationQuota] request = build_get_quotas_request( @@ -74,11 +76,13 @@ async def get_quotas( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_quotas.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 @@ -106,7 +110,7 @@ def list_supported_virtual_machine_skus( maxresults: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.SupportedSkusResult"]: + ) -> AsyncIterable[_models.SupportedSkusResult]: """Gets the list of Batch supported Virtual Machine VM sizes available at the given location. :param location_name: The region for which to retrieve Batch service supported SKUs. @@ -122,13 +126,16 @@ def list_supported_virtual_machine_skus( :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.SupportedSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SupportedSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedSkusResult"] 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: @@ -139,9 +146,11 @@ def prepare_request(next_link=None): maxresults=maxresults, filter=filter, template_url=self.list_supported_virtual_machine_skus.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: @@ -152,9 +161,11 @@ def prepare_request(next_link=None): maxresults=maxresults, filter=filter, 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 @@ -194,7 +205,7 @@ def list_supported_cloud_service_skus( maxresults: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.SupportedSkusResult"]: + ) -> AsyncIterable[_models.SupportedSkusResult]: """Gets the list of Batch supported Cloud Service VM sizes available at the given location. :param location_name: The region for which to retrieve Batch service supported SKUs. @@ -210,13 +221,16 @@ def list_supported_cloud_service_skus( :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.SupportedSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SupportedSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedSkusResult"] 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: @@ -227,9 +241,11 @@ def prepare_request(next_link=None): maxresults=maxresults, filter=filter, template_url=self.list_supported_cloud_service_skus.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: @@ -240,9 +256,11 @@ def prepare_request(next_link=None): maxresults=maxresults, filter=filter, 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 @@ -279,9 +297,9 @@ async def get_next(next_link=None): async def check_name_availability( self, location_name: str, - parameters: "_models.CheckNameAvailabilityParameters", + parameters: _models.CheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks whether the Batch account name is available in the specified region. :param location_name: The desired region for the name check. @@ -293,14 +311,17 @@ async def check_name_availability( :rtype: ~azure.mgmt.batch.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] 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-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-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.CheckNameAvailabilityResult] _json = self._serialize.body(parameters, 'CheckNameAvailabilityParameters') @@ -311,11 +332,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/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_operations.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_operations.py index a1c905d00d6d..f9e34f887602 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_operations.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_operations.py @@ -14,6 +14,7 @@ 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 @@ -23,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.batch.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.batch.aio.BatchManagementClient`'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]: """Lists available operations for the Microsoft.Batch provider. :keyword callable cls: A custom type or function that will be passed the direct response @@ -56,31 +55,38 @@ def list( :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_patch.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/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/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_pool_operations.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_pool_operations.py index 0763264e3e72..3d8017e07864 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_pool_operations.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_pool_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,6 +16,7 @@ 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 @@ -26,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PoolOperations: - """PoolOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.batch.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.batch.aio.BatchManagementClient`'s + :attr:`pool` 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_batch_account( @@ -56,7 +55,7 @@ def list_by_batch_account( select: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListPoolsResult"]: + ) -> AsyncIterable[_models.ListPoolsResult]: """Lists all of the pools in the specified account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -89,13 +88,16 @@ def list_by_batch_account( :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.ListPoolsResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListPoolsResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListPoolsResult"] 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: @@ -108,9 +110,11 @@ def prepare_request(next_link=None): select=select, filter=filter, template_url=self.list_by_batch_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: @@ -123,9 +127,11 @@ def prepare_request(next_link=None): select=select, filter=filter, 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 @@ -164,11 +170,11 @@ async def create( resource_group_name: str, account_name: str, pool_name: str, - parameters: "_models.Pool", + parameters: _models.Pool, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> "_models.Pool": + ) -> _models.Pool: """Creates a new pool inside the specified account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -191,14 +197,17 @@ async def create( :rtype: ~azure.mgmt.batch.models.Pool :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Pool"] 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-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-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.Pool] _json = self._serialize.body(parameters, 'Pool') @@ -213,11 +222,13 @@ async def create( if_match=if_match, if_none_match=if_none_match, template_url=self.create.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 @@ -247,10 +258,10 @@ async def update( resource_group_name: str, account_name: str, pool_name: str, - parameters: "_models.Pool", + parameters: _models.Pool, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.Pool": + ) -> _models.Pool: """Updates the properties of an existing pool. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -270,14 +281,17 @@ async def update( :rtype: ~azure.mgmt.batch.models.Pool :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Pool"] 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-06-01") # 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-06-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.Pool] _json = self._serialize.body(parameters, 'Pool') @@ -291,11 +305,13 @@ async def update( json=_json, if_match=if_match, 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 @@ -326,13 +342,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements pool_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-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -342,11 +361,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_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 @@ -397,21 +418,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-06-01") # 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-06-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, pool_name=pool_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -421,8 +447,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( @@ -442,7 +474,7 @@ async def get( account_name: str, pool_name: str, **kwargs: Any - ) -> "_models.Pool": + ) -> _models.Pool: """Gets information about the specified pool. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -456,13 +488,16 @@ async def get( :rtype: ~azure.mgmt.batch.models.Pool :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Pool"] 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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Pool] request = build_get_request( @@ -472,11 +507,13 @@ async def get( subscription_id=self._config.subscription_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 @@ -507,7 +544,7 @@ async def disable_auto_scale( account_name: str, pool_name: str, **kwargs: Any - ) -> "_models.Pool": + ) -> _models.Pool: """Disables automatic scaling for a pool. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -521,13 +558,16 @@ async def disable_auto_scale( :rtype: ~azure.mgmt.batch.models.Pool :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Pool"] 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-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Pool] request = build_disable_auto_scale_request( @@ -537,11 +577,13 @@ async def disable_auto_scale( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.disable_auto_scale.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 @@ -572,7 +614,7 @@ async def stop_resize( account_name: str, pool_name: str, **kwargs: Any - ) -> "_models.Pool": + ) -> _models.Pool: """Stops an ongoing resize operation on the pool. This does not restore the pool to its previous state before the resize operation: it only stops @@ -593,13 +635,16 @@ async def stop_resize( :rtype: ~azure.mgmt.batch.models.Pool :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Pool"] 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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Pool] request = build_stop_resize_request( @@ -609,11 +654,13 @@ async def stop_resize( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.stop_resize.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/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_private_endpoint_connection_operations.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_private_endpoint_connection_operations.py index 8fc8a3f200a8..9d11f3a6b25c 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_private_endpoint_connection_operations.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_private_endpoint_connection_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,6 +16,7 @@ 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 @@ -26,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateEndpointConnectionOperations: - """PrivateEndpointConnectionOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.batch.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.batch.aio.BatchManagementClient`'s + :attr:`private_endpoint_connection` 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_batch_account( @@ -54,7 +53,7 @@ def list_by_batch_account( account_name: str, maxresults: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListPrivateEndpointConnectionsResult"]: + ) -> AsyncIterable[_models.ListPrivateEndpointConnectionsResult]: """Lists all of the private endpoint connections in the specified account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -71,13 +70,16 @@ def list_by_batch_account( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.ListPrivateEndpointConnectionsResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListPrivateEndpointConnectionsResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListPrivateEndpointConnectionsResult"] 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: @@ -88,9 +90,11 @@ def prepare_request(next_link=None): api_version=api_version, maxresults=maxresults, template_url=self.list_by_batch_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: @@ -101,9 +105,11 @@ def prepare_request(next_link=None): api_version=api_version, maxresults=maxresults, 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 @@ -143,7 +149,7 @@ async def get( account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets information about the specified private endpoint connection. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -158,13 +164,16 @@ async def get( :rtype: ~azure.mgmt.batch.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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -174,11 +183,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 @@ -204,18 +215,21 @@ async def _update_initial( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - parameters: "_models.PrivateEndpointConnection", + parameters: _models.PrivateEndpointConnection, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.PrivateEndpointConnection"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] + ) -> Optional[_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-06-01") # 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-06-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[Optional[_models.PrivateEndpointConnection]] _json = self._serialize.body(parameters, 'PrivateEndpointConnection') @@ -229,11 +243,13 @@ async def _update_initial( json=_json, if_match=if_match, 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 @@ -268,10 +284,10 @@ async def begin_update( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - parameters: "_models.PrivateEndpointConnection", + parameters: _models.PrivateEndpointConnection, if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Updates the properties of an existing private endpoint connection. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -301,17 +317,20 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.batch.models.PrivateEndpointConnection] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -320,20 +339,27 @@ async def begin_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( @@ -353,13 +379,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-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -369,11 +398,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 @@ -425,21 +456,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-06-01") # 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-06-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) @@ -449,8 +485,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': '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/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_private_link_resource_operations.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_private_link_resource_operations.py index 8e3a435f39ae..708379ba5a2a 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_private_link_resource_operations.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_private_link_resource_operations.py @@ -15,6 +15,7 @@ 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 @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateLinkResourceOperations: - """PrivateLinkResourceOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.batch.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.batch.aio.BatchManagementClient`'s + :attr:`private_link_resource` 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_batch_account( @@ -52,7 +51,7 @@ def list_by_batch_account( account_name: str, maxresults: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListPrivateLinkResourcesResult"]: + ) -> AsyncIterable[_models.ListPrivateLinkResourcesResult]: """Lists all of the private link resources in the specified account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -69,13 +68,16 @@ def list_by_batch_account( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.ListPrivateLinkResourcesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListPrivateLinkResourcesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListPrivateLinkResourcesResult"] 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: @@ -86,9 +88,11 @@ def prepare_request(next_link=None): api_version=api_version, maxresults=maxresults, template_url=self.list_by_batch_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: @@ -99,9 +103,11 @@ def prepare_request(next_link=None): api_version=api_version, maxresults=maxresults, 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 @@ -141,7 +147,7 @@ async def get( account_name: str, private_link_resource_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResource": + ) -> _models.PrivateLinkResource: """Gets information about the specified private link resource. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -156,13 +162,16 @@ async def get( :rtype: ~azure.mgmt.batch.models.PrivateLinkResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] 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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResource] request = build_get_request( @@ -172,11 +181,13 @@ async def get( private_link_resource_name=private_link_resource_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 diff --git a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/models/__init__.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/models/__init__.py index af6716ffd7a8..36544d078586 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/models/__init__.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/models/__init__.py @@ -145,7 +145,9 @@ ResourceIdentityType, StorageAccountType, ) - +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__ = [ 'ActivateApplicationPackageParameters', 'Application', @@ -283,3 +285,5 @@ 'ResourceIdentityType', 'StorageAccountType', ] +__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/batch/azure-mgmt-batch/azure/mgmt/batch/models/_batch_management_client_enums.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/models/_batch_management_client_enums.py index a5b553f83d30..473922658545 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/models/_batch_management_client_enums.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/models/_batch_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccountKeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of account key to regenerate. """ @@ -20,7 +19,7 @@ class AccountKeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The secondary account key. SECONDARY = "Secondary" -class AllocationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AllocationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Whether the pool is resizing. """ @@ -34,7 +33,7 @@ class AllocationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: request has not yet been completed. STOPPING = "Stopping" -class AuthenticationMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AuthenticationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication mode for the Batch account. """ @@ -45,7 +44,7 @@ class AuthenticationMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The authentication mode using task authentication tokens. TASK_AUTHENTICATION_TOKEN = "TaskAuthenticationToken" -class AutoStorageAuthenticationMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AutoStorageAuthenticationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication mode which the Batch service will use to manage the auto-storage account. """ @@ -55,7 +54,7 @@ class AutoStorageAuthenticationMode(with_metaclass(CaseInsensitiveEnumMeta, str, #: assigned to the Batch account. BATCH_ACCOUNT_MANAGED_IDENTITY = "BatchAccountManagedIdentity" -class AutoUserScope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AutoUserScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The default value is Pool. If the pool is running Windows a value of Task should be specified if stricter isolation between tasks is required. For example, if the task mutates the registry in a way which could impact other tasks, or if certificates have been specified on the pool @@ -68,7 +67,7 @@ class AutoUserScope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: a pool. POOL = "Pool" -class CachingType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CachingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of caching to enable for the disk. """ @@ -79,7 +78,7 @@ class CachingType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The caching mode for the disk is read and write. READ_WRITE = "ReadWrite" -class CertificateFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CertificateFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The format of the certificate - either Pfx or Cer. If omitted, the default is Pfx. """ @@ -88,7 +87,7 @@ class CertificateFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The certificate is a base64-encoded X.509 certificate. CER = "Cer" -class CertificateProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CertificateProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: The certificate is available for use in pools. SUCCEEDED = "Succeeded" @@ -103,7 +102,7 @@ class CertificateProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, #: the delete. FAILED = "Failed" -class CertificateStoreLocation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CertificateStoreLocation(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The default value is currentUser. This property is applicable only for pools configured with Windows nodes (that is, created with cloudServiceConfiguration, or with virtualMachineConfiguration using a Windows image reference). For Linux compute nodes, the @@ -118,7 +117,7 @@ class CertificateStoreLocation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum #: Certificates should be installed to the LocalMachine certificate store. LOCAL_MACHINE = "LocalMachine" -class CertificateVisibility(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CertificateVisibility(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: The certificate should be visible to the user account under which the start task is run. Note #: that if AutoUser Scope is Pool for both the StartTask and a Task, this certificate will be @@ -130,7 +129,7 @@ class CertificateVisibility(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: node. REMOTE_USER = "RemoteUser" -class ComputeNodeDeallocationOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ComputeNodeDeallocationOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Determines what to do with a node and its running task(s) after it has been selected for deallocation. """ @@ -149,7 +148,7 @@ class ComputeNodeDeallocationOption(with_metaclass(CaseInsensitiveEnumMeta, str, #: expired. RETAINED_DATA = "RetainedData" -class ComputeNodeFillType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ComputeNodeFillType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """How tasks should be distributed across compute nodes. """ @@ -159,7 +158,7 @@ class ComputeNodeFillType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: any tasks are assigned to the next node in the pool. PACK = "Pack" -class ContainerWorkingDirectory(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ContainerWorkingDirectory(str, Enum, metaclass=CaseInsensitiveEnumMeta): """A flag to indicate where the container task working directory is. The default is 'taskWorkingDirectory'. """ @@ -171,7 +170,7 @@ class ContainerWorkingDirectory(with_metaclass(CaseInsensitiveEnumMeta, str, Enu #: the resource files downloaded by Batch. CONTAINER_IMAGE_DEFAULT = "ContainerImageDefault" -class DiskEncryptionTarget(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskEncryptionTarget(str, Enum, metaclass=CaseInsensitiveEnumMeta): """If omitted, no disks on the compute nodes in the pool will be encrypted. """ @@ -181,7 +180,7 @@ class DiskEncryptionTarget(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: partitions (such as those on mounted data disks) when encryption occurs at boot time. TEMPORARY_DISK = "TemporaryDisk" -class DynamicVNetAssignmentScope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DynamicVNetAssignmentScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scope of dynamic vnet assignment. """ @@ -191,7 +190,7 @@ class DynamicVNetAssignmentScope(with_metaclass(CaseInsensitiveEnumMeta, str, En #: ID must also be set. This feature requires approval before use, please contact support. JOB = "job" -class ElevationLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ElevationLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The elevation level of the user. """ @@ -200,7 +199,7 @@ class ElevationLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The user is a user with elevated access and operates with full Administrator permissions. ADMIN = "Admin" -class EndpointAccessDefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EndpointAccessDefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Default action for endpoint access. It is only applicable when publicNetworkAccess is enabled. """ @@ -209,7 +208,7 @@ class EndpointAccessDefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, E #: Deny client access. DENY = "Deny" -class InboundEndpointProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class InboundEndpointProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The protocol of the endpoint. """ @@ -218,7 +217,7 @@ class InboundEndpointProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) #: Use UDP for the endpoint. UDP = "UDP" -class InterNodeCommunicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class InterNodeCommunicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This imposes restrictions on which nodes can be assigned to the pool. Enabling this value can reduce the chance of the requested number of nodes to be allocated in the pool. If not specified, this value defaults to 'Disabled'. @@ -229,7 +228,7 @@ class InterNodeCommunicationState(with_metaclass(CaseInsensitiveEnumMeta, str, E #: Disable network communication between virtual machines. DISABLED = "Disabled" -class IPAddressProvisioningType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IPAddressProvisioningType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning type for Public IP Addresses for the Batch Pool. """ @@ -241,7 +240,7 @@ class IPAddressProvisioningType(with_metaclass(CaseInsensitiveEnumMeta, str, Enu #: No public IP Address will be created for the Compute Nodes in the Pool. NO_PUBLIC_IP_ADDRESSES = "NoPublicIPAddresses" -class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of the key source. """ @@ -252,7 +251,7 @@ class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Identifier must also be supplied under the keyVaultProperties. MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" -class LoginMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LoginMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies login mode for the user. The default value for VirtualMachineConfiguration pools is interactive mode and for CloudServiceConfiguration pools is batch mode. """ @@ -265,7 +264,7 @@ class LoginMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: task, then this option is recommended. INTERACTIVE = "Interactive" -class NameAvailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class NameAvailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a Batch account name could not be used. The Reason element is only returned if NameAvailable is false. """ @@ -275,7 +274,7 @@ class NameAvailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)) #: The requested name is already in use. ALREADY_EXISTS = "AlreadyExists" -class NetworkSecurityGroupRuleAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class NetworkSecurityGroupRuleAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The action that should be taken for a specified IP address, subnet range or tag. """ @@ -284,7 +283,7 @@ class NetworkSecurityGroupRuleAccess(with_metaclass(CaseInsensitiveEnumMeta, str #: Deny access. DENY = "Deny" -class NodePlacementPolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class NodePlacementPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The default value is regional. """ @@ -293,7 +292,7 @@ class NodePlacementPolicyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) #: Nodes in the pool will be spread across different zones with best effort balancing. ZONAL = "Zonal" -class PackageState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PackageState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current state of the application package. """ @@ -302,7 +301,7 @@ class PackageState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The application package is ready for use. ACTIVE = "Active" -class PoolAllocationMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PoolAllocationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The allocation mode for creating pools in the Batch account. """ @@ -311,7 +310,7 @@ class PoolAllocationMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Pools will be allocated in a subscription owned by the user. USER_SUBSCRIPTION = "UserSubscription" -class PoolIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PoolIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the Batch Pool. """ @@ -321,7 +320,7 @@ class PoolIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: existing identities. NONE = "None" -class PoolProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PoolProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current state of the pool. """ @@ -331,7 +330,7 @@ class PoolProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: completed. DELETING = "Deleting" -class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state of the private endpoint connection. """ @@ -350,7 +349,7 @@ class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveE #: The user has cancelled the connection creation. CANCELLED = "Cancelled" -class PrivateLinkServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateLinkServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the Batch private endpoint connection """ @@ -363,7 +362,7 @@ class PrivateLinkServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, #: The private endpoint connection is disconnected and cannot be used to access Batch account. DISCONNECTED = "Disconnected" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioned state of the resource """ @@ -380,7 +379,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The last operation for the account is cancelled. CANCELLED = "Cancelled" -class PublicNetworkAccessType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicNetworkAccessType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The network access type for operating on the resources in the Batch account. """ @@ -390,7 +389,7 @@ class PublicNetworkAccessType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) #: private endpoint resource. DISABLED = "Disabled" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the Batch account. """ @@ -402,7 +401,7 @@ class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: remove existing identities. NONE = "None" -class StorageAccountType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The storage account type for use in creating data disks. """ diff --git a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/models/_models_py3.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/models/_models_py3.py index e0a569a0d8da..7c04215d910a 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/models/_models_py3.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/models/_models_py3.py @@ -7,11 +7,13 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union import msrest.serialization -from ._batch_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class ActivateApplicationPackageParameters(msrest.serialization.Model): @@ -164,7 +166,7 @@ class ApplicationPackage(ProxyResource): :vartype type: str :ivar etag: The ETag of the resource, used for concurrency statements. :vartype etag: str - :ivar state: The current state of the application package. Possible values include: "Pending", + :ivar state: The current state of the application package. Known values are: "Pending", "Active". :vartype state: str or ~azure.mgmt.batch.models.PackageState :ivar format: The format of the application package, if the package is active. @@ -291,7 +293,7 @@ def __init__( *, evaluation_time: datetime.datetime, results: Optional[str] = None, - error: Optional["AutoScaleRunError"] = None, + error: Optional["_models.AutoScaleRunError"] = None, **kwargs ): """ @@ -340,7 +342,7 @@ def __init__( *, code: str, message: str, - details: Optional[List["AutoScaleRunError"]] = None, + details: Optional[List["_models.AutoScaleRunError"]] = None, **kwargs ): """ @@ -406,8 +408,8 @@ class AutoStorageBaseProperties(msrest.serialization.Model): auto-storage account. :vartype storage_account_id: str :ivar authentication_mode: The authentication mode which the Batch service will use to manage - the auto-storage account. Possible values include: "StorageKeys", - "BatchAccountManagedIdentity". Default value: "StorageKeys". + the auto-storage account. Known values are: "StorageKeys", "BatchAccountManagedIdentity". + Default value: "StorageKeys". :vartype authentication_mode: str or ~azure.mgmt.batch.models.AutoStorageAuthenticationMode :ivar node_identity_reference: The identity referenced here must be assigned to pools which have compute nodes that need access to auto-storage. @@ -428,8 +430,8 @@ def __init__( self, *, storage_account_id: str, - authentication_mode: Optional[Union[str, "AutoStorageAuthenticationMode"]] = "StorageKeys", - node_identity_reference: Optional["ComputeNodeIdentityReference"] = None, + authentication_mode: Optional[Union[str, "_models.AutoStorageAuthenticationMode"]] = "StorageKeys", + node_identity_reference: Optional["_models.ComputeNodeIdentityReference"] = None, **kwargs ): """ @@ -437,7 +439,7 @@ def __init__( auto-storage account. :paramtype storage_account_id: str :keyword authentication_mode: The authentication mode which the Batch service will use to - manage the auto-storage account. Possible values include: "StorageKeys", + manage the auto-storage account. Known values are: "StorageKeys", "BatchAccountManagedIdentity". Default value: "StorageKeys". :paramtype authentication_mode: str or ~azure.mgmt.batch.models.AutoStorageAuthenticationMode :keyword node_identity_reference: The identity referenced here must be assigned to pools which @@ -459,8 +461,8 @@ class AutoStorageProperties(AutoStorageBaseProperties): auto-storage account. :vartype storage_account_id: str :ivar authentication_mode: The authentication mode which the Batch service will use to manage - the auto-storage account. Possible values include: "StorageKeys", - "BatchAccountManagedIdentity". Default value: "StorageKeys". + the auto-storage account. Known values are: "StorageKeys", "BatchAccountManagedIdentity". + Default value: "StorageKeys". :vartype authentication_mode: str or ~azure.mgmt.batch.models.AutoStorageAuthenticationMode :ivar node_identity_reference: The identity referenced here must be assigned to pools which have compute nodes that need access to auto-storage. @@ -487,8 +489,8 @@ def __init__( *, storage_account_id: str, last_key_sync: datetime.datetime, - authentication_mode: Optional[Union[str, "AutoStorageAuthenticationMode"]] = "StorageKeys", - node_identity_reference: Optional["ComputeNodeIdentityReference"] = None, + authentication_mode: Optional[Union[str, "_models.AutoStorageAuthenticationMode"]] = "StorageKeys", + node_identity_reference: Optional["_models.ComputeNodeIdentityReference"] = None, **kwargs ): """ @@ -496,7 +498,7 @@ def __init__( auto-storage account. :paramtype storage_account_id: str :keyword authentication_mode: The authentication mode which the Batch service will use to - manage the auto-storage account. Possible values include: "StorageKeys", + manage the auto-storage account. Known values are: "StorageKeys", "BatchAccountManagedIdentity". Default value: "StorageKeys". :paramtype authentication_mode: str or ~azure.mgmt.batch.models.AutoStorageAuthenticationMode :keyword node_identity_reference: The identity referenced here must be assigned to pools which @@ -517,10 +519,9 @@ class AutoUserSpecification(msrest.serialization.Model): be specified if stricter isolation between tasks is required. For example, if the task mutates the registry in a way which could impact other tasks, or if certificates have been specified on the pool which should not be accessible by normal tasks but should be accessible by start - tasks. Possible values include: "Task", "Pool". + tasks. Known values are: "Task", "Pool". :vartype scope: str or ~azure.mgmt.batch.models.AutoUserScope - :ivar elevation_level: The default value is nonAdmin. Possible values include: "NonAdmin", - "Admin". + :ivar elevation_level: The default value is nonAdmin. Known values are: "NonAdmin", "Admin". :vartype elevation_level: str or ~azure.mgmt.batch.models.ElevationLevel """ @@ -532,8 +533,8 @@ class AutoUserSpecification(msrest.serialization.Model): def __init__( self, *, - scope: Optional[Union[str, "AutoUserScope"]] = None, - elevation_level: Optional[Union[str, "ElevationLevel"]] = None, + scope: Optional[Union[str, "_models.AutoUserScope"]] = None, + elevation_level: Optional[Union[str, "_models.ElevationLevel"]] = None, **kwargs ): """ @@ -541,10 +542,9 @@ def __init__( should be specified if stricter isolation between tasks is required. For example, if the task mutates the registry in a way which could impact other tasks, or if certificates have been specified on the pool which should not be accessible by normal tasks but should be accessible - by start tasks. Possible values include: "Task", "Pool". + by start tasks. Known values are: "Task", "Pool". :paramtype scope: str or ~azure.mgmt.batch.models.AutoUserScope - :keyword elevation_level: The default value is nonAdmin. Possible values include: "NonAdmin", - "Admin". + :keyword elevation_level: The default value is nonAdmin. Known values are: "NonAdmin", "Admin". :paramtype elevation_level: str or ~azure.mgmt.batch.models.ElevationLevel """ super(AutoUserSpecification, self).__init__(**kwargs) @@ -602,7 +602,7 @@ def __init__( account_key: Optional[str] = None, sas_key: Optional[str] = None, blobfuse_options: Optional[str] = None, - identity_reference: Optional["ComputeNodeIdentityReference"] = None, + identity_reference: Optional["_models.ComputeNodeIdentityReference"] = None, **kwargs ): """ @@ -769,16 +769,16 @@ class BatchAccount(Resource): :ivar node_management_endpoint: The endpoint used by compute node to connect to the Batch node management service. :vartype node_management_endpoint: str - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Invalid", "Creating", "Deleting", "Succeeded", "Failed", "Cancelled". + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Invalid", + "Creating", "Deleting", "Succeeded", "Failed", "Cancelled". :vartype provisioning_state: str or ~azure.mgmt.batch.models.ProvisioningState - :ivar pool_allocation_mode: The allocation mode for creating pools in the Batch account. - Possible values include: "BatchService", "UserSubscription". + :ivar pool_allocation_mode: The allocation mode for creating pools in the Batch account. Known + values are: "BatchService", "UserSubscription". :vartype pool_allocation_mode: str or ~azure.mgmt.batch.models.PoolAllocationMode :ivar key_vault_reference: Identifies the Azure key vault associated with a Batch account. :vartype key_vault_reference: ~azure.mgmt.batch.models.KeyVaultReference - :ivar public_network_access: If not specified, the default value is 'enabled'. Possible values - include: "Enabled", "Disabled". Default value: "Enabled". + :ivar public_network_access: If not specified, the default value is 'enabled'. Known values + are: "Enabled", "Disabled". Default value: "Enabled". :vartype public_network_access: str or ~azure.mgmt.batch.models.PublicNetworkAccessType :ivar network_profile: The network profile only takes effect when publicNetworkAccess is enabled. @@ -872,16 +872,16 @@ class BatchAccount(Resource): def __init__( self, *, - identity: Optional["BatchAccountIdentity"] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccessType"]] = "Enabled", - network_profile: Optional["NetworkProfile"] = None, + identity: Optional["_models.BatchAccountIdentity"] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccessType"]] = "Enabled", + network_profile: Optional["_models.NetworkProfile"] = None, **kwargs ): """ :keyword identity: The identity of the Batch account. :paramtype identity: ~azure.mgmt.batch.models.BatchAccountIdentity - :keyword public_network_access: If not specified, the default value is 'enabled'. Possible - values include: "Enabled", "Disabled". Default value: "Enabled". + :keyword public_network_access: If not specified, the default value is 'enabled'. Known values + are: "Enabled", "Disabled". Default value: "Enabled". :paramtype public_network_access: str or ~azure.mgmt.batch.models.PublicNetworkAccessType :keyword network_profile: The network profile only takes effect when publicNetworkAccess is enabled. @@ -924,14 +924,13 @@ class BatchAccountCreateParameters(msrest.serialization.Model): :ivar pool_allocation_mode: The pool allocation mode also affects how clients may authenticate to the Batch Service API. If the mode is BatchService, clients may authenticate using access keys or Azure Active Directory. If the mode is UserSubscription, clients must use Azure Active - Directory. The default is BatchService. Possible values include: "BatchService", - "UserSubscription". + Directory. The default is BatchService. Known values are: "BatchService", "UserSubscription". :vartype pool_allocation_mode: str or ~azure.mgmt.batch.models.PoolAllocationMode :ivar key_vault_reference: A reference to the Azure key vault associated with the Batch account. :vartype key_vault_reference: ~azure.mgmt.batch.models.KeyVaultReference - :ivar public_network_access: If not specified, the default value is 'enabled'. Possible values - include: "Enabled", "Disabled". Default value: "Enabled". + :ivar public_network_access: If not specified, the default value is 'enabled'. Known values + are: "Enabled", "Disabled". Default value: "Enabled". :vartype public_network_access: str or ~azure.mgmt.batch.models.PublicNetworkAccessType :ivar network_profile: The network profile only takes effect when publicNetworkAccess is enabled. @@ -968,14 +967,14 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["BatchAccountIdentity"] = None, - auto_storage: Optional["AutoStorageBaseProperties"] = None, - pool_allocation_mode: Optional[Union[str, "PoolAllocationMode"]] = None, - key_vault_reference: Optional["KeyVaultReference"] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccessType"]] = "Enabled", - network_profile: Optional["NetworkProfile"] = None, - encryption: Optional["EncryptionProperties"] = None, - allowed_authentication_modes: Optional[List[Union[str, "AuthenticationMode"]]] = None, + identity: Optional["_models.BatchAccountIdentity"] = None, + auto_storage: Optional["_models.AutoStorageBaseProperties"] = None, + pool_allocation_mode: Optional[Union[str, "_models.PoolAllocationMode"]] = None, + key_vault_reference: Optional["_models.KeyVaultReference"] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccessType"]] = "Enabled", + network_profile: Optional["_models.NetworkProfile"] = None, + encryption: Optional["_models.EncryptionProperties"] = None, + allowed_authentication_modes: Optional[List[Union[str, "_models.AuthenticationMode"]]] = None, **kwargs ): """ @@ -990,14 +989,14 @@ def __init__( :keyword pool_allocation_mode: The pool allocation mode also affects how clients may authenticate to the Batch Service API. If the mode is BatchService, clients may authenticate using access keys or Azure Active Directory. If the mode is UserSubscription, clients must use - Azure Active Directory. The default is BatchService. Possible values include: "BatchService", + Azure Active Directory. The default is BatchService. Known values are: "BatchService", "UserSubscription". :paramtype pool_allocation_mode: str or ~azure.mgmt.batch.models.PoolAllocationMode :keyword key_vault_reference: A reference to the Azure key vault associated with the Batch account. :paramtype key_vault_reference: ~azure.mgmt.batch.models.KeyVaultReference - :keyword public_network_access: If not specified, the default value is 'enabled'. Possible - values include: "Enabled", "Disabled". Default value: "Enabled". + :keyword public_network_access: If not specified, the default value is 'enabled'. Known values + are: "Enabled", "Disabled". Default value: "Enabled". :paramtype public_network_access: str or ~azure.mgmt.batch.models.PublicNetworkAccessType :keyword network_profile: The network profile only takes effect when publicNetworkAccess is enabled. @@ -1038,7 +1037,7 @@ class BatchAccountIdentity(msrest.serialization.Model): :ivar tenant_id: The tenant id associated with the Batch account. This property will only be provided for a system assigned identity. :vartype tenant_id: str - :ivar type: Required. The type of identity used for the Batch account. Possible values include: + :ivar type: Required. The type of identity used for the Batch account. Known values are: "SystemAssigned", "UserAssigned", "None". :vartype type: str or ~azure.mgmt.batch.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the Batch account. @@ -1061,13 +1060,13 @@ class BatchAccountIdentity(msrest.serialization.Model): def __init__( self, *, - type: Union[str, "ResourceIdentityType"], - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentities"]] = None, + type: Union[str, "_models.ResourceIdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentities"]] = None, **kwargs ): """ - :keyword type: Required. The type of identity used for the Batch account. Possible values - include: "SystemAssigned", "UserAssigned", "None". + :keyword type: Required. The type of identity used for the Batch account. Known values are: + "SystemAssigned", "UserAssigned", "None". :paramtype type: str or ~azure.mgmt.batch.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the Batch account. @@ -1134,7 +1133,7 @@ class BatchAccountListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["BatchAccount"]] = None, + value: Optional[List["_models.BatchAccount"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -1154,8 +1153,8 @@ class BatchAccountRegenerateKeyParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The type of account key to regenerate. Possible values include: - "Primary", "Secondary". + :ivar key_name: Required. The type of account key to regenerate. Known values are: "Primary", + "Secondary". :vartype key_name: str or ~azure.mgmt.batch.models.AccountKeyType """ @@ -1170,11 +1169,11 @@ class BatchAccountRegenerateKeyParameters(msrest.serialization.Model): def __init__( self, *, - key_name: Union[str, "AccountKeyType"], + key_name: Union[str, "_models.AccountKeyType"], **kwargs ): """ - :keyword key_name: Required. The type of account key to regenerate. Possible values include: + :keyword key_name: Required. The type of account key to regenerate. Known values are: "Primary", "Secondary". :paramtype key_name: str or ~azure.mgmt.batch.models.AccountKeyType """ @@ -1199,8 +1198,8 @@ class BatchAccountUpdateParameters(msrest.serialization.Model): that can be used to authenticate with the data plane. This does not affect authentication with the control plane. :vartype allowed_authentication_modes: list[str or ~azure.mgmt.batch.models.AuthenticationMode] - :ivar public_network_access: If not specified, the default value is 'enabled'. Possible values - include: "Enabled", "Disabled". Default value: "Enabled". + :ivar public_network_access: If not specified, the default value is 'enabled'. Known values + are: "Enabled", "Disabled". Default value: "Enabled". :vartype public_network_access: str or ~azure.mgmt.batch.models.PublicNetworkAccessType :ivar network_profile: The network profile only takes effect when publicNetworkAccess is enabled. @@ -1221,12 +1220,12 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - identity: Optional["BatchAccountIdentity"] = None, - auto_storage: Optional["AutoStorageBaseProperties"] = None, - encryption: Optional["EncryptionProperties"] = None, - allowed_authentication_modes: Optional[List[Union[str, "AuthenticationMode"]]] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccessType"]] = "Enabled", - network_profile: Optional["NetworkProfile"] = None, + identity: Optional["_models.BatchAccountIdentity"] = None, + auto_storage: Optional["_models.AutoStorageBaseProperties"] = None, + encryption: Optional["_models.EncryptionProperties"] = None, + allowed_authentication_modes: Optional[List[Union[str, "_models.AuthenticationMode"]]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccessType"]] = "Enabled", + network_profile: Optional["_models.NetworkProfile"] = None, **kwargs ): """ @@ -1245,8 +1244,8 @@ def __init__( authentication with the control plane. :paramtype allowed_authentication_modes: list[str or ~azure.mgmt.batch.models.AuthenticationMode] - :keyword public_network_access: If not specified, the default value is 'enabled'. Possible - values include: "Enabled", "Disabled". Default value: "Enabled". + :keyword public_network_access: If not specified, the default value is 'enabled'. Known values + are: "Enabled", "Disabled". Default value: "Enabled". :paramtype public_network_access: str or ~azure.mgmt.batch.models.PublicNetworkAccessType :keyword network_profile: The network profile only takes effect when publicNetworkAccess is enabled. @@ -1295,7 +1294,7 @@ class BatchPoolIdentity(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of identity used for the Batch Pool. Possible values include: + :ivar type: Required. The type of identity used for the Batch Pool. Known values are: "UserAssigned", "None". :vartype type: str or ~azure.mgmt.batch.models.PoolIdentityType :ivar user_assigned_identities: The list of user identities associated with the Batch pool. @@ -1314,12 +1313,12 @@ class BatchPoolIdentity(msrest.serialization.Model): def __init__( self, *, - type: Union[str, "PoolIdentityType"], - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentities"]] = None, + type: Union[str, "_models.PoolIdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentities"]] = None, **kwargs ): """ - :keyword type: Required. The type of identity used for the Batch Pool. Possible values include: + :keyword type: Required. The type of identity used for the Batch Pool. Known values are: "UserAssigned", "None". :paramtype type: str or ~azure.mgmt.batch.models.PoolIdentityType :keyword user_assigned_identities: The list of user identities associated with the Batch pool. @@ -1349,15 +1348,15 @@ class Certificate(ProxyResource): :ivar thumbprint: This must match the thumbprint from the name. :vartype thumbprint: str :ivar format: The format of the certificate - either Pfx or Cer. If omitted, the default is - Pfx. Possible values include: "Pfx", "Cer". + Pfx. Known values are: "Pfx", "Cer". :vartype format: str or ~azure.mgmt.batch.models.CertificateFormat - :ivar provisioning_state: Possible values include: "Succeeded", "Deleting", "Failed". + :ivar provisioning_state: Known values are: "Succeeded", "Deleting", "Failed". :vartype provisioning_state: str or ~azure.mgmt.batch.models.CertificateProvisioningState :ivar provisioning_state_transition_time: The time at which the certificate entered its current state. :vartype provisioning_state_transition_time: ~datetime.datetime - :ivar previous_provisioning_state: The previous provisioned state of the resource. Possible - values include: "Succeeded", "Deleting", "Failed". + :ivar previous_provisioning_state: The previous provisioned state of the resource. Known values + are: "Succeeded", "Deleting", "Failed". :vartype previous_provisioning_state: str or ~azure.mgmt.batch.models.CertificateProvisioningState :ivar previous_provisioning_state_transition_time: The time at which the certificate entered @@ -1404,7 +1403,7 @@ def __init__( *, thumbprint_algorithm: Optional[str] = None, thumbprint: Optional[str] = None, - format: Optional[Union[str, "CertificateFormat"]] = None, + format: Optional[Union[str, "_models.CertificateFormat"]] = None, **kwargs ): """ @@ -1414,7 +1413,7 @@ def __init__( :keyword thumbprint: This must match the thumbprint from the name. :paramtype thumbprint: str :keyword format: The format of the certificate - either Pfx or Cer. If omitted, the default is - Pfx. Possible values include: "Pfx", "Cer". + Pfx. Known values are: "Pfx", "Cer". :paramtype format: str or ~azure.mgmt.batch.models.CertificateFormat """ super(Certificate, self).__init__(**kwargs) @@ -1438,7 +1437,7 @@ class CertificateBaseProperties(msrest.serialization.Model): :ivar thumbprint: This must match the thumbprint from the name. :vartype thumbprint: str :ivar format: The format of the certificate - either Pfx or Cer. If omitted, the default is - Pfx. Possible values include: "Pfx", "Cer". + Pfx. Known values are: "Pfx", "Cer". :vartype format: str or ~azure.mgmt.batch.models.CertificateFormat """ @@ -1453,7 +1452,7 @@ def __init__( *, thumbprint_algorithm: Optional[str] = None, thumbprint: Optional[str] = None, - format: Optional[Union[str, "CertificateFormat"]] = None, + format: Optional[Union[str, "_models.CertificateFormat"]] = None, **kwargs ): """ @@ -1463,7 +1462,7 @@ def __init__( :keyword thumbprint: This must match the thumbprint from the name. :paramtype thumbprint: str :keyword format: The format of the certificate - either Pfx or Cer. If omitted, the default is - Pfx. Possible values include: "Pfx", "Cer". + Pfx. Known values are: "Pfx", "Cer". :paramtype format: str or ~azure.mgmt.batch.models.CertificateFormat """ super(CertificateBaseProperties, self).__init__(**kwargs) @@ -1491,7 +1490,7 @@ class CertificateCreateOrUpdateParameters(ProxyResource): :ivar thumbprint: This must match the thumbprint from the name. :vartype thumbprint: str :ivar format: The format of the certificate - either Pfx or Cer. If omitted, the default is - Pfx. Possible values include: "Pfx", "Cer". + Pfx. Known values are: "Pfx", "Cer". :vartype format: str or ~azure.mgmt.batch.models.CertificateFormat :ivar data: The maximum size is 10KB. :vartype data: str @@ -1523,7 +1522,7 @@ def __init__( *, thumbprint_algorithm: Optional[str] = None, thumbprint: Optional[str] = None, - format: Optional[Union[str, "CertificateFormat"]] = None, + format: Optional[Union[str, "_models.CertificateFormat"]] = None, data: Optional[str] = None, password: Optional[str] = None, **kwargs @@ -1535,7 +1534,7 @@ def __init__( :keyword thumbprint: This must match the thumbprint from the name. :paramtype thumbprint: str :keyword format: The format of the certificate - either Pfx or Cer. If omitted, the default is - Pfx. Possible values include: "Pfx", "Cer". + Pfx. Known values are: "Pfx", "Cer". :paramtype format: str or ~azure.mgmt.batch.models.CertificateFormat :keyword data: The maximum size is 10KB. :paramtype data: str @@ -1561,7 +1560,7 @@ class CertificateCreateOrUpdateProperties(CertificateBaseProperties): :ivar thumbprint: This must match the thumbprint from the name. :vartype thumbprint: str :ivar format: The format of the certificate - either Pfx or Cer. If omitted, the default is - Pfx. Possible values include: "Pfx", "Cer". + Pfx. Known values are: "Pfx", "Cer". :vartype format: str or ~azure.mgmt.batch.models.CertificateFormat :ivar data: Required. The maximum size is 10KB. :vartype data: str @@ -1587,7 +1586,7 @@ def __init__( data: str, thumbprint_algorithm: Optional[str] = None, thumbprint: Optional[str] = None, - format: Optional[Union[str, "CertificateFormat"]] = None, + format: Optional[Union[str, "_models.CertificateFormat"]] = None, password: Optional[str] = None, **kwargs ): @@ -1598,7 +1597,7 @@ def __init__( :keyword thumbprint: This must match the thumbprint from the name. :paramtype thumbprint: str :keyword format: The format of the certificate - either Pfx or Cer. If omitted, the default is - Pfx. Possible values include: "Pfx", "Cer". + Pfx. Known values are: "Pfx", "Cer". :paramtype format: str or ~azure.mgmt.batch.models.CertificateFormat :keyword data: Required. The maximum size is 10KB. :paramtype data: str @@ -1621,15 +1620,15 @@ class CertificateProperties(CertificateBaseProperties): :ivar thumbprint: This must match the thumbprint from the name. :vartype thumbprint: str :ivar format: The format of the certificate - either Pfx or Cer. If omitted, the default is - Pfx. Possible values include: "Pfx", "Cer". + Pfx. Known values are: "Pfx", "Cer". :vartype format: str or ~azure.mgmt.batch.models.CertificateFormat - :ivar provisioning_state: Possible values include: "Succeeded", "Deleting", "Failed". + :ivar provisioning_state: Known values are: "Succeeded", "Deleting", "Failed". :vartype provisioning_state: str or ~azure.mgmt.batch.models.CertificateProvisioningState :ivar provisioning_state_transition_time: The time at which the certificate entered its current state. :vartype provisioning_state_transition_time: ~datetime.datetime - :ivar previous_provisioning_state: The previous provisioned state of the resource. Possible - values include: "Succeeded", "Deleting", "Failed". + :ivar previous_provisioning_state: The previous provisioned state of the resource. Known values + are: "Succeeded", "Deleting", "Failed". :vartype previous_provisioning_state: str or ~azure.mgmt.batch.models.CertificateProvisioningState :ivar previous_provisioning_state_transition_time: The time at which the certificate entered @@ -1668,7 +1667,7 @@ def __init__( *, thumbprint_algorithm: Optional[str] = None, thumbprint: Optional[str] = None, - format: Optional[Union[str, "CertificateFormat"]] = None, + format: Optional[Union[str, "_models.CertificateFormat"]] = None, **kwargs ): """ @@ -1678,7 +1677,7 @@ def __init__( :keyword thumbprint: This must match the thumbprint from the name. :paramtype thumbprint: str :keyword format: The format of the certificate - either Pfx or Cer. If omitted, the default is - Pfx. Possible values include: "Pfx", "Cer". + Pfx. Known values are: "Pfx", "Cer". :paramtype format: str or ~azure.mgmt.batch.models.CertificateFormat """ super(CertificateProperties, self).__init__(thumbprint_algorithm=thumbprint_algorithm, thumbprint=thumbprint, format=format, **kwargs) @@ -1704,8 +1703,8 @@ class CertificateReference(msrest.serialization.Model): certificates are stored in a directory inside the task working directory and an environment variable AZ_BATCH_CERTIFICATES_DIR is supplied to the task to query for this location. For certificates with visibility of 'remoteUser', a 'certs' directory is created in the user's home - directory (e.g., /home/{user-name}/certs) and certificates are placed in that directory. - Possible values include: "CurrentUser", "LocalMachine". + directory (e.g., /home/{user-name}/certs) and certificates are placed in that directory. Known + values are: "CurrentUser", "LocalMachine". :vartype store_location: str or ~azure.mgmt.batch.models.CertificateStoreLocation :ivar store_name: This property is applicable only for pools configured with Windows nodes (that is, created with cloudServiceConfiguration, or with virtualMachineConfiguration using a @@ -1733,9 +1732,9 @@ def __init__( self, *, id: str, - store_location: Optional[Union[str, "CertificateStoreLocation"]] = None, + store_location: Optional[Union[str, "_models.CertificateStoreLocation"]] = None, store_name: Optional[str] = None, - visibility: Optional[List[Union[str, "CertificateVisibility"]]] = None, + visibility: Optional[List[Union[str, "_models.CertificateVisibility"]]] = None, **kwargs ): """ @@ -1748,8 +1747,8 @@ def __init__( certificates are stored in a directory inside the task working directory and an environment variable AZ_BATCH_CERTIFICATES_DIR is supplied to the task to query for this location. For certificates with visibility of 'remoteUser', a 'certs' directory is created in the user's home - directory (e.g., /home/{user-name}/certs) and certificates are placed in that directory. - Possible values include: "CurrentUser", "LocalMachine". + directory (e.g., /home/{user-name}/certs) and certificates are placed in that directory. Known + values are: "CurrentUser", "LocalMachine". :paramtype store_location: str or ~azure.mgmt.batch.models.CertificateStoreLocation :keyword store_name: This property is applicable only for pools configured with Windows nodes (that is, created with cloudServiceConfiguration, or with virtualMachineConfiguration using a @@ -1817,8 +1816,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a Batch account name could not be used. The Reason element - is only returned if NameAvailable is false. Possible values include: "Invalid", - "AlreadyExists". + is only returned if NameAvailable is false. Known values are: "Invalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.batch.models.NameAvailabilityReason :ivar message: Gets an error message explaining the Reason value in more detail. :vartype message: str @@ -1942,7 +1940,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -2073,7 +2071,7 @@ def __init__( self, *, container_image_names: Optional[List[str]] = None, - container_registries: Optional[List["ContainerRegistry"]] = None, + container_registries: Optional[List["_models.ContainerRegistry"]] = None, **kwargs ): """ @@ -2117,7 +2115,7 @@ def __init__( user_name: Optional[str] = None, password: Optional[str] = None, registry_server: Optional[str] = None, - identity_reference: Optional["ComputeNodeIdentityReference"] = None, + identity_reference: Optional["_models.ComputeNodeIdentityReference"] = None, **kwargs ): """ @@ -2154,15 +2152,15 @@ class DataDisk(msrest.serialization.Model): The default value for caching is none. For information about the caching options see: https://blogs.msdn.microsoft.com/windowsazurestorage/2012/06/27/exploring-windows-azure-drives-disks-and-images/. - Possible values include: "None", "ReadOnly", "ReadWrite". + Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.batch.models.CachingType :ivar disk_size_gb: Required. The initial disk size in GB when creating new data disk. :vartype disk_size_gb: int :ivar storage_account_type: If omitted, the default is "Standard_LRS". Values are: Standard_LRS - The data disk should use standard locally redundant storage. - Premium_LRS - The data disk should use premium locally redundant storage. Possible values - include: "Standard_LRS", "Premium_LRS". + Premium_LRS - The data disk should use premium locally redundant storage. Known values are: + "Standard_LRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.batch.models.StorageAccountType """ @@ -2183,8 +2181,8 @@ def __init__( *, lun: int, disk_size_gb: int, - caching: Optional[Union[str, "CachingType"]] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, + caching: Optional[Union[str, "_models.CachingType"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, **kwargs ): """ @@ -2199,15 +2197,15 @@ def __init__( The default value for caching is none. For information about the caching options see: https://blogs.msdn.microsoft.com/windowsazurestorage/2012/06/27/exploring-windows-azure-drives-disks-and-images/. - Possible values include: "None", "ReadOnly", "ReadWrite". + Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.batch.models.CachingType :keyword disk_size_gb: Required. The initial disk size in GB when creating new data disk. :paramtype disk_size_gb: int :keyword storage_account_type: If omitted, the default is "Standard_LRS". Values are: Standard_LRS - The data disk should use standard locally redundant storage. - Premium_LRS - The data disk should use premium locally redundant storage. Possible values - include: "Standard_LRS", "Premium_LRS". + Premium_LRS - The data disk should use premium locally redundant storage. Known values are: + "Standard_LRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.batch.models.StorageAccountType """ super(DataDisk, self).__init__(**kwargs) @@ -2253,7 +2251,7 @@ def __init__( code: str, message: str, target: Optional[str] = None, - details: Optional[List["DeleteCertificateError"]] = None, + details: Optional[List["_models.DeleteCertificateError"]] = None, **kwargs ): """ @@ -2296,8 +2294,8 @@ class DeploymentConfiguration(msrest.serialization.Model): def __init__( self, *, - cloud_service_configuration: Optional["CloudServiceConfiguration"] = None, - virtual_machine_configuration: Optional["VirtualMachineConfiguration"] = None, + cloud_service_configuration: Optional["_models.CloudServiceConfiguration"] = None, + virtual_machine_configuration: Optional["_models.VirtualMachineConfiguration"] = None, **kwargs ): """ @@ -2332,7 +2330,7 @@ class DetectorListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["DetectorResponse"]] = None, + value: Optional[List["_models.DetectorResponse"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -2447,7 +2445,7 @@ class DiskEncryptionConfiguration(msrest.serialization.Model): def __init__( self, *, - targets: Optional[List[Union[str, "DiskEncryptionTarget"]]] = None, + targets: Optional[List[Union[str, "_models.DiskEncryptionTarget"]]] = None, **kwargs ): """ @@ -2462,7 +2460,7 @@ def __init__( class EncryptionProperties(msrest.serialization.Model): """Configures how customer data is encrypted inside the Batch account. By default, accounts are encrypted using a Microsoft managed key. For additional control, a customer-managed key can be used instead. - :ivar key_source: Type of the key source. Possible values include: "Microsoft.Batch", + :ivar key_source: Type of the key source. Known values are: "Microsoft.Batch", "Microsoft.KeyVault". :vartype key_source: str or ~azure.mgmt.batch.models.KeySource :ivar key_vault_properties: Additional details when using Microsoft.KeyVault. @@ -2477,12 +2475,12 @@ class EncryptionProperties(msrest.serialization.Model): def __init__( self, *, - key_source: Optional[Union[str, "KeySource"]] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, + key_source: Optional[Union[str, "_models.KeySource"]] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, **kwargs ): """ - :keyword key_source: Type of the key source. Possible values include: "Microsoft.Batch", + :keyword key_source: Type of the key source. Known values are: "Microsoft.Batch", "Microsoft.KeyVault". :paramtype key_source: str or ~azure.mgmt.batch.models.KeySource :keyword key_vault_properties: Additional details when using Microsoft.KeyVault. @@ -2499,7 +2497,7 @@ class EndpointAccessProfile(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar default_action: Required. Default action for endpoint access. It is only applicable when - publicNetworkAccess is enabled. Possible values include: "Allow", "Deny". + publicNetworkAccess is enabled. Known values are: "Allow", "Deny". :vartype default_action: str or ~azure.mgmt.batch.models.EndpointAccessDefaultAction :ivar ip_rules: Array of IP ranges to filter client IP address. :vartype ip_rules: list[~azure.mgmt.batch.models.IPRule] @@ -2517,13 +2515,13 @@ class EndpointAccessProfile(msrest.serialization.Model): def __init__( self, *, - default_action: Union[str, "EndpointAccessDefaultAction"], - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.EndpointAccessDefaultAction"], + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ :keyword default_action: Required. Default action for endpoint access. It is only applicable - when publicNetworkAccess is enabled. Possible values include: "Allow", "Deny". + when publicNetworkAccess is enabled. Known values are: "Allow", "Deny". :paramtype default_action: str or ~azure.mgmt.batch.models.EndpointAccessDefaultAction :keyword ip_rules: Array of IP ranges to filter client IP address. :paramtype ip_rules: list[~azure.mgmt.batch.models.IPRule] @@ -2651,8 +2649,8 @@ class FixedScaleSettings(msrest.serialization.Model): :ivar target_low_priority_nodes: At least one of targetDedicatedNodes, targetLowPriorityNodes must be set. :vartype target_low_priority_nodes: int - :ivar node_deallocation_option: If omitted, the default value is Requeue. Possible values - include: "Requeue", "Terminate", "TaskCompletion", "RetainedData". + :ivar node_deallocation_option: If omitted, the default value is Requeue. Known values are: + "Requeue", "Terminate", "TaskCompletion", "RetainedData". :vartype node_deallocation_option: str or ~azure.mgmt.batch.models.ComputeNodeDeallocationOption """ @@ -2670,7 +2668,7 @@ def __init__( resize_timeout: Optional[datetime.timedelta] = None, target_dedicated_nodes: Optional[int] = None, target_low_priority_nodes: Optional[int] = None, - node_deallocation_option: Optional[Union[str, "ComputeNodeDeallocationOption"]] = None, + node_deallocation_option: Optional[Union[str, "_models.ComputeNodeDeallocationOption"]] = None, **kwargs ): """ @@ -2685,8 +2683,8 @@ def __init__( :keyword target_low_priority_nodes: At least one of targetDedicatedNodes, targetLowPriorityNodes must be set. :paramtype target_low_priority_nodes: int - :keyword node_deallocation_option: If omitted, the default value is Requeue. Possible values - include: "Requeue", "Terminate", "TaskCompletion", "RetainedData". + :keyword node_deallocation_option: If omitted, the default value is Requeue. Known values are: + "Requeue", "Terminate", "TaskCompletion", "RetainedData". :paramtype node_deallocation_option: str or ~azure.mgmt.batch.models.ComputeNodeDeallocationOption """ @@ -2768,7 +2766,7 @@ class InboundNatPool(msrest.serialization.Model): with a letter, number, or underscore, and cannot exceed 77 characters. If any invalid values are provided the request fails with HTTP status code 400. :vartype name: str - :ivar protocol: Required. The protocol of the endpoint. Possible values include: "TCP", "UDP". + :ivar protocol: Required. The protocol of the endpoint. Known values are: "TCP", "UDP". :vartype protocol: str or ~azure.mgmt.batch.models.InboundEndpointProtocol :ivar backend_port: Required. This must be unique within a Batch pool. Acceptable values are between 1 and 65535 except for 22, 3389, 29876 and 29877 as these are reserved. If any reserved @@ -2813,11 +2811,11 @@ def __init__( self, *, name: str, - protocol: Union[str, "InboundEndpointProtocol"], + protocol: Union[str, "_models.InboundEndpointProtocol"], backend_port: int, frontend_port_range_start: int, frontend_port_range_end: int, - network_security_group_rules: Optional[List["NetworkSecurityGroupRule"]] = None, + network_security_group_rules: Optional[List["_models.NetworkSecurityGroupRule"]] = None, **kwargs ): """ @@ -2826,8 +2824,7 @@ def __init__( with a letter, number, or underscore, and cannot exceed 77 characters. If any invalid values are provided the request fails with HTTP status code 400. :paramtype name: str - :keyword protocol: Required. The protocol of the endpoint. Possible values include: "TCP", - "UDP". + :keyword protocol: Required. The protocol of the endpoint. Known values are: "TCP", "UDP". :paramtype protocol: str or ~azure.mgmt.batch.models.InboundEndpointProtocol :keyword backend_port: Required. This must be unique within a Batch pool. Acceptable values are between 1 and 65535 except for 22, 3389, 29876 and 29877 as these are reserved. If any reserved @@ -3046,7 +3043,7 @@ class ListApplicationPackagesResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ApplicationPackage"]] = None, + value: Optional[List["_models.ApplicationPackage"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -3078,7 +3075,7 @@ class ListApplicationsResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Application"]] = None, + value: Optional[List["_models.Application"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -3110,7 +3107,7 @@ class ListCertificatesResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Certificate"]] = None, + value: Optional[List["_models.Certificate"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -3142,7 +3139,7 @@ class ListPoolsResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Pool"]] = None, + value: Optional[List["_models.Pool"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -3174,7 +3171,7 @@ class ListPrivateEndpointConnectionsResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -3206,7 +3203,7 @@ class ListPrivateLinkResourcesResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateLinkResource"]] = None, + value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -3286,10 +3283,10 @@ class MountConfiguration(msrest.serialization.Model): def __init__( self, *, - azure_blob_file_system_configuration: Optional["AzureBlobFileSystemConfiguration"] = None, - nfs_mount_configuration: Optional["NFSMountConfiguration"] = None, - cifs_mount_configuration: Optional["CIFSMountConfiguration"] = None, - azure_file_share_configuration: Optional["AzureFileShareConfiguration"] = None, + azure_blob_file_system_configuration: Optional["_models.AzureBlobFileSystemConfiguration"] = None, + nfs_mount_configuration: Optional["_models.NFSMountConfiguration"] = None, + cifs_mount_configuration: Optional["_models.CIFSMountConfiguration"] = None, + azure_file_share_configuration: Optional["_models.AzureFileShareConfiguration"] = None, **kwargs ): """ @@ -3335,8 +3332,8 @@ class NetworkConfiguration(msrest.serialization.Model): VNETs are supported. For more details see: https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration. :vartype subnet_id: str - :ivar dynamic_v_net_assignment_scope: The scope of dynamic vnet assignment. Possible values - include: "none", "job". + :ivar dynamic_v_net_assignment_scope: The scope of dynamic vnet assignment. Known values are: + "none", "job". :vartype dynamic_v_net_assignment_scope: str or ~azure.mgmt.batch.models.DynamicVNetAssignmentScope :ivar endpoint_configuration: Pool endpoint configuration is only supported on pools with the @@ -3358,9 +3355,9 @@ def __init__( self, *, subnet_id: Optional[str] = None, - dynamic_v_net_assignment_scope: Optional[Union[str, "DynamicVNetAssignmentScope"]] = None, - endpoint_configuration: Optional["PoolEndpointConfiguration"] = None, - public_ip_address_configuration: Optional["PublicIPAddressConfiguration"] = None, + dynamic_v_net_assignment_scope: Optional[Union[str, "_models.DynamicVNetAssignmentScope"]] = None, + endpoint_configuration: Optional["_models.PoolEndpointConfiguration"] = None, + public_ip_address_configuration: Optional["_models.PublicIPAddressConfiguration"] = None, **kwargs ): """ @@ -3382,8 +3379,8 @@ def __init__( VNETs are supported. For more details see: https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration. :paramtype subnet_id: str - :keyword dynamic_v_net_assignment_scope: The scope of dynamic vnet assignment. Possible values - include: "none", "job". + :keyword dynamic_v_net_assignment_scope: The scope of dynamic vnet assignment. Known values + are: "none", "job". :paramtype dynamic_v_net_assignment_scope: str or ~azure.mgmt.batch.models.DynamicVNetAssignmentScope :keyword endpoint_configuration: Pool endpoint configuration is only supported on pools with @@ -3420,8 +3417,8 @@ class NetworkProfile(msrest.serialization.Model): def __init__( self, *, - account_access: Optional["EndpointAccessProfile"] = None, - node_management_access: Optional["EndpointAccessProfile"] = None, + account_access: Optional["_models.EndpointAccessProfile"] = None, + node_management_access: Optional["_models.EndpointAccessProfile"] = None, **kwargs ): """ @@ -3449,7 +3446,7 @@ class NetworkSecurityGroupRule(msrest.serialization.Model): duplicate values are provided the request fails with HTTP status code 400. :vartype priority: int :ivar access: Required. The action that should be taken for a specified IP address, subnet - range or tag. Possible values include: "Allow", "Deny". + range or tag. Known values are: "Allow", "Deny". :vartype access: str or ~azure.mgmt.batch.models.NetworkSecurityGroupRuleAccess :ivar source_address_prefix: Required. Valid values are a single IP address (i.e. 10.10.10.10), IP subnet (i.e. 192.168.1.0/24), default tag, or * (for all addresses). If any other values @@ -3479,7 +3476,7 @@ def __init__( self, *, priority: int, - access: Union[str, "NetworkSecurityGroupRuleAccess"], + access: Union[str, "_models.NetworkSecurityGroupRuleAccess"], source_address_prefix: str, source_port_ranges: Optional[List[str]] = None, **kwargs @@ -3492,7 +3489,7 @@ def __init__( reserved or duplicate values are provided the request fails with HTTP status code 400. :paramtype priority: int :keyword access: Required. The action that should be taken for a specified IP address, subnet - range or tag. Possible values include: "Allow", "Deny". + range or tag. Known values are: "Allow", "Deny". :paramtype access: str or ~azure.mgmt.batch.models.NetworkSecurityGroupRuleAccess :keyword source_address_prefix: Required. Valid values are a single IP address (i.e. 10.10.10.10), IP subnet (i.e. 192.168.1.0/24), default tag, or * (for all addresses). If any @@ -3563,7 +3560,7 @@ class NodePlacementConfiguration(msrest.serialization.Model): """Allocation configuration used by Batch Service to provision the nodes. :ivar policy: Allocation policy used by Batch Service to provision the nodes. If not specified, - Batch will use the regional policy. Possible values include: "Regional", "Zonal". + Batch will use the regional policy. Known values are: "Regional", "Zonal". :vartype policy: str or ~azure.mgmt.batch.models.NodePlacementPolicyType """ @@ -3574,12 +3571,12 @@ class NodePlacementConfiguration(msrest.serialization.Model): def __init__( self, *, - policy: Optional[Union[str, "NodePlacementPolicyType"]] = None, + policy: Optional[Union[str, "_models.NodePlacementPolicyType"]] = None, **kwargs ): """ :keyword policy: Allocation policy used by Batch Service to provision the nodes. If not - specified, Batch will use the regional policy. Possible values include: "Regional", "Zonal". + specified, Batch will use the regional policy. Known values are: "Regional", "Zonal". :paramtype policy: str or ~azure.mgmt.batch.models.NodePlacementPolicyType """ super(NodePlacementConfiguration, self).__init__(**kwargs) @@ -3614,7 +3611,7 @@ def __init__( *, name: Optional[str] = None, is_data_action: Optional[bool] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, properties: Optional[Any] = None, **kwargs @@ -3702,7 +3699,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -3732,7 +3729,7 @@ class OSDisk(msrest.serialization.Model): def __init__( self, *, - ephemeral_os_disk_settings: Optional["DiffDiskSettings"] = None, + ephemeral_os_disk_settings: Optional["_models.DiffDiskSettings"] = None, **kwargs ): """ @@ -3837,13 +3834,13 @@ class Pool(ProxyResource): :vartype last_modified: ~datetime.datetime :ivar creation_time: The creation time of the pool. :vartype creation_time: ~datetime.datetime - :ivar provisioning_state: The current state of the pool. Possible values include: "Succeeded", + :ivar provisioning_state: The current state of the pool. Known values are: "Succeeded", "Deleting". :vartype provisioning_state: str or ~azure.mgmt.batch.models.PoolProvisioningState :ivar provisioning_state_transition_time: The time at which the pool entered its current state. :vartype provisioning_state_transition_time: ~datetime.datetime - :ivar allocation_state: Whether the pool is resizing. Possible values include: "Steady", - "Resizing", "Stopping". + :ivar allocation_state: Whether the pool is resizing. Known values are: "Steady", "Resizing", + "Stopping". :vartype allocation_state: str or ~azure.mgmt.batch.models.AllocationState :ivar allocation_state_transition_time: The time at which the pool entered its current allocation state. @@ -3866,8 +3863,8 @@ class Pool(ProxyResource): :vartype deployment_configuration: ~azure.mgmt.batch.models.DeploymentConfiguration :ivar current_dedicated_nodes: The number of compute nodes currently in the pool. :vartype current_dedicated_nodes: int - :ivar current_low_priority_nodes: The number of low-priority compute nodes currently in the - pool. + :ivar current_low_priority_nodes: The number of Spot/low-priority compute nodes currently in + the pool. :vartype current_low_priority_nodes: int :ivar scale_settings: Defines the desired size of the pool. This can either be 'fixedScale' where the requested targetDedicatedNodes is specified, or 'autoScale' which defines a formula @@ -3879,8 +3876,8 @@ class Pool(ProxyResource): :vartype auto_scale_run: ~azure.mgmt.batch.models.AutoScaleRun :ivar inter_node_communication: This imposes restrictions on which nodes can be assigned to the pool. Enabling this value can reduce the chance of the requested number of nodes to be - allocated in the pool. If not specified, this value defaults to 'Disabled'. Possible values - include: "Enabled", "Disabled". + allocated in the pool. If not specified, this value defaults to 'Disabled'. Known values are: + "Enabled", "Disabled". :vartype inter_node_communication: str or ~azure.mgmt.batch.models.InterNodeCommunicationState :ivar network_configuration: The network configuration for a pool. :vartype network_configuration: ~azure.mgmt.batch.models.NetworkConfiguration @@ -3974,22 +3971,22 @@ class Pool(ProxyResource): def __init__( self, *, - identity: Optional["BatchPoolIdentity"] = None, + identity: Optional["_models.BatchPoolIdentity"] = None, display_name: Optional[str] = None, vm_size: Optional[str] = None, - deployment_configuration: Optional["DeploymentConfiguration"] = None, - scale_settings: Optional["ScaleSettings"] = None, - inter_node_communication: Optional[Union[str, "InterNodeCommunicationState"]] = None, - network_configuration: Optional["NetworkConfiguration"] = None, + deployment_configuration: Optional["_models.DeploymentConfiguration"] = None, + scale_settings: Optional["_models.ScaleSettings"] = None, + inter_node_communication: Optional[Union[str, "_models.InterNodeCommunicationState"]] = None, + network_configuration: Optional["_models.NetworkConfiguration"] = None, task_slots_per_node: Optional[int] = None, - task_scheduling_policy: Optional["TaskSchedulingPolicy"] = None, - user_accounts: Optional[List["UserAccount"]] = None, - metadata: Optional[List["MetadataItem"]] = None, - start_task: Optional["StartTask"] = None, - certificates: Optional[List["CertificateReference"]] = None, - application_packages: Optional[List["ApplicationPackageReference"]] = None, + task_scheduling_policy: Optional["_models.TaskSchedulingPolicy"] = None, + user_accounts: Optional[List["_models.UserAccount"]] = None, + metadata: Optional[List["_models.MetadataItem"]] = None, + start_task: Optional["_models.StartTask"] = None, + certificates: Optional[List["_models.CertificateReference"]] = None, + application_packages: Optional[List["_models.ApplicationPackageReference"]] = None, application_licenses: Optional[List[str]] = None, - mount_configuration: Optional[List["MountConfiguration"]] = None, + mount_configuration: Optional[List["_models.MountConfiguration"]] = None, **kwargs ): """ @@ -4021,8 +4018,8 @@ def __init__( :paramtype scale_settings: ~azure.mgmt.batch.models.ScaleSettings :keyword inter_node_communication: This imposes restrictions on which nodes can be assigned to the pool. Enabling this value can reduce the chance of the requested number of nodes to be - allocated in the pool. If not specified, this value defaults to 'Disabled'. Possible values - include: "Enabled", "Disabled". + allocated in the pool. If not specified, this value defaults to 'Disabled'. Known values are: + "Enabled", "Disabled". :paramtype inter_node_communication: str or ~azure.mgmt.batch.models.InterNodeCommunicationState :keyword network_configuration: The network configuration for a pool. @@ -4110,7 +4107,7 @@ class PoolEndpointConfiguration(msrest.serialization.Model): def __init__( self, *, - inbound_nat_pools: List["InboundNatPool"], + inbound_nat_pools: List["_models.InboundNatPool"], **kwargs ): """ @@ -4164,8 +4161,8 @@ class PrivateEndpointConnection(ProxyResource): :vartype type: str :ivar etag: The ETag of the resource, used for concurrency statements. :vartype etag: str - :ivar provisioning_state: The provisioning state of the private endpoint connection. Possible - values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Cancelled". + :ivar provisioning_state: The provisioning state of the private endpoint connection. Known + values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Cancelled". :vartype provisioning_state: str or ~azure.mgmt.batch.models.PrivateEndpointConnectionProvisioningState :ivar private_endpoint: The private endpoint of the private endpoint connection. @@ -4202,7 +4199,7 @@ class PrivateEndpointConnection(ProxyResource): def __init__( self, *, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -4279,8 +4276,8 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar status: Required. The status of the Batch private endpoint connection. Possible values - include: "Approved", "Pending", "Rejected", "Disconnected". + :ivar status: Required. The status of the Batch private endpoint connection. Known values are: + "Approved", "Pending", "Rejected", "Disconnected". :vartype status: str or ~azure.mgmt.batch.models.PrivateLinkServiceConnectionStatus :ivar description: Description of the private Connection state. :vartype description: str @@ -4302,13 +4299,13 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): def __init__( self, *, - status: Union[str, "PrivateLinkServiceConnectionStatus"], + status: Union[str, "_models.PrivateLinkServiceConnectionStatus"], description: Optional[str] = None, **kwargs ): """ - :keyword status: Required. The status of the Batch private endpoint connection. Possible values - include: "Approved", "Pending", "Rejected", "Disconnected". + :keyword status: Required. The status of the Batch private endpoint connection. Known values + are: "Approved", "Pending", "Rejected", "Disconnected". :paramtype status: str or ~azure.mgmt.batch.models.PrivateLinkServiceConnectionStatus :keyword description: Description of the private Connection state. :paramtype description: str @@ -4322,13 +4319,13 @@ def __init__( class PublicIPAddressConfiguration(msrest.serialization.Model): """The public IP Address configuration of the networking configuration of a Pool. - :ivar provision: The default value is BatchManaged. Possible values include: "BatchManaged", + :ivar provision: The default value is BatchManaged. Known values are: "BatchManaged", "UserManaged", "NoPublicIPAddresses". :vartype provision: str or ~azure.mgmt.batch.models.IPAddressProvisioningType :ivar ip_address_ids: The number of IPs specified here limits the maximum size of the Pool - - 100 dedicated nodes or 100 low-priority nodes can be allocated for each public IP. For example, - a pool needing 250 dedicated VMs would need at least 3 public IPs specified. Each element of - this collection is of the form: + 100 dedicated nodes or 100 Spot/low-priority nodes can be allocated for each public IP. For + example, a pool needing 250 dedicated VMs would need at least 3 public IPs specified. Each + element of this collection is of the form: /subscriptions/{subscription}/resourceGroups/{group}/providers/Microsoft.Network/publicIPAddresses/{ip}. :vartype ip_address_ids: list[str] """ @@ -4341,18 +4338,18 @@ class PublicIPAddressConfiguration(msrest.serialization.Model): def __init__( self, *, - provision: Optional[Union[str, "IPAddressProvisioningType"]] = None, + provision: Optional[Union[str, "_models.IPAddressProvisioningType"]] = None, ip_address_ids: Optional[List[str]] = None, **kwargs ): """ - :keyword provision: The default value is BatchManaged. Possible values include: "BatchManaged", + :keyword provision: The default value is BatchManaged. Known values are: "BatchManaged", "UserManaged", "NoPublicIPAddresses". :paramtype provision: str or ~azure.mgmt.batch.models.IPAddressProvisioningType :keyword ip_address_ids: The number of IPs specified here limits the maximum size of the Pool - - 100 dedicated nodes or 100 low-priority nodes can be allocated for each public IP. For example, - a pool needing 250 dedicated VMs would need at least 3 public IPs specified. Each element of - this collection is of the form: + 100 dedicated nodes or 100 Spot/low-priority nodes can be allocated for each public IP. For + example, a pool needing 250 dedicated VMs would need at least 3 public IPs specified. Each + element of this collection is of the form: /subscriptions/{subscription}/resourceGroups/{group}/providers/Microsoft.Network/publicIPAddresses/{ip}. :paramtype ip_address_ids: list[str] """ @@ -4392,7 +4389,7 @@ def __init__( *, code: str, message: str, - details: Optional[List["ResizeError"]] = None, + details: Optional[List["_models.ResizeError"]] = None, **kwargs ): """ @@ -4416,14 +4413,15 @@ class ResizeOperationStatus(msrest.serialization.Model): :ivar target_dedicated_nodes: The desired number of dedicated compute nodes in the pool. :vartype target_dedicated_nodes: int - :ivar target_low_priority_nodes: The desired number of low-priority compute nodes in the pool. + :ivar target_low_priority_nodes: The desired number of Spot/low-priority compute nodes in the + pool. :vartype target_low_priority_nodes: int :ivar resize_timeout: The default value is 15 minutes. The minimum value is 5 minutes. If you specify a value less than 5 minutes, the Batch service returns an error; if you are calling the REST API directly, the HTTP status code is 400 (Bad Request). :vartype resize_timeout: ~datetime.timedelta - :ivar node_deallocation_option: The default value is requeue. Possible values include: - "Requeue", "Terminate", "TaskCompletion", "RetainedData". + :ivar node_deallocation_option: The default value is requeue. Known values are: "Requeue", + "Terminate", "TaskCompletion", "RetainedData". :vartype node_deallocation_option: str or ~azure.mgmt.batch.models.ComputeNodeDeallocationOption :ivar start_time: The time when this resize operation was started. @@ -4448,23 +4446,23 @@ def __init__( target_dedicated_nodes: Optional[int] = None, target_low_priority_nodes: Optional[int] = None, resize_timeout: Optional[datetime.timedelta] = None, - node_deallocation_option: Optional[Union[str, "ComputeNodeDeallocationOption"]] = None, + node_deallocation_option: Optional[Union[str, "_models.ComputeNodeDeallocationOption"]] = None, start_time: Optional[datetime.datetime] = None, - errors: Optional[List["ResizeError"]] = None, + errors: Optional[List["_models.ResizeError"]] = None, **kwargs ): """ :keyword target_dedicated_nodes: The desired number of dedicated compute nodes in the pool. :paramtype target_dedicated_nodes: int - :keyword target_low_priority_nodes: The desired number of low-priority compute nodes in the - pool. + :keyword target_low_priority_nodes: The desired number of Spot/low-priority compute nodes in + the pool. :paramtype target_low_priority_nodes: int :keyword resize_timeout: The default value is 15 minutes. The minimum value is 5 minutes. If you specify a value less than 5 minutes, the Batch service returns an error; if you are calling the REST API directly, the HTTP status code is 400 (Bad Request). :paramtype resize_timeout: ~datetime.timedelta - :keyword node_deallocation_option: The default value is requeue. Possible values include: - "Requeue", "Terminate", "TaskCompletion", "RetainedData". + :keyword node_deallocation_option: The default value is requeue. Known values are: "Requeue", + "Terminate", "TaskCompletion", "RetainedData". :paramtype node_deallocation_option: str or ~azure.mgmt.batch.models.ComputeNodeDeallocationOption :keyword start_time: The time when this resize operation was started. @@ -4543,7 +4541,7 @@ def __init__( blob_prefix: Optional[str] = None, file_path: Optional[str] = None, file_mode: Optional[str] = None, - identity_reference: Optional["ComputeNodeIdentityReference"] = None, + identity_reference: Optional["_models.ComputeNodeIdentityReference"] = None, **kwargs ): """ @@ -4614,8 +4612,8 @@ class ScaleSettings(msrest.serialization.Model): def __init__( self, *, - fixed_scale: Optional["FixedScaleSettings"] = None, - auto_scale: Optional["AutoScaleSettings"] = None, + fixed_scale: Optional["_models.FixedScaleSettings"] = None, + auto_scale: Optional["_models.AutoScaleSettings"] = None, **kwargs ): """ @@ -4716,12 +4714,12 @@ def __init__( self, *, command_line: Optional[str] = None, - resource_files: Optional[List["ResourceFile"]] = None, - environment_settings: Optional[List["EnvironmentSetting"]] = None, - user_identity: Optional["UserIdentity"] = None, + resource_files: Optional[List["_models.ResourceFile"]] = None, + environment_settings: Optional[List["_models.EnvironmentSetting"]] = None, + user_identity: Optional["_models.UserIdentity"] = None, max_task_retry_count: Optional[int] = None, wait_for_success: Optional[bool] = None, - container_settings: Optional["TaskContainerSettings"] = None, + container_settings: Optional["_models.TaskContainerSettings"] = None, **kwargs ): """ @@ -4834,7 +4832,7 @@ class SupportedSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["SupportedSku"], + value: List["_models.SupportedSku"], **kwargs ): """ @@ -4860,7 +4858,7 @@ class TaskContainerSettings(msrest.serialization.Model): :ivar registry: This setting can be omitted if was already provided at pool creation. :vartype registry: ~azure.mgmt.batch.models.ContainerRegistry :ivar working_directory: A flag to indicate where the container task working directory is. The - default is 'taskWorkingDirectory'. Possible values include: "TaskWorkingDirectory", + default is 'taskWorkingDirectory'. Known values are: "TaskWorkingDirectory", "ContainerImageDefault". :vartype working_directory: str or ~azure.mgmt.batch.models.ContainerWorkingDirectory """ @@ -4881,8 +4879,8 @@ def __init__( *, image_name: str, container_run_options: Optional[str] = None, - registry: Optional["ContainerRegistry"] = None, - working_directory: Optional[Union[str, "ContainerWorkingDirectory"]] = None, + registry: Optional["_models.ContainerRegistry"] = None, + working_directory: Optional[Union[str, "_models.ContainerWorkingDirectory"]] = None, **kwargs ): """ @@ -4896,7 +4894,7 @@ def __init__( :keyword registry: This setting can be omitted if was already provided at pool creation. :paramtype registry: ~azure.mgmt.batch.models.ContainerRegistry :keyword working_directory: A flag to indicate where the container task working directory is. - The default is 'taskWorkingDirectory'. Possible values include: "TaskWorkingDirectory", + The default is 'taskWorkingDirectory'. Known values are: "TaskWorkingDirectory", "ContainerImageDefault". :paramtype working_directory: str or ~azure.mgmt.batch.models.ContainerWorkingDirectory """ @@ -4912,8 +4910,8 @@ class TaskSchedulingPolicy(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar node_fill_type: Required. How tasks should be distributed across compute nodes. Possible - values include: "Spread", "Pack". + :ivar node_fill_type: Required. How tasks should be distributed across compute nodes. Known + values are: "Spread", "Pack". :vartype node_fill_type: str or ~azure.mgmt.batch.models.ComputeNodeFillType """ @@ -4928,12 +4926,12 @@ class TaskSchedulingPolicy(msrest.serialization.Model): def __init__( self, *, - node_fill_type: Union[str, "ComputeNodeFillType"], + node_fill_type: Union[str, "_models.ComputeNodeFillType"], **kwargs ): """ - :keyword node_fill_type: Required. How tasks should be distributed across compute nodes. - Possible values include: "Spread", "Pack". + :keyword node_fill_type: Required. How tasks should be distributed across compute nodes. Known + values are: "Spread", "Pack". :paramtype node_fill_type: str or ~azure.mgmt.batch.models.ComputeNodeFillType """ super(TaskSchedulingPolicy, self).__init__(**kwargs) @@ -4951,7 +4949,7 @@ class UserAccount(msrest.serialization.Model): :vartype password: str :ivar elevation_level: nonAdmin - The auto user is a standard user without elevated access. admin - The auto user is a user with elevated access and operates with full Administrator - permissions. The default value is nonAdmin. Possible values include: "NonAdmin", "Admin". + permissions. The default value is nonAdmin. Known values are: "NonAdmin", "Admin". :vartype elevation_level: str or ~azure.mgmt.batch.models.ElevationLevel :ivar linux_user_configuration: This property is ignored if specified on a Windows pool. If not specified, the user is created with the default options. @@ -4980,9 +4978,9 @@ def __init__( *, name: str, password: str, - elevation_level: Optional[Union[str, "ElevationLevel"]] = None, - linux_user_configuration: Optional["LinuxUserConfiguration"] = None, - windows_user_configuration: Optional["WindowsUserConfiguration"] = None, + elevation_level: Optional[Union[str, "_models.ElevationLevel"]] = None, + linux_user_configuration: Optional["_models.LinuxUserConfiguration"] = None, + windows_user_configuration: Optional["_models.WindowsUserConfiguration"] = None, **kwargs ): """ @@ -4992,7 +4990,7 @@ def __init__( :paramtype password: str :keyword elevation_level: nonAdmin - The auto user is a standard user without elevated access. admin - The auto user is a user with elevated access and operates with full Administrator - permissions. The default value is nonAdmin. Possible values include: "NonAdmin", "Admin". + permissions. The default value is nonAdmin. Known values are: "NonAdmin", "Admin". :paramtype elevation_level: str or ~azure.mgmt.batch.models.ElevationLevel :keyword linux_user_configuration: This property is ignored if specified on a Windows pool. If not specified, the user is created with the default options. @@ -5062,7 +5060,7 @@ def __init__( self, *, user_name: Optional[str] = None, - auto_user: Optional["AutoUserSpecification"] = None, + auto_user: Optional["_models.AutoUserSpecification"] = None, **kwargs ): """ @@ -5145,16 +5143,16 @@ class VirtualMachineConfiguration(msrest.serialization.Model): def __init__( self, *, - image_reference: "ImageReference", + image_reference: "_models.ImageReference", node_agent_sku_id: str, - windows_configuration: Optional["WindowsConfiguration"] = None, - data_disks: Optional[List["DataDisk"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + data_disks: Optional[List["_models.DataDisk"]] = None, license_type: Optional[str] = None, - container_configuration: Optional["ContainerConfiguration"] = None, - disk_encryption_configuration: Optional["DiskEncryptionConfiguration"] = None, - node_placement_configuration: Optional["NodePlacementConfiguration"] = None, - extensions: Optional[List["VMExtension"]] = None, - os_disk: Optional["OSDisk"] = None, + container_configuration: Optional["_models.ContainerConfiguration"] = None, + disk_encryption_configuration: Optional["_models.DiskEncryptionConfiguration"] = None, + node_placement_configuration: Optional["_models.NodePlacementConfiguration"] = None, + extensions: Optional[List["_models.VMExtension"]] = None, + os_disk: Optional["_models.OSDisk"] = None, **kwargs ): """ @@ -5363,7 +5361,7 @@ class WindowsUserConfiguration(msrest.serialization.Model): :ivar login_mode: Specifies login mode for the user. The default value for VirtualMachineConfiguration pools is interactive mode and for CloudServiceConfiguration pools - is batch mode. Possible values include: "Batch", "Interactive". + is batch mode. Known values are: "Batch", "Interactive". :vartype login_mode: str or ~azure.mgmt.batch.models.LoginMode """ @@ -5374,13 +5372,13 @@ class WindowsUserConfiguration(msrest.serialization.Model): def __init__( self, *, - login_mode: Optional[Union[str, "LoginMode"]] = None, + login_mode: Optional[Union[str, "_models.LoginMode"]] = None, **kwargs ): """ :keyword login_mode: Specifies login mode for the user. The default value for VirtualMachineConfiguration pools is interactive mode and for CloudServiceConfiguration pools - is batch mode. Possible values include: "Batch", "Interactive". + is batch mode. Known values are: "Batch", "Interactive". :paramtype login_mode: str or ~azure.mgmt.batch.models.LoginMode """ super(WindowsUserConfiguration, self).__init__(**kwargs) diff --git a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/models/_patch.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/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/batch/azure-mgmt-batch/azure/mgmt/batch/operations/__init__.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/__init__.py index c4a185c29107..bc56b670cd21 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/__init__.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/__init__.py @@ -16,6 +16,9 @@ from ._private_endpoint_connection_operations import PrivateEndpointConnectionOperations from ._pool_operations import PoolOperations +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__ = [ 'BatchAccountOperations', 'ApplicationPackageOperations', @@ -27,3 +30,5 @@ 'PrivateEndpointConnectionOperations', 'PoolOperations', ] +__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/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_application_operations.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_application_operations.py index cc56b50b13ee..7a86454026a4 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_application_operations.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_application_operations.py @@ -16,12 +16,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 T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,14 +33,17 @@ def build_create_request( application_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Application] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/applications/{applicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_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="PUT", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,9 +81,12 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/applications/{applicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,18 +99,16 @@ def build_delete_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="DELETE", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -118,9 +120,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/applications/{applicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -133,18 +138,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 ) @@ -155,14 +158,17 @@ def build_update_request( application_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Application] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/applications/{applicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ 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 @@ -203,9 +207,12 @@ def build_list_request( maxresults: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/applications") # pylint: disable=line-too-long path_format_arguments = { @@ -217,44 +224,40 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if maxresults is not None: - _query_parameters['maxresults'] = _SERIALIZER.query("maxresults", maxresults, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['maxresults'] = _SERIALIZER.query("maxresults", maxresults, 'int') + _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 ApplicationOperations(object): - """ApplicationOperations 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 ApplicationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.batch.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.batch.BatchManagementClient`'s + :attr:`application` 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 create( @@ -262,9 +265,9 @@ def create( resource_group_name: str, account_name: str, application_name: str, - parameters: Optional["_models.Application"] = None, + parameters: Optional[_models.Application] = None, **kwargs: Any - ) -> "_models.Application": + ) -> _models.Application: """Adds an application to the specified Batch account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -280,14 +283,17 @@ def create( :rtype: ~azure.mgmt.batch.models.Application :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] 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-06-01") # 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-06-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.Application] if parameters is not None: _json = self._serialize.body(parameters, 'Application') @@ -303,11 +309,13 @@ def create( content_type=content_type, json=_json, template_url=self.create.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 @@ -349,13 +357,16 @@ def delete( # 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-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -365,11 +376,13 @@ def delete( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 @@ -393,7 +406,7 @@ def get( account_name: str, application_name: str, **kwargs: Any - ) -> "_models.Application": + ) -> _models.Application: """Gets information about the specified application. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -407,13 +420,16 @@ def get( :rtype: ~azure.mgmt.batch.models.Application :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] 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-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Application] request = build_get_request( @@ -423,11 +439,13 @@ def get( subscription_id=self._config.subscription_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 @@ -454,9 +472,9 @@ def update( resource_group_name: str, account_name: str, application_name: str, - parameters: "_models.Application", + parameters: _models.Application, **kwargs: Any - ) -> "_models.Application": + ) -> _models.Application: """Updates settings for the specified application. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -472,14 +490,17 @@ def update( :rtype: ~azure.mgmt.batch.models.Application :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] 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-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-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.Application] _json = self._serialize.body(parameters, 'Application') @@ -492,11 +513,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 @@ -524,7 +547,7 @@ def list( account_name: str, maxresults: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ListApplicationsResult"]: + ) -> Iterable[_models.ListApplicationsResult]: """Lists all of the applications in the specified account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -540,13 +563,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.ListApplicationsResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListApplicationsResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListApplicationsResult"] 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: @@ -557,9 +583,11 @@ def prepare_request(next_link=None): api_version=api_version, maxresults=maxresults, 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: @@ -570,9 +598,11 @@ def prepare_request(next_link=None): api_version=api_version, maxresults=maxresults, 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/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_application_package_operations.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_application_package_operations.py index ab8fda23ca5b..bd56a38b819d 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_application_package_operations.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_application_package_operations.py @@ -16,12 +16,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 T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -34,14 +34,17 @@ def build_activate_request( version_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ActivateApplicationPackageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/applications/{applicationName}/versions/{versionName}/activate") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_activate_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 @@ -82,14 +83,17 @@ def build_create_request( version_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ApplicationPackage] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/applications/{applicationName}/versions/{versionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -103,20 +107,18 @@ def build_create_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="PUT", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -131,9 +133,12 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/applications/{applicationName}/versions/{versionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -147,18 +152,16 @@ def build_delete_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="DELETE", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -171,9 +174,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/applications/{applicationName}/versions/{versionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -187,18 +193,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 ) @@ -212,9 +216,12 @@ def build_list_request( maxresults: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/applications/{applicationName}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -227,44 +234,40 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if maxresults is not None: - _query_parameters['maxresults'] = _SERIALIZER.query("maxresults", maxresults, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['maxresults'] = _SERIALIZER.query("maxresults", maxresults, 'int') + _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 ApplicationPackageOperations(object): - """ApplicationPackageOperations 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 ApplicationPackageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.batch.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.batch.BatchManagementClient`'s + :attr:`application_package` 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 activate( @@ -273,9 +276,9 @@ def activate( account_name: str, application_name: str, version_name: str, - parameters: "_models.ActivateApplicationPackageParameters", + parameters: _models.ActivateApplicationPackageParameters, **kwargs: Any - ) -> "_models.ApplicationPackage": + ) -> _models.ApplicationPackage: """Activates the specified application package. This should be done after the ``ApplicationPackage`` was created and uploaded. This needs to be done before an ``ApplicationPackage`` can be used on Pools or Tasks. @@ -295,14 +298,17 @@ def activate( :rtype: ~azure.mgmt.batch.models.ApplicationPackage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationPackage"] 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-06-01") # 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-06-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.ApplicationPackage] _json = self._serialize.body(parameters, 'ActivateApplicationPackageParameters') @@ -316,11 +322,13 @@ def activate( content_type=content_type, json=_json, template_url=self.activate.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 @@ -348,9 +356,9 @@ def create( account_name: str, application_name: str, version_name: str, - parameters: Optional["_models.ApplicationPackage"] = None, + parameters: Optional[_models.ApplicationPackage] = None, **kwargs: Any - ) -> "_models.ApplicationPackage": + ) -> _models.ApplicationPackage: """Creates an application package record. The record contains a storageUrl where the package should be uploaded to. Once it is uploaded the ``ApplicationPackage`` needs to be activated using ``ApplicationPackageActive`` before it can be used. If the auto storage account was @@ -371,14 +379,17 @@ def create( :rtype: ~azure.mgmt.batch.models.ApplicationPackage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationPackage"] 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-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-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.ApplicationPackage] if parameters is not None: _json = self._serialize.body(parameters, 'ApplicationPackage') @@ -395,11 +406,13 @@ def create( content_type=content_type, json=_json, template_url=self.create.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 @@ -444,13 +457,16 @@ def delete( # 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-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -461,11 +477,13 @@ def delete( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 @@ -490,7 +508,7 @@ def get( application_name: str, version_name: str, **kwargs: Any - ) -> "_models.ApplicationPackage": + ) -> _models.ApplicationPackage: """Gets information about the specified application package. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -506,13 +524,16 @@ def get( :rtype: ~azure.mgmt.batch.models.ApplicationPackage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationPackage"] 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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplicationPackage] request = build_get_request( @@ -523,11 +544,13 @@ def get( subscription_id=self._config.subscription_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 @@ -556,7 +579,7 @@ def list( application_name: str, maxresults: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ListApplicationPackagesResult"]: + ) -> Iterable[_models.ListApplicationPackagesResult]: """Lists all of the application packages in the specified application. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -574,13 +597,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.ListApplicationPackagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListApplicationPackagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListApplicationPackagesResult"] 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: @@ -592,9 +618,11 @@ def prepare_request(next_link=None): api_version=api_version, maxresults=maxresults, 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: @@ -606,9 +634,11 @@ def prepare_request(next_link=None): api_version=api_version, maxresults=maxresults, 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/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_batch_account_operations.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_batch_account_operations.py index c184cb9ec99f..f2a8140f35d6 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_batch_account_operations.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_batch_account_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 T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -34,14 +34,17 @@ def build_create_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BatchAccountCreateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,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 @@ -78,14 +79,17 @@ def build_update_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BatchAccountUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ 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 @@ -123,9 +125,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,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 ) @@ -159,9 +162,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,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 ) @@ -193,9 +197,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Batch/batchAccounts") path_format_arguments = { @@ -205,18 +212,16 @@ def build_list_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 ) @@ -226,9 +231,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts") # pylint: disable=line-too-long path_format_arguments = { @@ -239,18 +247,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 ) @@ -261,9 +267,12 @@ def build_synchronize_auto_storage_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/syncAutoStorageKeys") # pylint: disable=line-too-long path_format_arguments = { @@ -275,18 +284,16 @@ def build_synchronize_auto_storage_keys_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="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -296,14 +303,17 @@ def build_regenerate_key_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BatchAccountRegenerateKeyParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/regenerateKeys") # pylint: disable=line-too-long path_format_arguments = { @@ -315,20 +325,18 @@ def build_regenerate_key_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 @@ -341,9 +349,12 @@ def build_get_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/listKeys") # pylint: disable=line-too-long path_format_arguments = { @@ -355,18 +366,16 @@ def build_get_keys_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="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -377,9 +386,12 @@ def build_list_detectors_request( account_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/detectors") # pylint: disable=line-too-long path_format_arguments = { @@ -391,18 +403,16 @@ def build_list_detectors_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 ) @@ -414,9 +424,12 @@ def build_get_detector_request( detector_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/detectors/{detectorId}") # pylint: disable=line-too-long path_format_arguments = { @@ -429,18 +442,16 @@ def build_get_detector_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 ) @@ -451,9 +462,12 @@ def build_list_outbound_network_dependencies_endpoints_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/outboundNetworkDependenciesEndpoints") # pylint: disable=line-too-long path_format_arguments = { @@ -465,58 +479,57 @@ def build_list_outbound_network_dependencies_endpoints_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 BatchAccountOperations(object): - """BatchAccountOperations 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 BatchAccountOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.batch.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.batch.BatchManagementClient`'s + :attr:`batch_account` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.BatchAccountCreateParameters", + parameters: _models.BatchAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.BatchAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BatchAccount"]] + ) -> Optional[_models.BatchAccount]: 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-06-01") # 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-06-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[Optional[_models.BatchAccount]] _json = self._serialize.body(parameters, 'BatchAccountCreateParameters') @@ -528,11 +541,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 @@ -566,9 +581,9 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.BatchAccountCreateParameters", + parameters: _models.BatchAccountCreateParameters, **kwargs: Any - ) -> LROPoller["_models.BatchAccount"]: + ) -> LROPoller[_models.BatchAccount]: """Creates a new Batch account with the specified parameters. Existing accounts cannot be updated with this API and should instead be updated with the Update Batch Account API. @@ -595,37 +610,47 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.batch.models.BatchAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.BatchAccount] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BatchAccount"] 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, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('BatchAccount', 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': '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( @@ -643,9 +668,9 @@ def update( self, resource_group_name: str, account_name: str, - parameters: "_models.BatchAccountUpdateParameters", + parameters: _models.BatchAccountUpdateParameters, **kwargs: Any - ) -> "_models.BatchAccount": + ) -> _models.BatchAccount: """Updates the properties of an existing Batch account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -659,14 +684,17 @@ def update( :rtype: ~azure.mgmt.batch.models.BatchAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BatchAccount"] 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-06-01") # 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-06-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.BatchAccount] _json = self._serialize.body(parameters, 'BatchAccountUpdateParameters') @@ -678,11 +706,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 @@ -709,13 +739,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-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -724,11 +757,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_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 @@ -776,20 +811,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-06-01") # 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-06-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) @@ -799,8 +839,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( @@ -819,7 +865,7 @@ def get( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BatchAccount": + ) -> _models.BatchAccount: """Gets information about the specified Batch account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -831,13 +877,16 @@ def get( :rtype: ~azure.mgmt.batch.models.BatchAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BatchAccount"] 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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BatchAccount] request = build_get_request( @@ -846,11 +895,13 @@ def get( subscription_id=self._config.subscription_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 @@ -875,7 +926,7 @@ def get( def list( self, **kwargs: Any - ) -> Iterable["_models.BatchAccountListResult"]: + ) -> Iterable[_models.BatchAccountListResult]: """Gets information about the Batch accounts associated with the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -884,13 +935,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.BatchAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BatchAccountListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BatchAccountListResult"] 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: @@ -898,9 +952,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -908,9 +964,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 @@ -948,7 +1006,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.BatchAccountListResult"]: + ) -> Iterable[_models.BatchAccountListResult]: """Gets information about the Batch accounts associated with the specified resource group. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -959,13 +1017,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.BatchAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BatchAccountListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BatchAccountListResult"] 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: @@ -974,9 +1035,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: @@ -985,9 +1048,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 @@ -1039,13 +1104,16 @@ def synchronize_auto_storage_keys( # pylint: disable=inconsistent-return-statem :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-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_synchronize_auto_storage_keys_request( @@ -1054,11 +1122,13 @@ def synchronize_auto_storage_keys( # pylint: disable=inconsistent-return-statem subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.synchronize_auto_storage_keys.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 @@ -1080,9 +1150,9 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - parameters: "_models.BatchAccountRegenerateKeyParameters", + parameters: _models.BatchAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.BatchAccountKeys": + ) -> _models.BatchAccountKeys: """Regenerates the specified account key for the Batch account. This operation applies only to Batch accounts with allowedAuthenticationModes containing @@ -1101,14 +1171,17 @@ def regenerate_key( :rtype: ~azure.mgmt.batch.models.BatchAccountKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BatchAccountKeys"] 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-06-01") # 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-06-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.BatchAccountKeys] _json = self._serialize.body(parameters, 'BatchAccountRegenerateKeyParameters') @@ -1120,11 +1193,13 @@ def regenerate_key( content_type=content_type, json=_json, template_url=self.regenerate_key.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 @@ -1151,7 +1226,7 @@ def get_keys( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BatchAccountKeys": + ) -> _models.BatchAccountKeys: """Gets the account keys for the specified Batch account. This operation applies only to Batch accounts with allowedAuthenticationModes containing @@ -1168,13 +1243,16 @@ def get_keys( :rtype: ~azure.mgmt.batch.models.BatchAccountKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BatchAccountKeys"] 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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BatchAccountKeys] request = build_get_keys_request( @@ -1183,11 +1261,13 @@ def get_keys( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_keys.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 @@ -1214,7 +1294,7 @@ def list_detectors( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.DetectorListResult"]: + ) -> Iterable[_models.DetectorListResult]: """Gets information about the detectors available for a given Batch account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -1226,13 +1306,16 @@ def list_detectors( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.DetectorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DetectorListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DetectorListResult"] 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: @@ -1242,9 +1325,11 @@ def prepare_request(next_link=None): account_name=account_name, api_version=api_version, template_url=self.list_detectors.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: @@ -1254,9 +1339,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 @@ -1296,7 +1383,7 @@ def get_detector( account_name: str, detector_id: str, **kwargs: Any - ) -> "_models.DetectorResponse": + ) -> _models.DetectorResponse: """Gets information about the given detector for a given Batch account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -1310,13 +1397,16 @@ def get_detector( :rtype: ~azure.mgmt.batch.models.DetectorResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DetectorResponse"] 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-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DetectorResponse] request = build_get_detector_request( @@ -1326,11 +1416,13 @@ def get_detector( detector_id=detector_id, api_version=api_version, template_url=self.get_detector.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 @@ -1357,13 +1449,13 @@ def list_outbound_network_dependencies_endpoints( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.OutboundEnvironmentEndpointCollection"]: + ) -> Iterable[_models.OutboundEnvironmentEndpointCollection]: """Lists the endpoints that a Batch Compute Node under this Batch Account may call as part of Batch service administration. If you are deploying a Pool inside of a virtual network that you specify, you must make sure your network allows outbound access to these endpoints. Failure to allow access to these endpoints may cause Batch to mark the affected nodes as unusable. For more information about creating a pool inside of a virtual network, see - https://docs.microsoft.com/en-us/azure/batch/batch-virtual-network. + https://docs.microsoft.com/azure/batch/batch-virtual-network. :param resource_group_name: The name of the resource group that contains the Batch account. :type resource_group_name: str @@ -1376,13 +1468,16 @@ def list_outbound_network_dependencies_endpoints( ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.OutboundEnvironmentEndpointCollection] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OutboundEnvironmentEndpointCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundEnvironmentEndpointCollection"] 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: @@ -1392,9 +1487,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_outbound_network_dependencies_endpoints.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: @@ -1404,9 +1501,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 diff --git a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_certificate_operations.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_certificate_operations.py index 8791ce8f2bfa..12bb658f2a3d 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_certificate_operations.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_certificate_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 T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -39,9 +39,12 @@ def build_list_by_batch_account_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/certificates") # pylint: disable=line-too-long path_format_arguments = { @@ -53,24 +56,22 @@ def build_list_by_batch_account_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if maxresults is not None: - _query_parameters['maxresults'] = _SERIALIZER.query("maxresults", maxresults, 'int') + _params['maxresults'] = _SERIALIZER.query("maxresults", maxresults, 'int') if select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, '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 ) @@ -81,16 +82,19 @@ def build_create_request( certificate_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CertificateCreateOrUpdateParameters] = None, content: Any = None, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/certificates/{certificateName}") # pylint: disable=line-too-long path_format_arguments = { @@ -103,24 +107,22 @@ def build_create_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 if_match is not None: - _header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if if_none_match is not None: - _header_parameters['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') + _headers['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') 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 @@ -133,15 +135,18 @@ def build_update_request( certificate_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CertificateCreateOrUpdateParameters] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/certificates/{certificateName}") # pylint: disable=line-too-long path_format_arguments = { @@ -154,22 +159,20 @@ 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 if_match is not None: - _header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') 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 @@ -183,9 +186,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/certificates/{certificateName}") # pylint: disable=line-too-long path_format_arguments = { @@ -198,18 +204,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 ) @@ -221,9 +225,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/certificates/{certificateName}") # pylint: disable=line-too-long path_format_arguments = { @@ -236,18 +243,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 ) @@ -259,9 +264,12 @@ def build_cancel_deletion_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/certificates/{certificateName}/cancelDelete") # pylint: disable=line-too-long path_format_arguments = { @@ -274,42 +282,38 @@ def build_cancel_deletion_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="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class CertificateOperations(object): - """CertificateOperations 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 CertificateOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.batch.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.batch.BatchManagementClient`'s + :attr:`certificate` 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_batch_account( @@ -320,7 +324,7 @@ def list_by_batch_account( select: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ListCertificatesResult"]: + ) -> Iterable[_models.ListCertificatesResult]: """Lists all of the certificates in the specified account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -344,13 +348,16 @@ def list_by_batch_account( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.ListCertificatesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListCertificatesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListCertificatesResult"] 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: @@ -363,9 +370,11 @@ def prepare_request(next_link=None): select=select, filter=filter, template_url=self.list_by_batch_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: @@ -378,9 +387,11 @@ def prepare_request(next_link=None): select=select, filter=filter, 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 @@ -419,11 +430,11 @@ def create( resource_group_name: str, account_name: str, certificate_name: str, - parameters: "_models.CertificateCreateOrUpdateParameters", + parameters: _models.CertificateCreateOrUpdateParameters, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> "_models.Certificate": + ) -> _models.Certificate: """Creates a new certificate inside the specified account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -448,14 +459,17 @@ def create( :rtype: ~azure.mgmt.batch.models.Certificate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Certificate"] 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-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-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.Certificate] _json = self._serialize.body(parameters, 'CertificateCreateOrUpdateParameters') @@ -470,11 +484,13 @@ def create( if_match=if_match, if_none_match=if_none_match, template_url=self.create.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 @@ -504,10 +520,10 @@ def update( resource_group_name: str, account_name: str, certificate_name: str, - parameters: "_models.CertificateCreateOrUpdateParameters", + parameters: _models.CertificateCreateOrUpdateParameters, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.Certificate": + ) -> _models.Certificate: """Updates the properties of an existing certificate. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -528,14 +544,17 @@ def update( :rtype: ~azure.mgmt.batch.models.Certificate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Certificate"] 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-06-01") # 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-06-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.Certificate] _json = self._serialize.body(parameters, 'CertificateCreateOrUpdateParameters') @@ -549,11 +568,13 @@ def update( json=_json, if_match=if_match, 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 @@ -584,13 +605,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements certificate_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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -600,11 +624,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_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 @@ -657,21 +683,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-06-01") # 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-06-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, certificate_name=certificate_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -681,8 +712,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( @@ -702,7 +739,7 @@ def get( account_name: str, certificate_name: str, **kwargs: Any - ) -> "_models.Certificate": + ) -> _models.Certificate: """Gets information about the specified certificate. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -718,13 +755,16 @@ def get( :rtype: ~azure.mgmt.batch.models.Certificate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Certificate"] 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-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Certificate] request = build_get_request( @@ -734,11 +774,13 @@ def get( subscription_id=self._config.subscription_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 @@ -769,7 +811,7 @@ def cancel_deletion( account_name: str, certificate_name: str, **kwargs: Any - ) -> "_models.Certificate": + ) -> _models.Certificate: """Cancels a failed deletion of a certificate from the specified account. If you try to delete a certificate that is being used by a pool or compute node, the status of @@ -792,13 +834,16 @@ def cancel_deletion( :rtype: ~azure.mgmt.batch.models.Certificate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Certificate"] 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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Certificate] request = build_cancel_deletion_request( @@ -808,11 +853,13 @@ def cancel_deletion( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.cancel_deletion.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/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_location_operations.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_location_operations.py index 09cd4e75ad51..fbbf330595e5 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_location_operations.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_location_operations.py @@ -16,12 +16,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 T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,9 +32,12 @@ def build_get_quotas_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Batch/locations/{locationName}/quotas") # pylint: disable=line-too-long path_format_arguments = { @@ -45,18 +48,16 @@ def build_get_quotas_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 +70,12 @@ def build_list_supported_virtual_machine_skus_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Batch/locations/{locationName}/virtualMachineSkus") # pylint: disable=line-too-long path_format_arguments = { @@ -82,22 +86,20 @@ def build_list_supported_virtual_machine_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if maxresults is not None: - _query_parameters['maxresults'] = _SERIALIZER.query("maxresults", maxresults, 'int') + _params['maxresults'] = _SERIALIZER.query("maxresults", maxresults, 'int') if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, '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_list_supported_cloud_service_skus_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Batch/locations/{locationName}/cloudServiceSkus") # pylint: disable=line-too-long path_format_arguments = { @@ -123,22 +128,20 @@ def build_list_supported_cloud_service_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if maxresults is not None: - _query_parameters['maxresults'] = _SERIALIZER.query("maxresults", maxresults, 'int') + _params['maxresults'] = _SERIALIZER.query("maxresults", maxresults, 'int') if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, '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 ) @@ -147,14 +150,17 @@ def build_check_name_availability_request( location_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CheckNameAvailabilityParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/locations/{locationName}/checkNameAvailability") # pylint: disable=line-too-long path_format_arguments = { @@ -165,53 +171,49 @@ 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 LocationOperations(object): - """LocationOperations 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 LocationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.batch.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.batch.BatchManagementClient`'s + :attr:`location` 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 get_quotas( self, location_name: str, **kwargs: Any - ) -> "_models.BatchLocationQuota": + ) -> _models.BatchLocationQuota: """Gets the Batch service quotas for the specified subscription at the given location. :param location_name: The region for which to retrieve Batch service quotas. @@ -221,13 +223,16 @@ def get_quotas( :rtype: ~azure.mgmt.batch.models.BatchLocationQuota :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BatchLocationQuota"] 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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BatchLocationQuota] request = build_get_quotas_request( @@ -235,11 +240,13 @@ def get_quotas( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_quotas.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 @@ -267,7 +274,7 @@ def list_supported_virtual_machine_skus( maxresults: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.SupportedSkusResult"]: + ) -> Iterable[_models.SupportedSkusResult]: """Gets the list of Batch supported Virtual Machine VM sizes available at the given location. :param location_name: The region for which to retrieve Batch service supported SKUs. @@ -283,13 +290,16 @@ def list_supported_virtual_machine_skus( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.SupportedSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SupportedSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedSkusResult"] 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: @@ -300,9 +310,11 @@ def prepare_request(next_link=None): maxresults=maxresults, filter=filter, template_url=self.list_supported_virtual_machine_skus.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: @@ -313,9 +325,11 @@ def prepare_request(next_link=None): maxresults=maxresults, filter=filter, 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 @@ -355,7 +369,7 @@ def list_supported_cloud_service_skus( maxresults: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.SupportedSkusResult"]: + ) -> Iterable[_models.SupportedSkusResult]: """Gets the list of Batch supported Cloud Service VM sizes available at the given location. :param location_name: The region for which to retrieve Batch service supported SKUs. @@ -371,13 +385,16 @@ def list_supported_cloud_service_skus( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.SupportedSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SupportedSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SupportedSkusResult"] 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: @@ -388,9 +405,11 @@ def prepare_request(next_link=None): maxresults=maxresults, filter=filter, template_url=self.list_supported_cloud_service_skus.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: @@ -401,9 +420,11 @@ def prepare_request(next_link=None): maxresults=maxresults, filter=filter, 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 @@ -440,9 +461,9 @@ def get_next(next_link=None): def check_name_availability( self, location_name: str, - parameters: "_models.CheckNameAvailabilityParameters", + parameters: _models.CheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks whether the Batch account name is available in the specified region. :param location_name: The desired region for the name check. @@ -454,14 +475,17 @@ def check_name_availability( :rtype: ~azure.mgmt.batch.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] 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-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-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.CheckNameAvailabilityResult] _json = self._serialize.body(parameters, 'CheckNameAvailabilityParameters') @@ -472,11 +496,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/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_operations.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_operations.py index 59de7fee57a0..90eaf1391ba7 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_operations.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_operations.py @@ -16,6 +16,7 @@ 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 @@ -29,55 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Batch/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: ~azure.mgmt.batch.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.batch.BatchManagementClient`'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]: """Lists available operations for the Microsoft.Batch 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[~azure.mgmt.batch.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_patch.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/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/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_pool_operations.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_pool_operations.py index d41200a0f9a8..008b9c5977c5 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_pool_operations.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_pool_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 T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -39,9 +39,12 @@ def build_list_by_batch_account_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/pools") # pylint: disable=line-too-long path_format_arguments = { @@ -53,24 +56,22 @@ def build_list_by_batch_account_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if maxresults is not None: - _query_parameters['maxresults'] = _SERIALIZER.query("maxresults", maxresults, 'int') + _params['maxresults'] = _SERIALIZER.query("maxresults", maxresults, 'int') if select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, '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 ) @@ -81,16 +82,19 @@ def build_create_request( pool_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Pool] = None, content: Any = None, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/pools/{poolName}") # pylint: disable=line-too-long path_format_arguments = { @@ -103,24 +107,22 @@ def build_create_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 if_match is not None: - _header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if if_none_match is not None: - _header_parameters['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') + _headers['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') 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 @@ -133,15 +135,18 @@ def build_update_request( pool_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Pool] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/pools/{poolName}") # pylint: disable=line-too-long path_format_arguments = { @@ -154,22 +159,20 @@ 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 if_match is not None: - _header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') 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 @@ -183,9 +186,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/pools/{poolName}") # pylint: disable=line-too-long path_format_arguments = { @@ -198,18 +204,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 ) @@ -221,9 +225,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/pools/{poolName}") # pylint: disable=line-too-long path_format_arguments = { @@ -236,18 +243,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 ) @@ -259,9 +264,12 @@ def build_disable_auto_scale_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/pools/{poolName}/disableAutoScale") # pylint: disable=line-too-long path_format_arguments = { @@ -274,18 +282,16 @@ def build_disable_auto_scale_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="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -297,9 +303,12 @@ def build_stop_resize_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/pools/{poolName}/stopResize") # pylint: disable=line-too-long path_format_arguments = { @@ -312,42 +321,38 @@ def build_stop_resize_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="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class PoolOperations(object): - """PoolOperations 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 PoolOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.batch.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.batch.BatchManagementClient`'s + :attr:`pool` 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_batch_account( @@ -358,7 +363,7 @@ def list_by_batch_account( select: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ListPoolsResult"]: + ) -> Iterable[_models.ListPoolsResult]: """Lists all of the pools in the specified account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -391,13 +396,16 @@ def list_by_batch_account( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.ListPoolsResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListPoolsResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListPoolsResult"] 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: @@ -410,9 +418,11 @@ def prepare_request(next_link=None): select=select, filter=filter, template_url=self.list_by_batch_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: @@ -425,9 +435,11 @@ def prepare_request(next_link=None): select=select, filter=filter, 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 @@ -466,11 +478,11 @@ def create( resource_group_name: str, account_name: str, pool_name: str, - parameters: "_models.Pool", + parameters: _models.Pool, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> "_models.Pool": + ) -> _models.Pool: """Creates a new pool inside the specified account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -493,14 +505,17 @@ def create( :rtype: ~azure.mgmt.batch.models.Pool :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Pool"] 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-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-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.Pool] _json = self._serialize.body(parameters, 'Pool') @@ -515,11 +530,13 @@ def create( if_match=if_match, if_none_match=if_none_match, template_url=self.create.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 @@ -549,10 +566,10 @@ def update( resource_group_name: str, account_name: str, pool_name: str, - parameters: "_models.Pool", + parameters: _models.Pool, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.Pool": + ) -> _models.Pool: """Updates the properties of an existing pool. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -572,14 +589,17 @@ def update( :rtype: ~azure.mgmt.batch.models.Pool :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Pool"] 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-06-01") # 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-06-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.Pool] _json = self._serialize.body(parameters, 'Pool') @@ -593,11 +613,13 @@ def update( json=_json, if_match=if_match, 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 @@ -628,13 +650,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements pool_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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -644,11 +669,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_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 @@ -699,21 +726,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-06-01") # 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-06-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, pool_name=pool_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -723,8 +755,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( @@ -744,7 +782,7 @@ def get( account_name: str, pool_name: str, **kwargs: Any - ) -> "_models.Pool": + ) -> _models.Pool: """Gets information about the specified pool. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -758,13 +796,16 @@ def get( :rtype: ~azure.mgmt.batch.models.Pool :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Pool"] 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-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Pool] request = build_get_request( @@ -774,11 +815,13 @@ def get( subscription_id=self._config.subscription_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 @@ -809,7 +852,7 @@ def disable_auto_scale( account_name: str, pool_name: str, **kwargs: Any - ) -> "_models.Pool": + ) -> _models.Pool: """Disables automatic scaling for a pool. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -823,13 +866,16 @@ def disable_auto_scale( :rtype: ~azure.mgmt.batch.models.Pool :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Pool"] 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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Pool] request = build_disable_auto_scale_request( @@ -839,11 +885,13 @@ def disable_auto_scale( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.disable_auto_scale.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 @@ -874,7 +922,7 @@ def stop_resize( account_name: str, pool_name: str, **kwargs: Any - ) -> "_models.Pool": + ) -> _models.Pool: """Stops an ongoing resize operation on the pool. This does not restore the pool to its previous state before the resize operation: it only stops @@ -895,13 +943,16 @@ def stop_resize( :rtype: ~azure.mgmt.batch.models.Pool :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Pool"] 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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Pool] request = build_stop_resize_request( @@ -911,11 +962,13 @@ def stop_resize( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.stop_resize.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/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_private_endpoint_connection_operations.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_private_endpoint_connection_operations.py index a6200ff466b5..654854656798 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_private_endpoint_connection_operations.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_private_endpoint_connection_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 T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,9 +37,12 @@ def build_list_by_batch_account_request( maxresults: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/privateEndpointConnections") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_list_by_batch_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') if maxresults is not None: - _query_parameters['maxresults'] = _SERIALIZER.query("maxresults", maxresults, 'int') + _params['maxresults'] = _SERIALIZER.query("maxresults", maxresults, 'int') # 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 ) @@ -76,9 +77,12 @@ def build_get_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -91,18 +95,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 ) @@ -113,15 +115,18 @@ def build_update_request_initial( account_name: str, private_endpoint_connection_name: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointConnection] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,22 +139,20 @@ 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 if_match is not None: - _header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') 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 @@ -163,9 +166,12 @@ def build_delete_request_initial( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -178,42 +184,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 PrivateEndpointConnectionOperations(object): - """PrivateEndpointConnectionOperations 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 PrivateEndpointConnectionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.batch.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.batch.BatchManagementClient`'s + :attr:`private_endpoint_connection` 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_batch_account( @@ -222,7 +224,7 @@ def list_by_batch_account( account_name: str, maxresults: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ListPrivateEndpointConnectionsResult"]: + ) -> Iterable[_models.ListPrivateEndpointConnectionsResult]: """Lists all of the private endpoint connections in the specified account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -239,13 +241,16 @@ def list_by_batch_account( ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.ListPrivateEndpointConnectionsResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListPrivateEndpointConnectionsResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListPrivateEndpointConnectionsResult"] 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: @@ -256,9 +261,11 @@ def prepare_request(next_link=None): api_version=api_version, maxresults=maxresults, template_url=self.list_by_batch_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: @@ -269,9 +276,11 @@ def prepare_request(next_link=None): api_version=api_version, maxresults=maxresults, 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 @@ -311,7 +320,7 @@ def get( account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets information about the specified private endpoint connection. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -326,13 +335,16 @@ def get( :rtype: ~azure.mgmt.batch.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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -342,11 +354,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 @@ -372,18 +386,21 @@ def _update_initial( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - parameters: "_models.PrivateEndpointConnection", + parameters: _models.PrivateEndpointConnection, if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.PrivateEndpointConnection"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] + ) -> Optional[_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-06-01") # 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-06-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[Optional[_models.PrivateEndpointConnection]] _json = self._serialize.body(parameters, 'PrivateEndpointConnection') @@ -397,11 +414,13 @@ def _update_initial( json=_json, if_match=if_match, 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 @@ -436,10 +455,10 @@ def begin_update( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - parameters: "_models.PrivateEndpointConnection", + parameters: _models.PrivateEndpointConnection, if_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Updates the properties of an existing private endpoint connection. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -469,17 +488,20 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.batch.models.PrivateEndpointConnection] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -488,20 +510,27 @@ def begin_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( @@ -521,13 +550,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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -537,11 +569,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 @@ -593,21 +627,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-06-01") # 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-06-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) @@ -617,8 +656,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': '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/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_private_link_resource_operations.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_private_link_resource_operations.py index 51e8c9d7d567..042c66ef3336 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_private_link_resource_operations.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_private_link_resource_operations.py @@ -16,6 +16,7 @@ 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 @@ -34,9 +35,12 @@ def build_list_by_batch_account_request( maxresults: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/privateLinkResources") # pylint: disable=line-too-long path_format_arguments = { @@ -48,20 +52,18 @@ def build_list_by_batch_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') if maxresults is not None: - _query_parameters['maxresults'] = _SERIALIZER.query("maxresults", maxresults, 'int') + _params['maxresults'] = _SERIALIZER.query("maxresults", maxresults, 'int') # 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 ) @@ -73,9 +75,12 @@ def build_get_request( private_link_resource_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-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.Batch/batchAccounts/{accountName}/privateLinkResources/{privateLinkResourceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -88,42 +93,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 PrivateLinkResourceOperations(object): - """PrivateLinkResourceOperations 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 PrivateLinkResourceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.batch.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.batch.BatchManagementClient`'s + :attr:`private_link_resource` 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_batch_account( @@ -132,7 +133,7 @@ def list_by_batch_account( account_name: str, maxresults: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ListPrivateLinkResourcesResult"]: + ) -> Iterable[_models.ListPrivateLinkResourcesResult]: """Lists all of the private link resources in the specified account. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -148,13 +149,16 @@ def list_by_batch_account( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.ListPrivateLinkResourcesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-06-01") # 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListPrivateLinkResourcesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListPrivateLinkResourcesResult"] 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: @@ -165,9 +169,11 @@ def prepare_request(next_link=None): api_version=api_version, maxresults=maxresults, template_url=self.list_by_batch_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: @@ -178,9 +184,11 @@ def prepare_request(next_link=None): api_version=api_version, maxresults=maxresults, 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 @@ -220,7 +228,7 @@ def get( account_name: str, private_link_resource_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResource": + ) -> _models.PrivateLinkResource: """Gets information about the specified private link resource. :param resource_group_name: The name of the resource group that contains the Batch account. @@ -235,13 +243,16 @@ def get( :rtype: ~azure.mgmt.batch.models.PrivateLinkResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] 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-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResource] request = build_get_request( @@ -251,11 +262,13 @@ def get( private_link_resource_name=private_link_resource_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