From b6a47ab635b65ec8dd08752284866ff3d5705e64 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Tue, 24 Sep 2024 20:41:46 -0700 Subject: [PATCH] [AutoRelease] t2-batch-2024-08-23-81943(can only be merged by SDK owner) (#36998) * code and test * update-testcase * Delete sdk/batch/azure-mgmt-batch/assets.json * update-testcase * changelog * changelog * Update CHANGELOG.md --------- Co-authored-by: azure-sdk Co-authored-by: ChenxiJiang333 Co-authored-by: ChenxiJiang333 <119990644+ChenxiJiang333@users.noreply.github.com> Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> Co-authored-by: Yuchao Yan --- sdk/batch/azure-mgmt-batch/CHANGELOG.md | 60 + sdk/batch/azure-mgmt-batch/_meta.json | 10 +- sdk/batch/azure-mgmt-batch/assets.json | 6 - .../mgmt/batch/_batch_management_client.py | 38 +- .../azure/mgmt/batch/_configuration.py | 11 +- .../azure/mgmt/batch/_patch.py | 1 + .../azure/mgmt/batch/_serialization.py | 94 +- .../azure/mgmt/batch/_vendor.py | 16 - .../azure/mgmt/batch/_version.py | 2 +- .../batch/aio/_batch_management_client.py | 40 +- .../azure/mgmt/batch/aio/_configuration.py | 11 +- .../azure/mgmt/batch/aio/_patch.py | 1 + .../mgmt/batch/aio/operations/__init__.py | 2 + .../aio/operations/_application_operations.py | 153 +-- .../_application_package_operations.py | 151 +- .../operations/_batch_account_operations.py | 412 ++---- .../aio/operations/_certificate_operations.py | 207 ++- .../aio/operations/_location_operations.py | 192 +-- .../_network_security_perimeter_operations.py | 340 +++++ .../mgmt/batch/aio/operations/_operations.py | 37 +- .../batch/aio/operations/_pool_operations.py | 232 ++-- ..._private_endpoint_connection_operations.py | 203 ++- .../_private_link_resource_operations.py | 60 +- .../azure/mgmt/batch/models/__init__.py | 58 +- .../models/_batch_management_client_enums.py | 209 ++- .../azure/mgmt/batch/models/_models_py3.py | 1213 ++++++++++++++--- .../azure/mgmt/batch/operations/__init__.py | 2 + .../operations/_application_operations.py | 163 +-- .../_application_package_operations.py | 161 +-- .../operations/_batch_account_operations.py | 440 +++--- .../operations/_certificate_operations.py | 219 ++- .../batch/operations/_location_operations.py | 238 +--- .../_network_security_perimeter_operations.py | 457 +++++++ .../mgmt/batch/operations/_operations.py | 39 +- .../mgmt/batch/operations/_pool_operations.py | 246 ++-- ..._private_endpoint_connection_operations.py | 211 ++- .../_private_link_resource_operations.py | 64 +- .../azure-mgmt-batch/dev_requirements.txt | 3 +- .../generated_samples/application_create.py | 3 +- .../generated_samples/application_delete.py | 3 +- .../generated_samples/application_get.py | 3 +- .../generated_samples/application_list.py | 3 +- .../application_package_activate.py | 3 +- .../application_package_create.py | 3 +- .../application_package_delete.py | 3 +- .../application_package_get.py | 3 +- .../application_package_list.py | 3 +- .../generated_samples/application_update.py | 3 +- .../batch_account_create_byos.py | 3 +- .../batch_account_create_default.py | 3 +- ...account_create_system_assigned_identity.py | 3 +- ...h_account_create_user_assigned_identity.py | 3 +- .../generated_samples/batch_account_delete.py | 3 +- .../generated_samples/batch_account_get.py | 3 +- .../batch_account_get_keys.py | 3 +- .../generated_samples/batch_account_list.py | 3 +- .../batch_account_list_by_resource_group.py | 3 +- ...outbound_network_dependencies_endpoints.py | 3 +- .../batch_account_regenerate_key.py | 3 +- ...h_account_synchronize_auto_storage_keys.py | 3 +- .../generated_samples/batch_account_update.py | 3 +- .../certificate_cancel_deletion.py | 3 +- .../certificate_create_full.py | 3 +- .../certificate_create_minimal.py | 3 +- .../certificate_create_minimal_cer.py | 3 +- .../generated_samples/certificate_delete.py | 3 +- .../generated_samples/certificate_get.py | 3 +- .../certificate_get_with_deletion_error.py | 3 +- .../generated_samples/certificate_list.py | 3 +- .../certificate_list_with_filter.py | 3 +- .../generated_samples/certificate_update.py | 3 +- .../generated_samples/detector_get.py | 3 +- .../generated_samples/detector_list.py | 3 +- ..._check_name_availability_already_exists.py | 3 +- ...ation_check_name_availability_available.py | 3 +- .../generated_samples/location_get_quotas.py | 3 +- .../location_list_virtual_machine_skus.py | 3 +- ...figuration.py => nsp_configuration_get.py} | 16 +- .../nsp_configuration_reconcile.py | 42 + ...ice_skus.py => nsp_configurations_list.py} | 10 +- .../generated_samples/operations_list.py | 3 +- .../pool_create_accelerated_networking.py | 3 +- ...pool_create_cloud_service_configuration.py | 110 -- ...e_minimal_virtual_machine_configuration.py | 3 +- .../pool_create_no_public_ip_addresses.py | 3 +- .../pool_create_public_ips.py | 3 +- .../pool_create_resource_tags.py | 3 +- .../pool_create_security_profile.py | 3 +- .../pool_create_shared_image_gallery.py | 3 +- .../generated_samples/pool_create_tags.py | 61 + .../pool_create_upgrade_policy.py | 3 +- .../pool_create_user_assigned_identities.py | 3 +- ...ol_create_virtual_machine_configuration.py | 3 +- ...irtual_machine_configuration_extensions.py | 3 +- ...l_machine_configuration_managed_os_disk.py | 3 +- ...onfiguration_service_artifact_reference.py | 3 +- .../generated_samples/pool_delete.py | 3 +- .../pool_disable_auto_scale.py | 3 +- .../generated_samples/pool_get.py | 3 +- .../pool_get_accelerated_networking.py | 3 +- .../pool_get_security_profile.py | 3 +- .../pool_get_upgrade_policy.py | 3 +- ...irtual_machine_configuration_extensions.py | 3 +- ...al_machine_configuration_manged_os_disk.py | 3 +- ...onfiguration_service_artifact_reference.py | 3 +- .../generated_samples/pool_list.py | 3 +- .../pool_list_with_filter.py | 3 +- .../generated_samples/pool_stop_resize.py | 3 +- .../pool_update_enable_auto_scale.py | 3 +- .../pool_update_other_properties.py | 3 +- .../pool_update_remove_start_task.py | 3 +- .../pool_update_resize_pool.py | 3 +- .../private_batch_account_create.py | 3 +- .../private_batch_account_get.py | 3 +- .../private_endpoint_connection_delete.py | 3 +- .../private_endpoint_connection_get.py | 3 +- .../private_endpoint_connection_update.py | 3 +- .../private_endpoint_connections_list.py | 3 +- .../private_link_resource_get.py | 3 +- .../private_link_resources_list.py | 3 +- .../generated_tests/conftest.py | 35 + ...batch_management_application_operations.py | 93 ++ ...management_application_operations_async.py | 94 ++ ...nagement_application_package_operations.py | 89 ++ ...nt_application_package_operations_async.py | 90 ++ ...tch_management_batch_account_operations.py | 207 +++ ...nagement_batch_account_operations_async.py | 215 +++ ...batch_management_certificate_operations.py | 120 ++ ...management_certificate_operations_async.py | 123 ++ ...st_batch_management_location_operations.py | 53 + ...ch_management_location_operations_async.py | 54 + ...t_network_security_perimeter_operations.py | 57 + ...ork_security_perimeter_operations_async.py | 60 + .../test_batch_management_operations.py | 29 + .../test_batch_management_operations_async.py | 30 + .../test_batch_management_pool_operations.py | 555 ++++++++ ..._batch_management_pool_operations_async.py | 558 ++++++++ ..._private_endpoint_connection_operations.py | 81 ++ ...te_endpoint_connection_operations_async.py | 90 ++ ...gement_private_link_resource_operations.py | 44 + ..._private_link_resource_operations_async.py | 45 + ...ent_batch_account_operations_async_test.py | 29 + ...anagement_batch_account_operations_test.py | 29 + ..._batch_management_operations_async_test.py | 28 + .../test_batch_management_operations_test.py | 27 + ..._mgmt_batch.py => test_mgmt_batch_test.py} | 3 +- 146 files changed, 6501 insertions(+), 2809 deletions(-) delete mode 100644 sdk/batch/azure-mgmt-batch/assets.json delete mode 100644 sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_vendor.py create mode 100644 sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_network_security_perimeter_operations.py create mode 100644 sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_network_security_perimeter_operations.py rename sdk/batch/azure-mgmt-batch/generated_samples/{pool_create_minimal_cloud_service_configuration.py => nsp_configuration_get.py} (73%) create mode 100644 sdk/batch/azure-mgmt-batch/generated_samples/nsp_configuration_reconcile.py rename sdk/batch/azure-mgmt-batch/generated_samples/{location_list_cloud_service_skus.py => nsp_configurations_list.py} (83%) delete mode 100644 sdk/batch/azure-mgmt-batch/generated_samples/pool_create_cloud_service_configuration.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_samples/pool_create_tags.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_tests/conftest.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_application_operations.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_application_operations_async.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_application_package_operations.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_application_package_operations_async.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_batch_account_operations.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_batch_account_operations_async.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_certificate_operations.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_certificate_operations_async.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_location_operations.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_location_operations_async.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_network_security_perimeter_operations.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_network_security_perimeter_operations_async.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_operations.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_operations_async.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_pool_operations.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_pool_operations_async.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_private_endpoint_connection_operations.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_private_endpoint_connection_operations_async.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_private_link_resource_operations.py create mode 100644 sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_private_link_resource_operations_async.py create mode 100644 sdk/batch/azure-mgmt-batch/tests/test_batch_management_batch_account_operations_async_test.py create mode 100644 sdk/batch/azure-mgmt-batch/tests/test_batch_management_batch_account_operations_test.py create mode 100644 sdk/batch/azure-mgmt-batch/tests/test_batch_management_operations_async_test.py create mode 100644 sdk/batch/azure-mgmt-batch/tests/test_batch_management_operations_test.py rename sdk/batch/azure-mgmt-batch/tests/{test_mgmt_batch.py => test_mgmt_batch_test.py} (99%) diff --git a/sdk/batch/azure-mgmt-batch/CHANGELOG.md b/sdk/batch/azure-mgmt-batch/CHANGELOG.md index ec8d310e7066..be68ee0e06a5 100644 --- a/sdk/batch/azure-mgmt-batch/CHANGELOG.md +++ b/sdk/batch/azure-mgmt-batch/CHANGELOG.md @@ -1,5 +1,65 @@ # Release History +## 18.0.0 (2024-09-25) + +### Features Added + + - Client `BatchManagementClient` added operation group `network_security_perimeter` + - Model `Application` added parameter `tags` in method `__init__` + - Model `ApplicationPackage` added parameter `tags` in method `__init__` + - Model `Certificate` added parameter `tags` in method `__init__` + - Model `CertificateCreateOrUpdateParameters` added parameter `tags` in method `__init__` + - Model `DetectorResponse` added parameter `tags` in method `__init__` + - Model `ImageReference` added property `shared_gallery_image_id` + - Model `ImageReference` added property `community_gallery_image_id` + - Model `ManagedDisk` added property `security_profile` + - Model `Pool` added parameter `tags` in method `__init__` + - Model `PrivateEndpointConnection` added parameter `tags` in method `__init__` + - Model `PrivateLinkResource` added parameter `tags` in method `__init__` + - Model `ProxyResource` added property `system_data` + - Model `ProxyResource` added property `additional_properties` + - Enum `PublicNetworkAccessType` added member `SECURED_BY_PERIMETER` + - Model `Resource` added property `system_data` + - Model `TaskContainerSettings` added property `container_host_batch_bind_mounts` + - Added model `AccessRule` + - Added enum `AccessRuleDirection` + - Added model `AccessRuleProperties` + - Added model `AccessRulePropertiesSubscriptionsItem` + - Added model `AzureProxyResource` + - Added model `AzureResource` + - Added model `ContainerHostBatchBindMountEntry` + - Added enum `ContainerHostDataPath` + - Added enum `CreatedByType` + - Added model `ErrorAdditionalInfo` + - Added model `ErrorDetail` + - Added model `ErrorResponse` + - Added enum `IssueType` + - Added model `NetworkSecurityPerimeter` + - Added model `NetworkSecurityPerimeterConfiguration` + - Added model `NetworkSecurityPerimeterConfigurationListResult` + - Added model `NetworkSecurityPerimeterConfigurationProperties` + - Added enum `NetworkSecurityPerimeterConfigurationProvisioningState` + - Added model `NetworkSecurityProfile` + - Added model `ProvisioningIssue` + - Added model `ProvisioningIssueProperties` + - Added model `ResourceAssociation` + - Added enum `ResourceAssociationAccessMode` + - Added enum `SecurityEncryptionTypes` + - Added enum `SecurityTypes` + - Added enum `Severity` + - Added model `SystemData` + - Added model `VMDiskSecurityProfile` + - Added model `NetworkSecurityPerimeterOperations` + +### Breaking Changes + + - Model `DeploymentConfiguration` deleted or renamed its instance variable `cloud_service_configuration` + - Model `ProxyResource` deleted or renamed its instance variable `etag` + - Model `Resource` deleted or renamed its instance variable `location` + - Model `Resource` deleted or renamed its instance variable `tags` + - Deleted or renamed model `CloudServiceConfiguration` + - Deleted or renamed method `LocationOperations.list_supported_cloud_service_skus` + ## 17.3.0 (2024-03-19) ### Features Added diff --git a/sdk/batch/azure-mgmt-batch/_meta.json b/sdk/batch/azure-mgmt-batch/_meta.json index 4d814f6b12ac..0450a38e7d99 100644 --- a/sdk/batch/azure-mgmt-batch/_meta.json +++ b/sdk/batch/azure-mgmt-batch/_meta.json @@ -1,11 +1,11 @@ { - "commit": "c577d8f27e0c3e5e4885134db19bc8193af7260c", + "commit": "1040c6b9bd69bf414c895f7bef87bfd470e90127", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.7", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.7.1", - "@autorest/modelerfour@4.26.2" + "@autorest/python@6.19.0", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/batch/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", + "autorest_command": "autorest specification/batch/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/batch/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/batch/azure-mgmt-batch/assets.json b/sdk/batch/azure-mgmt-batch/assets.json deleted file mode 100644 index 4ee3ba835b1b..000000000000 --- a/sdk/batch/azure-mgmt-batch/assets.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "AssetsRepo": "Azure/azure-sdk-assets", - "AssetsRepoPrefixPath": "python", - "TagPrefix": "python/batch/azure-mgmt-batch", - "Tag": "python/batch/azure-mgmt-batch_a0b3bb5717" -} 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 7ec98f07c75e..5407e5e94888 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 @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from ._configuration import BatchManagementClientConfiguration @@ -21,6 +24,7 @@ BatchAccountOperations, CertificateOperations, LocationOperations, + NetworkSecurityPerimeterOperations, Operations, PoolOperations, PrivateEndpointConnectionOperations, @@ -54,6 +58,9 @@ class BatchManagementClient: # pylint: disable=client-accepts-api-version-keywo azure.mgmt.batch.operations.PrivateEndpointConnectionOperations :ivar pool: PoolOperations operations :vartype pool: azure.mgmt.batch.operations.PoolOperations + :ivar network_security_perimeter: NetworkSecurityPerimeterOperations operations + :vartype network_security_perimeter: + azure.mgmt.batch.operations.NetworkSecurityPerimeterOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. @@ -61,7 +68,7 @@ class BatchManagementClient: # pylint: disable=client-accepts-api-version-keywo :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-07-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -78,7 +85,25 @@ def __init__( self._config = BatchManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -99,8 +124,11 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.pool = PoolOperations(self._client, self._config, self._serialize, self._deserialize) + self.network_security_perimeter = NetworkSecurityPerimeterOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -120,12 +148,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "BatchManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_configuration.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_configuration.py index ac476610c336..93f7c26287ca 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_configuration.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class BatchManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class BatchManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for BatchManagementClient. Note that all parameters used to create this instance are saved as instance @@ -30,14 +29,13 @@ class BatchManagementClientConfiguration(Configuration): # pylint: disable=too- :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-07-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(BatchManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2024-02-01") + api_version: str = kwargs.pop("api_version", "2024-07-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -49,6 +47,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-batch/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -57,9 +56,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_patch.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_patch.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file 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 def patch_sdk(): diff --git a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_serialization.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_serialization.py index 4bae2292227b..8139854b97bb 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_serialization.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_serialization.py @@ -63,8 +63,8 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -124,7 +124,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -143,7 +143,9 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -170,13 +172,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -295,7 +290,7 @@ class Model(object): _validation: Dict[str, Dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Dict[str, Any] = {} + self.additional_properties: Optional[Dict[str, Any]] = {} for k in kwargs: if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -340,7 +335,7 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,7 +346,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore def as_dict( self, @@ -390,7 +385,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore @classmethod def _infer_class_models(cls): @@ -415,7 +410,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( @@ -445,7 +440,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -545,7 +540,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -561,7 +556,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -649,7 +644,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -668,7 +663,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -710,7 +705,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) @@ -730,6 +725,7 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") except SerializationError: @@ -744,7 +740,7 @@ def query(self, name, data, data_type, **kwargs): :param str data_type: The type to be serialized from. :keyword bool skip_quote: Whether to skip quote the serialized result. Defaults to False. - :rtype: str + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -753,7 +749,7 @@ def query(self, name, data, data_type, **kwargs): if data_type.startswith("["): internal_data_type = data_type[1:-1] do_quote = not kwargs.get("skip_quote", False) - return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -804,7 +800,7 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -824,7 +820,7 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) + raise SerializationError(msg.format(data, data_type)) from err else: return self._serialize(data, **kwargs) @@ -993,7 +989,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1170,10 +1166,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod def serialize_unix(attr, **kwargs): @@ -1209,7 +1205,6 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1230,7 +1225,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1371,7 +1365,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1391,7 +1385,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1444,12 +1438,12 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore @@ -1481,7 +1475,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1515,14 +1509,14 @@ def _classify_target(self, target, data): if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1578,7 +1572,7 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data @@ -1652,7 +1646,7 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1700,7 +1694,7 @@ def deserialize_object(self, attr, **kwargs): if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1757,7 +1751,7 @@ def deserialize_basic(self, attr, data_type): if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + elif isinstance(attr, str): if attr.lower() in ["true", "1"]: return True elif attr.lower() in ["false", "0"]: @@ -1808,7 +1802,6 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] except IndexError: @@ -1862,10 +1855,10 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): @@ -1893,7 +1886,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return duration @@ -1910,7 +1903,7 @@ def deserialize_date(attr): if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): @@ -1945,7 +1938,7 @@ def deserialize_rfc(attr): date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1982,7 +1975,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1998,9 +1991,10 @@ def deserialize_unix(attr): if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj diff --git a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_vendor.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request 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 cc86eec5022f..8dae91701610 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 = "17.3.0" +VERSION = "18.0.0" 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 514c28149a78..4348a7b86864 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 @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from .._serialization import Deserializer, Serializer @@ -21,6 +24,7 @@ BatchAccountOperations, CertificateOperations, LocationOperations, + NetworkSecurityPerimeterOperations, Operations, PoolOperations, PrivateEndpointConnectionOperations, @@ -54,6 +58,9 @@ class BatchManagementClient: # pylint: disable=client-accepts-api-version-keywo azure.mgmt.batch.aio.operations.PrivateEndpointConnectionOperations :ivar pool: PoolOperations operations :vartype pool: azure.mgmt.batch.aio.operations.PoolOperations + :ivar network_security_perimeter: NetworkSecurityPerimeterOperations operations + :vartype network_security_perimeter: + azure.mgmt.batch.aio.operations.NetworkSecurityPerimeterOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. @@ -61,7 +68,7 @@ class BatchManagementClient: # pylint: disable=client-accepts-api-version-keywo :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-07-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -78,7 +85,25 @@ def __init__( self._config = BatchManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -99,8 +124,13 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.pool = PoolOperations(self._client, self._config, self._serialize, self._deserialize) + self.network_security_perimeter = NetworkSecurityPerimeterOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -120,12 +150,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "BatchManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/_configuration.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/_configuration.py index 2f71e5cff910..3e524c012aaf 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/_configuration.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class BatchManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class BatchManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for BatchManagementClient. Note that all parameters used to create this instance are saved as instance @@ -30,14 +29,13 @@ class BatchManagementClientConfiguration(Configuration): # pylint: disable=too- :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-07-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(BatchManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2024-02-01") + api_version: str = kwargs.pop("api_version", "2024-07-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -49,6 +47,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-batch/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -57,9 +56,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/_patch.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/_patch.py +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file 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 def patch_sdk(): 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 ec302145381b..5ef1210d26db 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 @@ -15,6 +15,7 @@ from ._private_link_resource_operations import PrivateLinkResourceOperations from ._private_endpoint_connection_operations import PrivateEndpointConnectionOperations from ._pool_operations import PoolOperations +from ._network_security_perimeter_operations import NetworkSecurityPerimeterOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -30,6 +31,7 @@ "PrivateLinkResourceOperations", "PrivateEndpointConnectionOperations", "PoolOperations", + "NetworkSecurityPerimeterOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() 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 c05d862a390b..c0619f924462 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._application_operations import ( build_create_request, build_delete_request, @@ -37,6 +36,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -86,7 +89,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Application or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Application :raises ~azure.core.exceptions.HttpResponseError: @@ -98,7 +100,7 @@ async def create( resource_group_name: str, account_name: str, application_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -114,11 +116,10 @@ async def create( Required. :type application_name: str :param parameters: The parameters for the request. Default value is None. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Application or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Application :raises ~azure.core.exceptions.HttpResponseError: @@ -130,7 +131,7 @@ async def create( resource_group_name: str, account_name: str, application_name: str, - parameters: Optional[Union[_models.Application, IO]] = None, + parameters: Optional[Union[_models.Application, IO[bytes]]] = None, **kwargs: Any ) -> _models.Application: """Adds an application to the specified Batch account. @@ -143,18 +144,14 @@ async def create( :param application_name: The name of the application. This must be unique within the account. Required. :type application_name: str - :param parameters: The parameters for the request. Is either a Application type or a IO type. - Default value is None. - :type parameters: ~azure.mgmt.batch.models.Application or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: The parameters for the request. Is either a Application type or a IO[bytes] + type. Default value is None. + :type parameters: ~azure.mgmt.batch.models.Application or IO[bytes] :return: Application or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Application :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -180,7 +177,7 @@ async def create( else: _json = None - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, application_name=application_name, @@ -189,16 +186,14 @@ async def create( content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -207,16 +202,12 @@ async def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Application", pipeline_response) + deserialized = self._deserialize("Application", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -232,12 +223,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :param application_name: The name of the application. This must be unique within the account. Required. :type application_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -251,22 +241,20 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, application_name=application_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -276,11 +264,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -296,12 +280,11 @@ async def get( :param application_name: The name of the application. This must be unique within the account. Required. :type application_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Application or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Application :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -315,22 +298,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Application] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, application_name=application_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -339,16 +320,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Application", pipeline_response) + deserialized = self._deserialize("Application", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationName}" - } + return deserialized # type: ignore @overload async def update( @@ -376,7 +353,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Application or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Application :raises ~azure.core.exceptions.HttpResponseError: @@ -388,7 +364,7 @@ async def update( resource_group_name: str, account_name: str, application_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -404,11 +380,10 @@ async def update( Required. :type application_name: str :param parameters: The parameters for the request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Application or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Application :raises ~azure.core.exceptions.HttpResponseError: @@ -420,7 +395,7 @@ async def update( resource_group_name: str, account_name: str, application_name: str, - parameters: Union[_models.Application, IO], + parameters: Union[_models.Application, IO[bytes]], **kwargs: Any ) -> _models.Application: """Updates settings for the specified application. @@ -433,18 +408,14 @@ async def update( :param application_name: The name of the application. This must be unique within the account. Required. :type application_name: str - :param parameters: The parameters for the request. Is either a Application type or a IO type. - Required. - :type parameters: ~azure.mgmt.batch.models.Application or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: The parameters for the request. Is either a Application type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.batch.models.Application or IO[bytes] :return: Application or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Application :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -467,7 +438,7 @@ async def update( else: _json = self._serialize.body(parameters, "Application") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, application_name=application_name, @@ -476,16 +447,14 @@ async def update( content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -494,16 +463,12 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Application", pipeline_response) + deserialized = self._deserialize("Application", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -519,7 +484,6 @@ def list( :param maxresults: The maximum number of items to return in the response. Default value is None. :type maxresults: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Application or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.Application] :raises ~azure.core.exceptions.HttpResponseError: @@ -530,7 +494,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ListApplicationsResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -541,18 +505,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxresults=maxresults, 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) else: # make call to next link with the client's api-version @@ -564,13 +526,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListApplicationsResult", pipeline_response) @@ -580,11 +541,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -595,7 +556,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications" - } 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 f0f72994dfa8..f9b516a08ecc 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._application_package_operations import ( build_activate_request, build_create_request, @@ -37,6 +36,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -91,7 +94,6 @@ async def activate( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationPackage or the result of cls(response) :rtype: ~azure.mgmt.batch.models.ApplicationPackage :raises ~azure.core.exceptions.HttpResponseError: @@ -104,7 +106,7 @@ async def activate( account_name: str, application_name: str, version_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -124,11 +126,10 @@ async def activate( :param version_name: The version of the application. Required. :type version_name: str :param parameters: The parameters for the request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationPackage or the result of cls(response) :rtype: ~azure.mgmt.batch.models.ApplicationPackage :raises ~azure.core.exceptions.HttpResponseError: @@ -141,7 +142,7 @@ async def activate( account_name: str, application_name: str, version_name: str, - parameters: Union[_models.ActivateApplicationPackageParameters, IO], + parameters: Union[_models.ActivateApplicationPackageParameters, IO[bytes]], **kwargs: Any ) -> _models.ApplicationPackage: """Activates the specified application package. This should be done after the @@ -159,17 +160,13 @@ async def activate( :param version_name: The version of the application. Required. :type version_name: str :param parameters: The parameters for the request. Is either a - ActivateApplicationPackageParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.batch.models.ActivateApplicationPackageParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ActivateApplicationPackageParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.batch.models.ActivateApplicationPackageParameters or IO[bytes] :return: ApplicationPackage or the result of cls(response) :rtype: ~azure.mgmt.batch.models.ApplicationPackage :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -192,7 +189,7 @@ async def activate( else: _json = self._serialize.body(parameters, "ActivateApplicationPackageParameters") - request = build_activate_request( + _request = build_activate_request( resource_group_name=resource_group_name, account_name=account_name, application_name=application_name, @@ -202,16 +199,14 @@ async def activate( content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,16 +215,12 @@ async def activate( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationPackage", pipeline_response) + deserialized = self._deserialize("ApplicationPackage", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - activate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationName}/versions/{versionName}/activate" - } + return deserialized # type: ignore @overload async def create( @@ -263,7 +254,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationPackage or the result of cls(response) :rtype: ~azure.mgmt.batch.models.ApplicationPackage :raises ~azure.core.exceptions.HttpResponseError: @@ -276,7 +266,7 @@ async def create( account_name: str, application_name: str, version_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -297,11 +287,10 @@ async def create( :param version_name: The version of the application. Required. :type version_name: str :param parameters: The parameters for the request. Default value is None. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationPackage or the result of cls(response) :rtype: ~azure.mgmt.batch.models.ApplicationPackage :raises ~azure.core.exceptions.HttpResponseError: @@ -314,7 +303,7 @@ async def create( account_name: str, application_name: str, version_name: str, - parameters: Optional[Union[_models.ApplicationPackage, IO]] = None, + parameters: Optional[Union[_models.ApplicationPackage, IO[bytes]]] = None, **kwargs: Any ) -> _models.ApplicationPackage: """Creates an application package record. The record contains a storageUrl where the package @@ -332,18 +321,14 @@ async def create( :type application_name: str :param version_name: The version of the application. Required. :type version_name: str - :param parameters: The parameters for the request. Is either a ApplicationPackage type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.batch.models.ApplicationPackage or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: The parameters for the request. Is either a ApplicationPackage type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.batch.models.ApplicationPackage or IO[bytes] :return: ApplicationPackage or the result of cls(response) :rtype: ~azure.mgmt.batch.models.ApplicationPackage :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -369,7 +354,7 @@ async def create( else: _json = None - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, application_name=application_name, @@ -379,16 +364,14 @@ async def create( content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -397,16 +380,12 @@ async def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationPackage", pipeline_response) + deserialized = self._deserialize("ApplicationPackage", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationName}/versions/{versionName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -424,12 +403,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type application_name: str :param version_name: The version of the application. Required. :type version_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -443,23 +421,21 @@ async def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, application_name=application_name, version_name=version_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -469,11 +445,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationName}/versions/{versionName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -491,12 +463,11 @@ async def get( :type application_name: str :param version_name: The version of the application. Required. :type version_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationPackage or the result of cls(response) :rtype: ~azure.mgmt.batch.models.ApplicationPackage :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -510,23 +481,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApplicationPackage] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, application_name=application_name, version_name=version_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -535,16 +504,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationPackage", pipeline_response) + deserialized = self._deserialize("ApplicationPackage", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationName}/versions/{versionName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -568,7 +533,6 @@ def list( :param maxresults: The maximum number of items to return in the response. Default value is None. :type maxresults: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApplicationPackage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.ApplicationPackage] :raises ~azure.core.exceptions.HttpResponseError: @@ -579,7 +543,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ListApplicationPackagesResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -590,19 +554,17 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, application_name=application_name, subscription_id=self._config.subscription_id, maxresults=maxresults, 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) else: # make call to next link with the client's api-version @@ -614,13 +576,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListApplicationPackagesResult", pipeline_response) @@ -630,11 +591,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -645,7 +606,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationName}/versions" - } 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 499709b7474b..eb8cd93e8fd2 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._batch_account_operations import ( build_create_request, build_delete_request, @@ -46,6 +47,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,10 +78,10 @@ async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BatchAccountCreateParameters, IO], + parameters: Union[_models.BatchAccountCreateParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.BatchAccount]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,7 +94,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.BatchAccount]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -99,7 +104,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "BatchAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -107,41 +112,38 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("BatchAccount", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -170,14 +172,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either BatchAccount or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.batch.models.BatchAccount] @@ -189,7 +183,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -207,18 +201,10 @@ async def begin_create( http://accountname.region.batch.azure.com/. Required. :type account_name: str :param parameters: Additional parameters for account creation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either BatchAccount or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.batch.models.BatchAccount] @@ -230,7 +216,7 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BatchAccountCreateParameters, IO], + parameters: Union[_models.BatchAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.BatchAccount]: """Creates a new Batch account with the specified parameters. Existing accounts cannot be updated @@ -246,19 +232,8 @@ async def begin_create( http://accountname.region.batch.azure.com/. Required. :type account_name: str :param parameters: Additional parameters for account creation. Is either a - BatchAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.batch.models.BatchAccountCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + BatchAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.batch.models.BatchAccountCreateParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either BatchAccount or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.batch.models.BatchAccount] @@ -285,12 +260,13 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("BatchAccount", pipeline_response) + deserialized = self._deserialize("BatchAccount", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -302,17 +278,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.BatchAccount].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}" - } + return AsyncLROPoller[_models.BatchAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @overload async def update( @@ -336,7 +310,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BatchAccount or the result of cls(response) :rtype: ~azure.mgmt.batch.models.BatchAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -347,7 +320,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -360,11 +333,10 @@ async def update( :param account_name: The name of the Batch account. Required. :type account_name: str :param parameters: Additional parameters for account update. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BatchAccount or the result of cls(response) :rtype: ~azure.mgmt.batch.models.BatchAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -375,7 +347,7 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BatchAccountUpdateParameters, IO], + parameters: Union[_models.BatchAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.BatchAccount: """Updates the properties of an existing Batch account. @@ -386,17 +358,13 @@ async def update( :param account_name: The name of the Batch account. Required. :type account_name: str :param parameters: Additional parameters for account update. Is either a - BatchAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.batch.models.BatchAccountUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + BatchAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.batch.models.BatchAccountUpdateParameters or IO[bytes] :return: BatchAccount or the result of cls(response) :rtype: ~azure.mgmt.batch.models.BatchAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -419,7 +387,7 @@ async def update( else: _json = self._serialize.body(parameters, "BatchAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -427,16 +395,14 @@ async def update( content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -445,21 +411,15 @@ async def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("BatchAccount", pipeline_response) + deserialized = self._deserialize("BatchAccount", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}" - } + return deserialized # type: ignore - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> None: - error_map = { + async def _delete_initial(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -471,28 +431,31 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -501,12 +464,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -517,14 +480,6 @@ async def begin_delete(self, resource_group_name: str, account_name: str, **kwar :type resource_group_name: str :param account_name: The name of the Batch account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -538,7 +493,7 @@ async def begin_delete(self, resource_group_name: str, account_name: str, **kwar lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, @@ -547,11 +502,12 @@ async def begin_delete(self, resource_group_name: str, account_name: str, **kwar params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -562,17 +518,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.BatchAccount: @@ -583,12 +535,11 @@ async def get(self, resource_group_name: str, account_name: str, **kwargs: Any) :type resource_group_name: str :param account_name: The name of the Batch account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BatchAccount or the result of cls(response) :rtype: ~azure.mgmt.batch.models.BatchAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -602,21 +553,19 @@ async def get(self, resource_group_name: str, account_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BatchAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -625,22 +574,17 @@ async def get(self, resource_group_name: str, account_name: str, **kwargs: Any) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("BatchAccount", pipeline_response) + deserialized = self._deserialize("BatchAccount", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.BatchAccount"]: """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 :return: An iterator like instance of either BatchAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.BatchAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -651,7 +595,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.BatchAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BatchAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -662,15 +606,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.BatchAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) else: # make call to next link with the client's api-version @@ -682,13 +624,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("BatchAccountListResult", pipeline_response) @@ -698,11 +639,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -714,8 +655,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Batch/batchAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.BatchAccount"]: """Gets information about the Batch accounts associated with the specified resource group. @@ -723,7 +662,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy :param resource_group_name: The name of the resource group that contains the Batch account. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BatchAccount or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.BatchAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -734,7 +672,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BatchAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -745,16 +683,14 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, 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) else: # make call to next link with the client's api-version @@ -766,13 +702,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("BatchAccountListResult", pipeline_response) @@ -782,11 +717,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -798,10 +733,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts" - } - @distributed_trace_async async def synchronize_auto_storage_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any @@ -814,12 +745,11 @@ async def synchronize_auto_storage_keys( # pylint: disable=inconsistent-return- :type resource_group_name: str :param account_name: The name of the Batch account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -833,21 +763,19 @@ async def synchronize_auto_storage_keys( # pylint: disable=inconsistent-return- api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_synchronize_auto_storage_keys_request( + _request = build_synchronize_auto_storage_keys_request( resource_group_name=resource_group_name, account_name=account_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -857,11 +785,7 @@ async def synchronize_auto_storage_keys( # pylint: disable=inconsistent-return- raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - synchronize_auto_storage_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/syncAutoStorageKeys" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def regenerate_key( @@ -890,7 +814,6 @@ async def regenerate_key( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BatchAccountKeys or the result of cls(response) :rtype: ~azure.mgmt.batch.models.BatchAccountKeys :raises ~azure.core.exceptions.HttpResponseError: @@ -901,7 +824,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -919,11 +842,10 @@ async def regenerate_key( :param account_name: The name of the Batch account. Required. :type account_name: str :param parameters: The type of key to regenerate. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BatchAccountKeys or the result of cls(response) :rtype: ~azure.mgmt.batch.models.BatchAccountKeys :raises ~azure.core.exceptions.HttpResponseError: @@ -934,7 +856,7 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BatchAccountRegenerateKeyParameters, IO], + parameters: Union[_models.BatchAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.BatchAccountKeys: """Regenerates the specified account key for the Batch account. @@ -950,17 +872,13 @@ async def regenerate_key( :param account_name: The name of the Batch account. Required. :type account_name: str :param parameters: The type of key to regenerate. Is either a - BatchAccountRegenerateKeyParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.batch.models.BatchAccountRegenerateKeyParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + BatchAccountRegenerateKeyParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.batch.models.BatchAccountRegenerateKeyParameters or IO[bytes] :return: BatchAccountKeys or the result of cls(response) :rtype: ~azure.mgmt.batch.models.BatchAccountKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -983,7 +901,7 @@ async def regenerate_key( else: _json = self._serialize.body(parameters, "BatchAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -991,16 +909,14 @@ async def regenerate_key( content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1009,16 +925,12 @@ async def regenerate_key( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("BatchAccountKeys", pipeline_response) + deserialized = self._deserialize("BatchAccountKeys", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/regenerateKeys" - } + return deserialized # type: ignore @distributed_trace_async async def get_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.BatchAccountKeys: @@ -1034,12 +946,11 @@ async def get_keys(self, resource_group_name: str, account_name: str, **kwargs: :type resource_group_name: str :param account_name: The name of the Batch account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BatchAccountKeys or the result of cls(response) :rtype: ~azure.mgmt.batch.models.BatchAccountKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1053,21 +964,19 @@ async def get_keys(self, resource_group_name: str, account_name: str, **kwargs: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BatchAccountKeys] = kwargs.pop("cls", None) - request = build_get_keys_request( + _request = build_get_keys_request( resource_group_name=resource_group_name, account_name=account_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1076,16 +985,12 @@ async def get_keys(self, resource_group_name: str, account_name: str, **kwargs: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("BatchAccountKeys", pipeline_response) + deserialized = self._deserialize("BatchAccountKeys", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @distributed_trace def list_detectors( @@ -1098,7 +1003,6 @@ def list_detectors( :type resource_group_name: str :param account_name: The name of the Batch account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DetectorResponse or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.DetectorResponse] :raises ~azure.core.exceptions.HttpResponseError: @@ -1109,7 +1013,7 @@ def list_detectors( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DetectorListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1120,17 +1024,15 @@ def list_detectors( def prepare_request(next_link=None): if not next_link: - request = build_list_detectors_request( + _request = build_list_detectors_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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) else: # make call to next link with the client's api-version @@ -1142,13 +1044,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DetectorListResult", pipeline_response) @@ -1158,11 +1059,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1174,10 +1075,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_detectors.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/detectors" - } - @distributed_trace_async async def get_detector( self, resource_group_name: str, account_name: str, detector_id: str, **kwargs: Any @@ -1191,12 +1088,11 @@ async def get_detector( :type account_name: str :param detector_id: The name of the detector. Required. :type detector_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DetectorResponse or the result of cls(response) :rtype: ~azure.mgmt.batch.models.DetectorResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1210,22 +1106,20 @@ async def get_detector( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DetectorResponse] = kwargs.pop("cls", None) - request = build_get_detector_request( + _request = build_get_detector_request( resource_group_name=resource_group_name, account_name=account_name, detector_id=detector_id, subscription_id=self._config.subscription_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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1234,19 +1128,15 @@ async def get_detector( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DetectorResponse", pipeline_response) + deserialized = self._deserialize("DetectorResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_detector.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/detectors/{detectorId}" - } + return deserialized # type: ignore @distributed_trace - def list_outbound_network_dependencies_endpoints( + def list_outbound_network_dependencies_endpoints( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> AsyncIterable["_models.OutboundEnvironmentEndpoint"]: """Lists the endpoints that a Batch Compute Node under this Batch Account may call as part of @@ -1261,7 +1151,6 @@ def list_outbound_network_dependencies_endpoints( :type resource_group_name: str :param account_name: The name of the Batch account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OutboundEnvironmentEndpoint or the result of cls(response) :rtype: @@ -1274,7 +1163,7 @@ def list_outbound_network_dependencies_endpoints( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OutboundEnvironmentEndpointCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1285,17 +1174,15 @@ def list_outbound_network_dependencies_endpoints( def prepare_request(next_link=None): if not next_link: - request = build_list_outbound_network_dependencies_endpoints_request( + _request = build_list_outbound_network_dependencies_endpoints_request( resource_group_name=resource_group_name, account_name=account_name, 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) else: # make call to next link with the client's api-version @@ -1307,13 +1194,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OutboundEnvironmentEndpointCollection", pipeline_response) @@ -1323,11 +1209,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1338,7 +1224,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_outbound_network_dependencies_endpoints.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/outboundNetworkDependenciesEndpoints" - } 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 0c1f1b1aeb77..34d762e60f16 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._certificate_operations import ( build_cancel_deletion_request, build_create_request, @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -95,7 +100,6 @@ def list_by_batch_account( "properties/provisioningState", "properties/provisioningStateTransitionTime", "name". Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Certificate or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.Certificate] :raises ~azure.core.exceptions.HttpResponseError: @@ -106,7 +110,7 @@ def list_by_batch_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ListCertificatesResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -117,7 +121,7 @@ def list_by_batch_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_batch_account_request( + _request = build_list_by_batch_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -125,12 +129,10 @@ def prepare_request(next_link=None): select=select, filter=filter, api_version=api_version, - 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) else: # make call to next link with the client's api-version @@ -142,13 +144,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListCertificatesResult", pipeline_response) @@ -158,11 +159,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -174,10 +175,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_batch_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/certificates" - } - @overload async def create( self, @@ -218,7 +215,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: @@ -230,7 +226,7 @@ async def create( resource_group_name: str, account_name: str, certificate_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -253,7 +249,7 @@ async def create( example SHA1-a3d1c5. Required. :type certificate_name: str :param parameters: Additional parameters for certificate creation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The entity state (ETag) version of the certificate to update. A value of "*" can be used to apply the operation only if the certificate already exists. If omitted, this operation will always be applied. Default value is None. @@ -264,7 +260,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: @@ -276,7 +271,7 @@ async def create( resource_group_name: str, account_name: str, certificate_name: str, - parameters: Union[_models.CertificateCreateOrUpdateParameters, IO], + parameters: Union[_models.CertificateCreateOrUpdateParameters, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -297,8 +292,8 @@ async def create( example SHA1-a3d1c5. Required. :type certificate_name: str :param parameters: Additional parameters for certificate creation. Is either a - CertificateCreateOrUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.batch.models.CertificateCreateOrUpdateParameters or IO + CertificateCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.batch.models.CertificateCreateOrUpdateParameters or IO[bytes] :param if_match: The entity state (ETag) version of the certificate to update. A value of "*" can be used to apply the operation only if the certificate already exists. If omitted, this operation will always be applied. Default value is None. @@ -306,15 +301,11 @@ async def create( :param if_none_match: Set to '*' to allow a new certificate to be created, but to prevent updating an existing certificate. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -337,7 +328,7 @@ async def create( else: _json = self._serialize.body(parameters, "CertificateCreateOrUpdateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, certificate_name=certificate_name, @@ -348,16 +339,14 @@ async def create( content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,16 +358,12 @@ async def create( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Certificate", pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/certificates/{certificateName}" - } + return deserialized # type: ignore @overload async def update( @@ -415,7 +400,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: @@ -427,7 +411,7 @@ async def update( resource_group_name: str, account_name: str, certificate_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -449,14 +433,13 @@ async def update( example SHA1-a3d1c5. Required. :type certificate_name: str :param parameters: Certificate entity to update. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The entity state (ETag) version of the certificate to update. This value can be omitted or set to "*" to apply the operation unconditionally. Default value is None. :type if_match: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: @@ -468,7 +451,7 @@ async def update( resource_group_name: str, account_name: str, certificate_name: str, - parameters: Union[_models.CertificateCreateOrUpdateParameters, IO], + parameters: Union[_models.CertificateCreateOrUpdateParameters, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> _models.Certificate: @@ -488,20 +471,16 @@ async def update( example SHA1-a3d1c5. Required. :type certificate_name: str :param parameters: Certificate entity to update. Is either a - CertificateCreateOrUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.batch.models.CertificateCreateOrUpdateParameters or IO + CertificateCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.batch.models.CertificateCreateOrUpdateParameters or IO[bytes] :param if_match: The entity state (ETag) version of the certificate to update. This value can be omitted or set to "*" to apply the operation unconditionally. Default value is None. :type if_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -524,7 +503,7 @@ async def update( else: _json = self._serialize.body(parameters, "CertificateCreateOrUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, certificate_name=certificate_name, @@ -534,16 +513,14 @@ async def update( content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -555,21 +532,17 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Certificate", pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/certificates/{certificateName}" - } + return deserialized # type: ignore - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, account_name: str, certificate_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -581,29 +554,32 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, certificate_name=certificate_name, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -612,12 +588,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/certificates/{certificateName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -638,14 +614,6 @@ async def begin_delete( and thumbprint separated by a dash, and must match the certificate data in the request. For example SHA1-a3d1c5. Required. :type certificate_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -659,7 +627,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, account_name=account_name, certificate_name=certificate_name, @@ -669,11 +637,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -684,17 +653,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/certificates/{certificateName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get( @@ -715,12 +680,11 @@ async def get( and thumbprint separated by a dash, and must match the certificate data in the request. For example SHA1-a3d1c5. Required. :type certificate_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -734,22 +698,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Certificate] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, certificate_name=certificate_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -761,16 +723,12 @@ async def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Certificate", pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/certificates/{certificateName}" - } + return deserialized # type: ignore @distributed_trace_async async def cancel_deletion( @@ -798,12 +756,11 @@ async def cancel_deletion( and thumbprint separated by a dash, and must match the certificate data in the request. For example SHA1-a3d1c5. Required. :type certificate_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -817,22 +774,20 @@ async def cancel_deletion( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Certificate] = kwargs.pop("cls", None) - request = build_cancel_deletion_request( + _request = build_cancel_deletion_request( resource_group_name=resource_group_name, account_name=account_name, certificate_name=certificate_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -844,13 +799,9 @@ async def cancel_deletion( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Certificate", pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - cancel_deletion.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/certificates/{certificateName}/cancelDelete" - } + return deserialized # type: ignore 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 5e9ede4a392e..75c99df5f828 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,22 +21,23 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._location_operations import ( build_check_name_availability_request, build_get_quotas_request, - build_list_supported_cloud_service_skus_request, build_list_supported_virtual_machine_skus_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -65,12 +67,11 @@ async def get_quotas(self, location_name: str, **kwargs: Any) -> _models.BatchLo :param location_name: The region for which to retrieve Batch service quotas. Required. :type location_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BatchLocationQuota or the result of cls(response) :rtype: ~azure.mgmt.batch.models.BatchLocationQuota :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,20 +85,18 @@ async def get_quotas(self, location_name: str, **kwargs: Any) -> _models.BatchLo api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BatchLocationQuota] = kwargs.pop("cls", None) - request = build_get_quotas_request( + _request = build_get_quotas_request( location_name=location_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -106,16 +105,12 @@ async def get_quotas(self, location_name: str, **kwargs: Any) -> _models.BatchLo map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("BatchLocationQuota", pipeline_response) + deserialized = self._deserialize("BatchLocationQuota", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_quotas.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Batch/locations/{locationName}/quotas" - } + return deserialized # type: ignore @distributed_trace def list_supported_virtual_machine_skus( @@ -131,102 +126,6 @@ def list_supported_virtual_machine_skus( :param filter: OData filter expression. Valid properties for filtering are "familyName". Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SupportedSku or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.SupportedSku] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SupportedSkusResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_supported_virtual_machine_skus_request( - location_name=location_name, - subscription_id=self._config.subscription_id, - maxresults=maxresults, - filter=filter, - api_version=api_version, - 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) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SupportedSkusResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_supported_virtual_machine_skus.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Batch/locations/{locationName}/virtualMachineSkus" - } - - @distributed_trace - def list_supported_cloud_service_skus( - self, location_name: str, maxresults: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.SupportedSku"]: - """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. Required. - :type location_name: str - :param maxresults: The maximum number of items to return in the response. Default value is - None. - :type maxresults: int - :param filter: OData filter expression. Valid properties for filtering are "familyName". - Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SupportedSku or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.SupportedSku] :raises ~azure.core.exceptions.HttpResponseError: @@ -237,7 +136,7 @@ def list_supported_cloud_service_skus( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SupportedSkusResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -248,18 +147,16 @@ def list_supported_cloud_service_skus( def prepare_request(next_link=None): if not next_link: - request = build_list_supported_cloud_service_skus_request( + _request = build_list_supported_virtual_machine_skus_request( location_name=location_name, subscription_id=self._config.subscription_id, maxresults=maxresults, filter=filter, api_version=api_version, - 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) else: # make call to next link with the client's api-version @@ -271,13 +168,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SupportedSkusResult", pipeline_response) @@ -287,11 +183,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -303,10 +199,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_supported_cloud_service_skus.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Batch/locations/{locationName}/cloudServiceSkus" - } - @overload async def check_name_availability( self, @@ -325,7 +217,6 @@ async def check_name_availability( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.batch.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -333,18 +224,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, location_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, location_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks whether the Batch account name is available in the specified region. :param location_name: The desired region for the name check. Required. :type location_name: str :param parameters: Properties needed to check the availability of a name. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.batch.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -352,24 +242,20 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, location_name: str, parameters: Union[_models.CheckNameAvailabilityParameters, IO], **kwargs: Any + self, location_name: str, parameters: Union[_models.CheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks whether the Batch account name is available in the specified region. :param location_name: The desired region for the name check. Required. :type location_name: str :param parameters: Properties needed to check the availability of a name. Is either a - CheckNameAvailabilityParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.batch.models.CheckNameAvailabilityParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + CheckNameAvailabilityParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.batch.models.CheckNameAvailabilityParameters or IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.batch.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -392,23 +278,21 @@ async def check_name_availability( else: _json = self._serialize.body(parameters, "CheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( location_name=location_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -417,13 +301,9 @@ async def check_name_availability( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Batch/locations/{locationName}/checkNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_network_security_perimeter_operations.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_network_security_perimeter_operations.py new file mode 100644 index 000000000000..3470186e0988 --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/aio/operations/_network_security_perimeter_operations.py @@ -0,0 +1,340 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, Optional, Type, TypeVar, Union, cast +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._network_security_perimeter_operations import ( + build_get_configuration_request, + build_list_configurations_request, + build_reconcile_configuration_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class NetworkSecurityPerimeterOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.batch.aio.BatchManagementClient`'s + :attr:`network_security_perimeter` attribute. + """ + + models = _models + + 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_configurations( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.NetworkSecurityPerimeterConfiguration"]: + """Lists all of the NSP configurations in the specified account. + + :param resource_group_name: The name of the resource group that contains the Batch account. + Required. + :type resource_group_name: str + :param account_name: The name of the Batch account. Required. + :type account_name: str + :return: An iterator like instance of either NetworkSecurityPerimeterConfiguration or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.NetworkSecurityPerimeterConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NetworkSecurityPerimeterConfigurationListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_configurations_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("NetworkSecurityPerimeterConfigurationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_configuration( + self, + resource_group_name: str, + account_name: str, + network_security_perimeter_configuration_name: str, + **kwargs: Any + ) -> _models.NetworkSecurityPerimeterConfiguration: + """Gets information about the specified NSP configuration. + + :param resource_group_name: The name of the resource group that contains the Batch account. + Required. + :type resource_group_name: str + :param account_name: The name of the Batch account. Required. + :type account_name: str + :param network_security_perimeter_configuration_name: The name for Network Security Perimeter + configuration. Required. + :type network_security_perimeter_configuration_name: str + :return: NetworkSecurityPerimeterConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.batch.models.NetworkSecurityPerimeterConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NetworkSecurityPerimeterConfiguration] = kwargs.pop("cls", None) + + _request = build_get_configuration_request( + resource_group_name=resource_group_name, + account_name=account_name, + network_security_perimeter_configuration_name=network_security_perimeter_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NetworkSecurityPerimeterConfiguration", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _reconcile_configuration_initial( + self, + resource_group_name: str, + account_name: str, + network_security_perimeter_configuration_name: str, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_reconcile_configuration_request( + resource_group_name=resource_group_name, + account_name=account_name, + network_security_perimeter_configuration_name=network_security_perimeter_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_reconcile_configuration( + self, + resource_group_name: str, + account_name: str, + network_security_perimeter_configuration_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Reconciles the specified NSP configuration. + + :param resource_group_name: The name of the resource group that contains the Batch account. + Required. + :type resource_group_name: str + :param account_name: The name of the Batch account. Required. + :type account_name: str + :param network_security_perimeter_configuration_name: The name for Network Security Perimeter + configuration. Required. + :type network_security_perimeter_configuration_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._reconcile_configuration_initial( + resource_group_name=resource_group_name, + account_name=account_name, + network_security_perimeter_configuration_name=network_security_perimeter_configuration_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 a5cedd2ba031..70847053dc83 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +59,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists available operations for the Microsoft.Batch provider. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -67,7 +69,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -78,14 +80,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) else: # make call to next link with the client's api-version @@ -97,13 +97,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -113,11 +112,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -128,5 +127,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Batch/operations"} 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 bb05c3c5cae9..dbf5c93b009e 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._pool_operations import ( build_create_request, build_delete_request, @@ -41,6 +42,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -102,7 +107,6 @@ def list_by_batch_account( properties/scaleSettings/autoScale properties/scaleSettings/fixedScale. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Pool or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.Pool] :raises ~azure.core.exceptions.HttpResponseError: @@ -113,7 +117,7 @@ def list_by_batch_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ListPoolsResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -124,7 +128,7 @@ def list_by_batch_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_batch_account_request( + _request = build_list_by_batch_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -132,12 +136,10 @@ def prepare_request(next_link=None): select=select, filter=filter, api_version=api_version, - 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) else: # make call to next link with the client's api-version @@ -149,13 +151,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListPoolsResult", pipeline_response) @@ -165,11 +166,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -181,10 +182,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_batch_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/pools" - } - @overload async def create( self, @@ -219,7 +216,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Pool or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Pool :raises ~azure.core.exceptions.HttpResponseError: @@ -231,7 +227,7 @@ async def create( resource_group_name: str, account_name: str, pool_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -248,7 +244,7 @@ async def create( :param pool_name: The pool name. This must be unique within the account. Required. :type pool_name: str :param parameters: Additional parameters for pool creation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The entity state (ETag) version of the pool to update. A value of "*" can be used to apply the operation only if the pool already exists. If omitted, this operation will always be applied. Default value is None. @@ -259,7 +255,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Pool or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Pool :raises ~azure.core.exceptions.HttpResponseError: @@ -271,7 +266,7 @@ async def create( resource_group_name: str, account_name: str, pool_name: str, - parameters: Union[_models.Pool, IO], + parameters: Union[_models.Pool, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -285,9 +280,9 @@ async def create( :type account_name: str :param pool_name: The pool name. This must be unique within the account. Required. :type pool_name: str - :param parameters: Additional parameters for pool creation. Is either a Pool type or a IO type. - Required. - :type parameters: ~azure.mgmt.batch.models.Pool or IO + :param parameters: Additional parameters for pool creation. Is either a Pool type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.batch.models.Pool or IO[bytes] :param if_match: The entity state (ETag) version of the pool to update. A value of "*" can be used to apply the operation only if the pool already exists. If omitted, this operation will always be applied. Default value is None. @@ -295,15 +290,11 @@ async def create( :param if_none_match: Set to '*' to allow a new pool to be created, but to prevent updating an existing pool. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Pool or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Pool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -326,7 +317,7 @@ async def create( else: _json = self._serialize.body(parameters, "Pool") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -337,16 +328,14 @@ async def create( content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,16 +347,12 @@ async def create( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Pool", pipeline_response) + deserialized = self._deserialize("Pool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/pools/{poolName}" - } + return deserialized # type: ignore @overload async def update( @@ -399,7 +384,6 @@ async def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Pool or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Pool :raises ~azure.core.exceptions.HttpResponseError: @@ -411,7 +395,7 @@ async def update( resource_group_name: str, account_name: str, pool_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -428,14 +412,13 @@ async def update( :type pool_name: str :param parameters: Pool properties that should be updated. Properties that are supplied will be updated, any property not supplied will be unchanged. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The entity state (ETag) version of the pool to update. This value can be omitted or set to "*" to apply the operation unconditionally. Default value is None. :type if_match: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Pool or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Pool :raises ~azure.core.exceptions.HttpResponseError: @@ -447,7 +430,7 @@ async def update( resource_group_name: str, account_name: str, pool_name: str, - parameters: Union[_models.Pool, IO], + parameters: Union[_models.Pool, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> _models.Pool: @@ -461,21 +444,17 @@ async def update( :param pool_name: The pool name. This must be unique within the account. Required. :type pool_name: str :param parameters: Pool properties that should be updated. Properties that are supplied will be - updated, any property not supplied will be unchanged. Is either a Pool type or a IO type. - Required. - :type parameters: ~azure.mgmt.batch.models.Pool or IO + updated, any property not supplied will be unchanged. Is either a Pool type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.batch.models.Pool or IO[bytes] :param if_match: The entity state (ETag) version of the pool to update. This value can be omitted or set to "*" to apply the operation unconditionally. Default value is None. :type if_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Pool or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Pool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -498,7 +477,7 @@ async def update( else: _json = self._serialize.body(parameters, "Pool") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -508,16 +487,14 @@ async def update( content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -529,21 +506,17 @@ async def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Pool", pipeline_response) + deserialized = self._deserialize("Pool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/pools/{poolName}" - } + return deserialized # type: ignore - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, account_name: str, pool_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -555,29 +528,32 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -586,12 +562,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/pools/{poolName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -606,14 +582,6 @@ async def begin_delete( :type account_name: str :param pool_name: The pool name. This must be unique within the account. Required. :type pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -627,7 +595,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -637,11 +605,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -652,17 +621,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/pools/{poolName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get(self, resource_group_name: str, account_name: str, pool_name: str, **kwargs: Any) -> _models.Pool: @@ -675,12 +640,11 @@ async def get(self, resource_group_name: str, account_name: str, pool_name: str, :type account_name: str :param pool_name: The pool name. This must be unique within the account. Required. :type pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Pool or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Pool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -694,22 +658,20 @@ async def get(self, resource_group_name: str, account_name: str, pool_name: str, api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Pool] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -721,16 +683,12 @@ async def get(self, resource_group_name: str, account_name: str, pool_name: str, response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Pool", pipeline_response) + deserialized = self._deserialize("Pool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/pools/{poolName}" - } + return deserialized # type: ignore @distributed_trace_async async def disable_auto_scale( @@ -745,12 +703,11 @@ async def disable_auto_scale( :type account_name: str :param pool_name: The pool name. This must be unique within the account. Required. :type pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Pool or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Pool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -764,22 +721,20 @@ async def disable_auto_scale( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Pool] = kwargs.pop("cls", None) - request = build_disable_auto_scale_request( + _request = build_disable_auto_scale_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -791,16 +746,12 @@ async def disable_auto_scale( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Pool", pipeline_response) + deserialized = self._deserialize("Pool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - disable_auto_scale.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/pools/{poolName}/disableAutoScale" - } + return deserialized # type: ignore @distributed_trace_async async def stop_resize( @@ -822,12 +773,11 @@ async def stop_resize( :type account_name: str :param pool_name: The pool name. This must be unique within the account. Required. :type pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Pool or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Pool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -841,22 +791,20 @@ async def stop_resize( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Pool] = kwargs.pop("cls", None) - request = build_stop_resize_request( + _request = build_stop_resize_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -868,13 +816,9 @@ async def stop_resize( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Pool", pipeline_response) + deserialized = self._deserialize("Pool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - stop_resize.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/pools/{poolName}/stopResize" - } + return deserialized # type: ignore 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 a5edb533b068..b412146c0669 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._private_endpoint_connection_operations import ( build_delete_request, build_get_request, @@ -38,6 +39,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -75,7 +80,6 @@ def list_by_batch_account( :param maxresults: The maximum number of items to return in the response. Default value is None. :type maxresults: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -88,7 +92,7 @@ def list_by_batch_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ListPrivateEndpointConnectionsResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -99,18 +103,16 @@ def list_by_batch_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_batch_account_request( + _request = build_list_by_batch_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxresults=maxresults, api_version=api_version, - 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) else: # make call to next link with the client's api-version @@ -122,13 +124,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListPrivateEndpointConnectionsResult", pipeline_response) @@ -138,11 +139,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -154,10 +155,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_batch_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -172,12 +169,11 @@ async def get( :param private_endpoint_connection_name: The private endpoint connection name. This must be unique within the account. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.batch.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -191,22 +187,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -215,27 +209,23 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore async def _update_initial( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.PrivateEndpointConnection]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -248,7 +238,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -258,7 +248,7 @@ async def _update_initial( else: _json = self._serialize.body(parameters, "PrivateEndpointConnection") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -268,41 +258,38 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -336,14 +323,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.batch.models.PrivateEndpointConnection] @@ -356,7 +335,7 @@ async def begin_update( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -374,7 +353,7 @@ async def begin_update( :type private_endpoint_connection_name: str :param parameters: PrivateEndpointConnection properties that should be updated. Properties that are supplied will be updated, any property not supplied will be unchanged. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The state (ETag) version of the private endpoint connection to update. This value can be omitted or set to "*" to apply the operation unconditionally. Default value is None. @@ -382,14 +361,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.batch.models.PrivateEndpointConnection] @@ -402,7 +373,7 @@ async def begin_update( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: @@ -418,23 +389,12 @@ async def begin_update( :type private_endpoint_connection_name: str :param parameters: PrivateEndpointConnection properties that should be updated. Properties that are supplied will be updated, any property not supplied will be unchanged. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type parameters: ~azure.mgmt.batch.models.PrivateEndpointConnection or IO + PrivateEndpointConnection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.batch.models.PrivateEndpointConnection or IO[bytes] :param if_match: The state (ETag) version of the private endpoint connection to update. This value can be omitted or set to "*" to apply the operation unconditionally. Default value is None. :type if_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.batch.models.PrivateEndpointConnection] @@ -463,12 +423,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -481,22 +442,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return AsyncLROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -508,29 +467,32 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -539,12 +501,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -560,14 +522,6 @@ async def begin_delete( :param private_endpoint_connection_name: The private endpoint connection name. This must be unique within the account. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -581,7 +535,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -591,11 +545,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -607,14 +562,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 08f9608a44cb..717ff683c703 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._private_link_resource_operations import build_get_request, build_list_by_batch_account_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -67,7 +70,6 @@ def list_by_batch_account( :param maxresults: The maximum number of items to return in the response. Default value is None. :type maxresults: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.batch.models.PrivateLinkResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -78,7 +80,7 @@ def list_by_batch_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ListPrivateLinkResourcesResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,18 +91,16 @@ def list_by_batch_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_batch_account_request( + _request = build_list_by_batch_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxresults=maxresults, api_version=api_version, - 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) else: # make call to next link with the client's api-version @@ -112,13 +112,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListPrivateLinkResourcesResult", pipeline_response) @@ -128,11 +127,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -144,10 +143,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_batch_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/privateLinkResources" - } - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, private_link_resource_name: str, **kwargs: Any @@ -162,12 +157,11 @@ async def get( :param private_link_resource_name: The private link resource name. This must be unique within the account. Required. :type private_link_resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.batch.models.PrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -181,22 +175,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_link_resource_name=private_link_resource_name, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -205,13 +197,9 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateLinkResource", pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/privateLinkResources/{privateLinkResourceName}" - } + return deserialized # type: ignore 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 b0c78856b0b6..b5e36793db93 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 @@ -6,6 +6,9 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from ._models_py3 import AccessRule +from ._models_py3 import AccessRuleProperties +from ._models_py3 import AccessRulePropertiesSubscriptionsItem from ._models_py3 import ActivateApplicationPackageParameters from ._models_py3 import Application from ._models_py3 import ApplicationPackage @@ -19,6 +22,8 @@ from ._models_py3 import AutomaticOSUpgradePolicy from ._models_py3 import AzureBlobFileSystemConfiguration from ._models_py3 import AzureFileShareConfiguration +from ._models_py3 import AzureProxyResource +from ._models_py3 import AzureResource from ._models_py3 import BatchAccount from ._models_py3 import BatchAccountCreateParameters from ._models_py3 import BatchAccountIdentity @@ -38,9 +43,9 @@ from ._models_py3 import CheckNameAvailabilityParameters from ._models_py3 import CheckNameAvailabilityResult from ._models_py3 import CloudErrorBody -from ._models_py3 import CloudServiceConfiguration from ._models_py3 import ComputeNodeIdentityReference from ._models_py3 import ContainerConfiguration +from ._models_py3 import ContainerHostBatchBindMountEntry from ._models_py3 import ContainerRegistry from ._models_py3 import DataDisk from ._models_py3 import DeleteCertificateError @@ -54,6 +59,9 @@ from ._models_py3 import EndpointDependency from ._models_py3 import EndpointDetail from ._models_py3 import EnvironmentSetting +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse from ._models_py3 import FixedScaleSettings from ._models_py3 import IPRule from ._models_py3 import ImageReference @@ -74,6 +82,11 @@ from ._models_py3 import NetworkConfiguration from ._models_py3 import NetworkProfile from ._models_py3 import NetworkSecurityGroupRule +from ._models_py3 import NetworkSecurityPerimeter +from ._models_py3 import NetworkSecurityPerimeterConfiguration +from ._models_py3 import NetworkSecurityPerimeterConfigurationListResult +from ._models_py3 import NetworkSecurityPerimeterConfigurationProperties +from ._models_py3 import NetworkSecurityProfile from ._models_py3 import NodePlacementConfiguration from ._models_py3 import OSDisk from ._models_py3 import Operation @@ -87,11 +100,14 @@ from ._models_py3 import PrivateEndpointConnection from ._models_py3 import PrivateLinkResource from ._models_py3 import PrivateLinkServiceConnectionState +from ._models_py3 import ProvisioningIssue +from ._models_py3 import ProvisioningIssueProperties from ._models_py3 import ProxyResource from ._models_py3 import PublicIPAddressConfiguration from ._models_py3 import ResizeError from ._models_py3 import ResizeOperationStatus from ._models_py3 import Resource +from ._models_py3 import ResourceAssociation from ._models_py3 import ResourceFile from ._models_py3 import RollingUpgradePolicy from ._models_py3 import ScaleSettings @@ -101,6 +117,7 @@ from ._models_py3 import StartTask from ._models_py3 import SupportedSku from ._models_py3 import SupportedSkusResult +from ._models_py3 import SystemData from ._models_py3 import TaskContainerSettings from ._models_py3 import TaskSchedulingPolicy from ._models_py3 import UefiSettings @@ -108,12 +125,14 @@ from ._models_py3 import UserAccount from ._models_py3 import UserAssignedIdentities from ._models_py3 import UserIdentity +from ._models_py3 import VMDiskSecurityProfile from ._models_py3 import VMExtension from ._models_py3 import VirtualMachineConfiguration from ._models_py3 import VirtualMachineFamilyCoreQuota from ._models_py3 import WindowsConfiguration from ._models_py3 import WindowsUserConfiguration +from ._batch_management_client_enums import AccessRuleDirection from ._batch_management_client_enums import AccountKeyType from ._batch_management_client_enums import AllocationState from ._batch_management_client_enums import AuthenticationMode @@ -126,8 +145,10 @@ from ._batch_management_client_enums import CertificateVisibility from ._batch_management_client_enums import ComputeNodeDeallocationOption from ._batch_management_client_enums import ComputeNodeFillType +from ._batch_management_client_enums import ContainerHostDataPath from ._batch_management_client_enums import ContainerType from ._batch_management_client_enums import ContainerWorkingDirectory +from ._batch_management_client_enums import CreatedByType from ._batch_management_client_enums import DiskEncryptionTarget from ._batch_management_client_enums import DynamicVNetAssignmentScope from ._batch_management_client_enums import ElevationLevel @@ -135,10 +156,12 @@ from ._batch_management_client_enums import IPAddressProvisioningType from ._batch_management_client_enums import InboundEndpointProtocol from ._batch_management_client_enums import InterNodeCommunicationState +from ._batch_management_client_enums import IssueType from ._batch_management_client_enums import KeySource from ._batch_management_client_enums import LoginMode from ._batch_management_client_enums import NameAvailabilityReason from ._batch_management_client_enums import NetworkSecurityGroupRuleAccess +from ._batch_management_client_enums import NetworkSecurityPerimeterConfigurationProvisioningState from ._batch_management_client_enums import NodeCommunicationMode from ._batch_management_client_enums import NodePlacementPolicyType from ._batch_management_client_enums import PackageState @@ -149,7 +172,11 @@ from ._batch_management_client_enums import PrivateLinkServiceConnectionStatus from ._batch_management_client_enums import ProvisioningState from ._batch_management_client_enums import PublicNetworkAccessType +from ._batch_management_client_enums import ResourceAssociationAccessMode from ._batch_management_client_enums import ResourceIdentityType +from ._batch_management_client_enums import SecurityEncryptionTypes +from ._batch_management_client_enums import SecurityTypes +from ._batch_management_client_enums import Severity from ._batch_management_client_enums import StorageAccountType from ._batch_management_client_enums import UpgradeMode from ._patch import __all__ as _patch_all @@ -157,6 +184,9 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ + "AccessRule", + "AccessRuleProperties", + "AccessRulePropertiesSubscriptionsItem", "ActivateApplicationPackageParameters", "Application", "ApplicationPackage", @@ -170,6 +200,8 @@ "AutomaticOSUpgradePolicy", "AzureBlobFileSystemConfiguration", "AzureFileShareConfiguration", + "AzureProxyResource", + "AzureResource", "BatchAccount", "BatchAccountCreateParameters", "BatchAccountIdentity", @@ -189,9 +221,9 @@ "CheckNameAvailabilityParameters", "CheckNameAvailabilityResult", "CloudErrorBody", - "CloudServiceConfiguration", "ComputeNodeIdentityReference", "ContainerConfiguration", + "ContainerHostBatchBindMountEntry", "ContainerRegistry", "DataDisk", "DeleteCertificateError", @@ -205,6 +237,9 @@ "EndpointDependency", "EndpointDetail", "EnvironmentSetting", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", "FixedScaleSettings", "IPRule", "ImageReference", @@ -225,6 +260,11 @@ "NetworkConfiguration", "NetworkProfile", "NetworkSecurityGroupRule", + "NetworkSecurityPerimeter", + "NetworkSecurityPerimeterConfiguration", + "NetworkSecurityPerimeterConfigurationListResult", + "NetworkSecurityPerimeterConfigurationProperties", + "NetworkSecurityProfile", "NodePlacementConfiguration", "OSDisk", "Operation", @@ -238,11 +278,14 @@ "PrivateEndpointConnection", "PrivateLinkResource", "PrivateLinkServiceConnectionState", + "ProvisioningIssue", + "ProvisioningIssueProperties", "ProxyResource", "PublicIPAddressConfiguration", "ResizeError", "ResizeOperationStatus", "Resource", + "ResourceAssociation", "ResourceFile", "RollingUpgradePolicy", "ScaleSettings", @@ -252,6 +295,7 @@ "StartTask", "SupportedSku", "SupportedSkusResult", + "SystemData", "TaskContainerSettings", "TaskSchedulingPolicy", "UefiSettings", @@ -259,11 +303,13 @@ "UserAccount", "UserAssignedIdentities", "UserIdentity", + "VMDiskSecurityProfile", "VMExtension", "VirtualMachineConfiguration", "VirtualMachineFamilyCoreQuota", "WindowsConfiguration", "WindowsUserConfiguration", + "AccessRuleDirection", "AccountKeyType", "AllocationState", "AuthenticationMode", @@ -276,8 +322,10 @@ "CertificateVisibility", "ComputeNodeDeallocationOption", "ComputeNodeFillType", + "ContainerHostDataPath", "ContainerType", "ContainerWorkingDirectory", + "CreatedByType", "DiskEncryptionTarget", "DynamicVNetAssignmentScope", "ElevationLevel", @@ -285,10 +333,12 @@ "IPAddressProvisioningType", "InboundEndpointProtocol", "InterNodeCommunicationState", + "IssueType", "KeySource", "LoginMode", "NameAvailabilityReason", "NetworkSecurityGroupRuleAccess", + "NetworkSecurityPerimeterConfigurationProvisioningState", "NodeCommunicationMode", "NodePlacementPolicyType", "PackageState", @@ -299,7 +349,11 @@ "PrivateLinkServiceConnectionStatus", "ProvisioningState", "PublicNetworkAccessType", + "ResourceAssociationAccessMode", "ResourceIdentityType", + "SecurityEncryptionTypes", + "SecurityTypes", + "Severity", "StorageAccountType", "UpgradeMode", ] 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 5594f40fbe2e..5741d1b9178d 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 @@ -10,6 +10,15 @@ from azure.core import CaseInsensitiveEnumMeta +class AccessRuleDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Direction of Access Rule.""" + + INBOUND = "Inbound" + """Applies to inbound network traffic to the secured resources.""" + OUTBOUND = "Outbound" + """Applies to outbound network traffic from the secured resources""" + + class AccountKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of account key to regenerate.""" @@ -24,13 +33,13 @@ class AllocationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): STEADY = "Steady" """The pool is not resizing. There are no changes to the number of nodes in the pool in progress. - #: A pool enters this state when it is created and when no operations are being performed on the - #: pool to change the number of nodes.""" + A pool enters this state when it is created and when no operations are being performed on the + pool to change the number of nodes.""" RESIZING = "Resizing" """The pool is resizing; that is, compute nodes are being added to or removed from the pool.""" STOPPING = "Stopping" """The pool was resizing, but the user has requested that the resize be stopped, but the stop - #: request has not yet been completed.""" + request has not yet been completed.""" class AuthenticationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -51,7 +60,7 @@ class AutoStorageAuthenticationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta """The Batch service will authenticate requests to auto-storage using storage account keys.""" BATCH_ACCOUNT_MANAGED_IDENTITY = "BatchAccountManagedIdentity" """The Batch service will authenticate requests to auto-storage using the managed identity - #: assigned to the Batch account.""" + assigned to the Batch account.""" class AutoUserScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -65,7 +74,7 @@ class AutoUserScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies that the service should create a new user for the task.""" POOL = "Pool" """Specifies that the task runs as the common auto user account which is created on every node in - #: a pool.""" + a pool.""" class CachingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -95,24 +104,23 @@ class CertificateProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta) """The certificate is available for use in pools.""" DELETING = "Deleting" """The user has requested that the certificate be deleted, but the delete operation has not yet - #: completed. You may not reference the certificate when creating or updating pools.""" + completed. You may not reference the certificate when creating or updating pools.""" FAILED = "Failed" """The user requested that the certificate be deleted, but there are pools that still have - #: references to the certificate, or it is still installed on one or more compute nodes. (The - #: latter can occur if the certificate has been removed from the pool, but the node has not yet - #: restarted. Nodes refresh their certificates only when they restart.) You may use the cancel - #: certificate delete operation to cancel the delete, or the delete certificate operation to retry - #: the delete.""" + references to the certificate, or it is still installed on one or more compute nodes. (The + latter can occur if the certificate has been removed from the pool, but the node has not yet + restarted. Nodes refresh their certificates only when they restart.) You may use the cancel + certificate delete operation to cancel the delete, or the delete certificate operation to retry + the delete.""" 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 - 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. + Windows compute nodes. For Linux compute nodes, the 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. """ CURRENT_USER = "CurrentUser" @@ -126,13 +134,13 @@ class CertificateVisibility(str, Enum, metaclass=CaseInsensitiveEnumMeta): START_TASK = "StartTask" """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 - #: visible to the Task as well.""" + that if AutoUser Scope is Pool for both the StartTask and a Task, this certificate will be + visible to the Task as well.""" TASK = "Task" """The certificate should be visible to the user accounts under which job tasks are run.""" REMOTE_USER = "RemoteUser" """The certificate should be visible to the user accounts under which users remotely access the - #: node.""" + node.""" class ComputeNodeDeallocationOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -142,17 +150,17 @@ class ComputeNodeDeallocationOption(str, Enum, metaclass=CaseInsensitiveEnumMeta REQUEUE = "Requeue" """Terminate running task processes and requeue the tasks. The tasks will run again when a node is - #: available. Remove nodes as soon as tasks have been terminated.""" + available. Remove nodes as soon as tasks have been terminated.""" TERMINATE = "Terminate" """Terminate running tasks. The tasks will be completed with failureInfo indicating that they were - #: terminated, and will not run again. Remove nodes as soon as tasks have been terminated.""" + terminated, and will not run again. Remove nodes as soon as tasks have been terminated.""" TASK_COMPLETION = "TaskCompletion" """Allow currently running tasks to complete. Schedule no new tasks while waiting. Remove nodes - #: when all tasks have completed.""" + when all tasks have completed.""" RETAINED_DATA = "RetainedData" """Allow currently running tasks to complete, then wait for all task data retention periods to - #: expire. Schedule no new tasks while waiting. Remove nodes when all task retention periods have - #: expired.""" + expire. Schedule no new tasks while waiting. Remove nodes when all task retention periods have + expired.""" class ComputeNodeFillType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -162,7 +170,24 @@ class ComputeNodeFillType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Tasks should be assigned evenly across all nodes in the pool.""" PACK = "Pack" """As many tasks as possible (taskSlotsPerNode) should be assigned to each node in the pool before - #: any tasks are assigned to the next node in the pool.""" + any tasks are assigned to the next node in the pool.""" + + +class ContainerHostDataPath(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The paths which will be mounted to container task's container.""" + + SHARED = "Shared" + """The path for multi-instances task to shared their files.""" + STARTUP = "Startup" + """The path for start task.""" + VFS_MOUNTS = "VfsMounts" + """The path contains all virtual file systems are mounted on this node.""" + TASK = "Task" + """The task path.""" + JOB_PREP = "JobPrep" + """The job-prep task path.""" + APPLICATIONS = "Applications" + """The applications path.""" class ContainerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -181,10 +206,19 @@ class ContainerWorkingDirectory(str, Enum, metaclass=CaseInsensitiveEnumMeta): TASK_WORKING_DIRECTORY = "TaskWorkingDirectory" """Use the standard Batch service task working directory, which will contain the Task resource - #: files populated by Batch.""" + files populated by Batch.""" CONTAINER_IMAGE_DEFAULT = "ContainerImageDefault" """Using container image defined working directory. Beware that this directory will not contain - #: the resource files downloaded by Batch.""" + the resource files downloaded by Batch.""" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" class DiskEncryptionTarget(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -194,7 +228,7 @@ class DiskEncryptionTarget(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The OS Disk on the compute node is encrypted.""" TEMPORARY_DISK = "TemporaryDisk" """The temporary disk on the compute node is encrypted. On Linux this encryption applies to other - #: partitions (such as those on mounted data disks) when encryption occurs at boot time.""" + partitions (such as those on mounted data disks) when encryption occurs at boot time.""" class DynamicVNetAssignmentScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -204,7 +238,7 @@ class DynamicVNetAssignmentScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): """No dynamic VNet assignment is enabled.""" JOB = "job" """Dynamic VNet assignment is done per-job. If this value is set, the network configuration subnet - #: ID must also be set. This feature requires approval before use, please contact support""" + ID must also be set. This feature requires approval before use, please contact support""" class ElevationLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -251,13 +285,29 @@ class IPAddressProvisioningType(str, Enum, metaclass=CaseInsensitiveEnumMeta): BATCH_MANAGED = "BatchManaged" """A public IP will be created and managed by Batch. There may be multiple public IPs depending on - #: the size of the Pool.""" + the size of the Pool.""" USER_MANAGED = "UserManaged" """Public IPs are provided by the user and will be used to provision the Compute Nodes.""" NO_PUBLIC_IP_ADDRESSES = "NoPublicIPAddresses" """No public IP Address will be created for the Compute Nodes in the Pool.""" +class IssueType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of issue.""" + + UNKNOWN = "Unknown" + """Unknown issue type""" + CONFIGURATION_PROPAGATION_FAILURE = "ConfigurationPropagationFailure" + """An error occurred while applying the network security perimeter (NSP) configuration.""" + MISSING_PERIMETER_CONFIGURATION = "MissingPerimeterConfiguration" + """A network connectivity issue is happening on the resource which could be addressed either by + adding new resources to the network security perimeter (NSP) or by modifying access rules.""" + MISSING_IDENTITY_CONFIGURATION = "MissingIdentityConfiguration" + """An managed identity hasn't been associated with the resource. The resource will still be able + to validate inbound traffic from the network security perimeter (NSP) or matching inbound + access rules, but it won't be able to perform outbound access as a member of the NSP.""" + + class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of the key source.""" @@ -265,22 +315,20 @@ class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Batch creates and manages the encryption keys used to protect the account data.""" MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" """The encryption keys used to protect the account data are stored in an external key vault. If - #: this is set then the Batch Account identity must be set to ``SystemAssigned`` and a valid Key - #: Identifier must also be supplied under the keyVaultProperties.""" + this is set then the Batch Account identity must be set to ``SystemAssigned`` and a valid Key + Identifier must also be supplied under the keyVaultProperties.""" 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. - """ + """Specifies login mode for the user. The default value is Interactive.""" BATCH = "Batch" """The LOGON32_LOGON_BATCH Win32 login mode. The batch login mode is recommended for long running - #: parallel processes.""" + parallel processes.""" INTERACTIVE = "Interactive" """The LOGON32_LOGON_INTERACTIVE Win32 login mode. Some applications require having permissions - #: associated with the interactive login mode. If this is the case for an application used in your - #: task, then this option is recommended.""" + associated with the interactive login mode. If this is the case for an application used in your + task, then this option is recommended.""" class NameAvailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -303,6 +351,20 @@ class NetworkSecurityGroupRuleAccess(str, Enum, metaclass=CaseInsensitiveEnumMet """Deny access.""" +class NetworkSecurityPerimeterConfigurationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of a network security perimeter configuration that is being created or + updated. + """ + + SUCCEEDED = "Succeeded" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + ACCEPTED = "Accepted" + FAILED = "Failed" + CANCELED = "Canceled" + + class NodeCommunicationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Determines how a pool communicates with the Batch service.""" @@ -310,11 +372,11 @@ class NodeCommunicationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The node communication mode is automatically set by the Batch service.""" CLASSIC = "Classic" """Nodes using the Classic communication mode require inbound TCP communication on ports 29876 and - #: 29877 from the "BatchNodeManagement.{region}" service tag and outbound TCP communication on - #: port 443 to the "Storage.region" and "BatchNodeManagement.{region}" service tags.""" + 29877 from the "BatchNodeManagement.{region}" service tag and outbound TCP communication on + port 443 to the "Storage.region" and "BatchNodeManagement.{region}" service tags.""" SIMPLIFIED = "Simplified" """Nodes using the Simplified communication mode require outbound TCP communication on port 443 to - #: the "BatchNodeManagement.{region}" service tag. No open inbound ports are required.""" + the "BatchNodeManagement.{region}" service tag. No open inbound ports are required.""" class NodePlacementPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -351,7 +413,7 @@ class PoolIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Batch pool has user assigned identities with it.""" NONE = "None" """Batch pool has no identity associated with it. Setting ``None`` in update pool will remove - #: existing identities.""" + existing identities.""" class PoolProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -361,7 +423,7 @@ class PoolProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The pool is available to run tasks subject to the availability of compute nodes.""" DELETING = "Deleting" """The user has requested that the pool be deleted, but the delete operation has not yet - #: completed.""" + completed.""" class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -371,14 +433,14 @@ class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsens """The connection is creating.""" UPDATING = "Updating" """The user has requested that the connection status be updated, but the update operation has not - #: yet completed. You may not reference the connection when connecting the Batch account.""" + yet completed. You may not reference the connection when connecting the Batch account.""" DELETING = "Deleting" """The connection is deleting.""" SUCCEEDED = "Succeeded" """The connection status is final and is ready for use if Status is Approved.""" FAILED = "Failed" """The user requested that the connection be updated and it failed. You may retry the update - #: operation.""" + operation.""" CANCELLED = "Cancelled" """The user has cancelled the connection creation.""" @@ -420,7 +482,20 @@ class PublicNetworkAccessType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Enables connectivity to Azure Batch through public DNS.""" DISABLED = "Disabled" """Disables public connectivity and enables private connectivity to Azure Batch Service through - #: private endpoint resource.""" + private endpoint resource.""" + SECURED_BY_PERIMETER = "SecuredByPerimeter" + """Secures connectivity to Azure Batch through NSP configuration.""" + + +class ResourceAssociationAccessMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Access mode of the resource association.""" + + ENFORCED = "Enforced" + """Enforced access mode - traffic to the resource that failed access checks is blocked""" + LEARNING = "Learning" + """Learning access mode - traffic to the resource is enabled for analysis but not blocked""" + AUDIT = "Audit" + """Audit access mode - traffic to the resource that fails access checks is logged but not blocked""" class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -432,7 +507,39 @@ class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Batch account has user assigned identities with it.""" NONE = "None" """Batch account has no identity associated with it. Setting ``None`` in update account will - #: remove existing identities.""" + remove existing identities.""" + + +class SecurityEncryptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the EncryptionType of the managed disk. It is set to VMGuestStateOnly for encryption + of just the VMGuestState blob, and NonPersistedTPM for not persisting firmware state in the + VMGuestState blob. **Note**\\ : It can be set for only Confidential VMs and required when using + Confidential VMs. + """ + + NON_PERSISTED_TPM = "NonPersistedTPM" + VM_GUEST_STATE_ONLY = "VMGuestStateOnly" + + +class SecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the SecurityType of the virtual machine. It has to be set to any specified value to + enable UefiSettings. + """ + + TRUSTED_LAUNCH = "trustedLaunch" + """Trusted launch protects against advanced and persistent attack techniques.""" + CONFIDENTIAL_VM = "confidentialVM" + """Azure confidential computing offers confidential VMs are for tenants with high security and + confidentiality requirements. These VMs provide a strong, hardware-enforced boundary to help + meet your security needs. You can use confidential VMs for migrations without making changes to + your code, with the platform protecting your VM's state from being read or modified.""" + + +class Severity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the issue.""" + + WARNING = "Warning" + ERROR = "Error" class StorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -459,8 +566,8 @@ class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """All virtual machines in the scale set are automatically updated at the same time.""" MANUAL = "manual" """You control the application of updates to virtual machines in the scale set. You do this by - #: using the manualUpgrade action.""" + using the manualUpgrade action.""" ROLLING = "rolling" """The existing instances in a scale set are brought down in batches to be upgraded. Once the - #: upgraded batch is complete, the instances will begin taking traffic again and the next batch - #: will begin. This continues until all instances brought up-to-date.""" + upgraded batch is complete, the instances will begin taking traffic again and the next batch + will begin. This continues until all instances brought up-to-date.""" 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 43a24799e6e6..acc1693c921b 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 @@ -9,7 +9,7 @@ import datetime import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union from .. import _serialization @@ -17,10 +17,6 @@ from collections.abc import MutableMapping else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -28,10 +24,127 @@ JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +class AccessRule(_serialization.Model): + """Access rule in a network security perimeter configuration profile. + + :ivar name: Name of the access rule. + :vartype name: str + :ivar properties: Properties of Access Rule. + :vartype properties: ~azure.mgmt.batch.models.AccessRuleProperties + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "AccessRuleProperties"}, + } + + def __init__( + self, *, name: Optional[str] = None, properties: Optional["_models.AccessRuleProperties"] = None, **kwargs: Any + ) -> None: + """ + :keyword name: Name of the access rule. + :paramtype name: str + :keyword properties: Properties of Access Rule. + :paramtype properties: ~azure.mgmt.batch.models.AccessRuleProperties + """ + super().__init__(**kwargs) + self.name = name + self.properties = properties + + +class AccessRuleProperties(_serialization.Model): + """Properties of Access Rule. + + :ivar direction: Direction of Access Rule. Known values are: "Inbound" and "Outbound". + :vartype direction: str or ~azure.mgmt.batch.models.AccessRuleDirection + :ivar address_prefixes: Address prefixes in the CIDR format for inbound rules. + :vartype address_prefixes: list[str] + :ivar subscriptions: Subscriptions for inbound rules. + :vartype subscriptions: list[~azure.mgmt.batch.models.AccessRulePropertiesSubscriptionsItem] + :ivar network_security_perimeters: Network security perimeters for inbound rules. + :vartype network_security_perimeters: list[~azure.mgmt.batch.models.NetworkSecurityPerimeter] + :ivar fully_qualified_domain_names: Fully qualified domain names (FQDN) for outbound rules. + :vartype fully_qualified_domain_names: list[str] + :ivar email_addresses: Email addresses for outbound rules. + :vartype email_addresses: list[str] + :ivar phone_numbers: Phone numbers for outbound rules. + :vartype phone_numbers: list[str] + """ + + _attribute_map = { + "direction": {"key": "direction", "type": "str"}, + "address_prefixes": {"key": "addressPrefixes", "type": "[str]"}, + "subscriptions": {"key": "subscriptions", "type": "[AccessRulePropertiesSubscriptionsItem]"}, + "network_security_perimeters": {"key": "networkSecurityPerimeters", "type": "[NetworkSecurityPerimeter]"}, + "fully_qualified_domain_names": {"key": "fullyQualifiedDomainNames", "type": "[str]"}, + "email_addresses": {"key": "emailAddresses", "type": "[str]"}, + "phone_numbers": {"key": "phoneNumbers", "type": "[str]"}, + } + + def __init__( + self, + *, + direction: Optional[Union[str, "_models.AccessRuleDirection"]] = None, + address_prefixes: Optional[List[str]] = None, + subscriptions: Optional[List["_models.AccessRulePropertiesSubscriptionsItem"]] = None, + network_security_perimeters: Optional[List["_models.NetworkSecurityPerimeter"]] = None, + fully_qualified_domain_names: Optional[List[str]] = None, + email_addresses: Optional[List[str]] = None, + phone_numbers: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword direction: Direction of Access Rule. Known values are: "Inbound" and "Outbound". + :paramtype direction: str or ~azure.mgmt.batch.models.AccessRuleDirection + :keyword address_prefixes: Address prefixes in the CIDR format for inbound rules. + :paramtype address_prefixes: list[str] + :keyword subscriptions: Subscriptions for inbound rules. + :paramtype subscriptions: list[~azure.mgmt.batch.models.AccessRulePropertiesSubscriptionsItem] + :keyword network_security_perimeters: Network security perimeters for inbound rules. + :paramtype network_security_perimeters: list[~azure.mgmt.batch.models.NetworkSecurityPerimeter] + :keyword fully_qualified_domain_names: Fully qualified domain names (FQDN) for outbound rules. + :paramtype fully_qualified_domain_names: list[str] + :keyword email_addresses: Email addresses for outbound rules. + :paramtype email_addresses: list[str] + :keyword phone_numbers: Phone numbers for outbound rules. + :paramtype phone_numbers: list[str] + """ + super().__init__(**kwargs) + self.direction = direction + self.address_prefixes = address_prefixes + self.subscriptions = subscriptions + self.network_security_perimeters = network_security_perimeters + self.fully_qualified_domain_names = fully_qualified_domain_names + self.email_addresses = email_addresses + self.phone_numbers = phone_numbers + + +class AccessRulePropertiesSubscriptionsItem(_serialization.Model): + """Subscription identifiers. + + :ivar id: The fully qualified Azure resource ID of the subscription e.g. + ('/subscriptions/00000000-0000-0000-0000-000000000000'). + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: The fully qualified Azure resource ID of the subscription e.g. + ('/subscriptions/00000000-0000-0000-0000-000000000000'). + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + class ActivateApplicationPackageParameters(_serialization.Model): """Parameters for an activating an application package. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar format: The format of the application package binary file. Required. :vartype format: str @@ -54,7 +167,7 @@ def __init__(self, *, format: str, **kwargs: Any) -> None: self.format = format -class ProxyResource(_serialization.Model): +class AzureProxyResource(_serialization.Model): """A definition of an Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -67,6 +180,8 @@ class ProxyResource(_serialization.Model): :vartype type: str :ivar etag: The ETag of the resource, used for concurrency statements. :vartype etag: str + :ivar tags: The tags of the resource. + :vartype tags: dict[str, str] """ _validation = { @@ -81,18 +196,23 @@ class ProxyResource(_serialization.Model): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "etag": {"key": "etag", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: The tags of the resource. + :paramtype tags: dict[str, str] + """ super().__init__(**kwargs) self.id = None self.name = None self.type = None self.etag = None + self.tags = tags -class Application(ProxyResource): +class Application(AzureProxyResource): """Contains information about an application in a Batch account. Variables are only populated by the server, and will be ignored when sending a request. @@ -105,6 +225,8 @@ class Application(ProxyResource): :vartype type: str :ivar etag: The ETag of the resource, used for concurrency statements. :vartype etag: str + :ivar tags: The tags of the resource. + :vartype tags: dict[str, str] :ivar display_name: The display name for the application. :vartype display_name: str :ivar allow_updates: A value indicating whether packages within the application may be @@ -127,6 +249,7 @@ class Application(ProxyResource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "etag": {"key": "etag", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, "display_name": {"key": "properties.displayName", "type": "str"}, "allow_updates": {"key": "properties.allowUpdates", "type": "bool"}, "default_version": {"key": "properties.defaultVersion", "type": "str"}, @@ -135,12 +258,15 @@ class Application(ProxyResource): def __init__( self, *, + tags: Optional[Dict[str, str]] = None, display_name: Optional[str] = None, allow_updates: Optional[bool] = None, default_version: Optional[str] = None, **kwargs: Any ) -> None: """ + :keyword tags: The tags of the resource. + :paramtype tags: dict[str, str] :keyword display_name: The display name for the application. :paramtype display_name: str :keyword allow_updates: A value indicating whether packages within the application may be @@ -150,13 +276,13 @@ def __init__( specify a version. This property can only be set to the name of an existing package. :paramtype default_version: str """ - super().__init__(**kwargs) + super().__init__(tags=tags, **kwargs) self.display_name = display_name self.allow_updates = allow_updates self.default_version = default_version -class ApplicationPackage(ProxyResource): +class ApplicationPackage(AzureProxyResource): """An application package which represents a particular version of an application. Variables are only populated by the server, and will be ignored when sending a request. @@ -169,6 +295,8 @@ class ApplicationPackage(ProxyResource): :vartype type: str :ivar etag: The ETag of the resource, used for concurrency statements. :vartype etag: str + :ivar tags: The tags of the resource. + :vartype tags: dict[str, str] :ivar state: The current state of the application package. Known values are: "Pending" and "Active". :vartype state: str or ~azure.mgmt.batch.models.PackageState @@ -200,6 +328,7 @@ class ApplicationPackage(ProxyResource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "etag": {"key": "etag", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, "state": {"key": "properties.state", "type": "str"}, "format": {"key": "properties.format", "type": "str"}, "storage_url": {"key": "properties.storageUrl", "type": "str"}, @@ -207,9 +336,12 @@ class ApplicationPackage(ProxyResource): "last_activation_time": {"key": "properties.lastActivationTime", "type": "iso-8601"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: The tags of the resource. + :paramtype tags: dict[str, str] + """ + super().__init__(tags=tags, **kwargs) self.state = None self.format = None self.storage_url = None @@ -220,7 +352,7 @@ def __init__(self, **kwargs: Any) -> None: class ApplicationPackageReference(_serialization.Model): """Link to an application package inside the batch account. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The ID of the application package to install. This must be inside the same batch account as the pool. This can either be a reference to a specific version or the default @@ -322,7 +454,7 @@ def __init__( class AutoScaleRun(_serialization.Model): """The results and errors from an execution of a pool autoscale formula. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar evaluation_time: The time at which the autoscale formula was last evaluated. Required. :vartype evaluation_time: ~datetime.datetime @@ -369,7 +501,7 @@ def __init__( class AutoScaleRunError(_serialization.Model): """An error that occurred when autoscaling a pool. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. Required. @@ -414,7 +546,7 @@ def __init__( class AutoScaleSettings(_serialization.Model): """AutoScale settings for the pool. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar formula: A formula for the desired number of compute nodes in the pool. Required. :vartype formula: str @@ -448,7 +580,7 @@ def __init__( class AutoStorageBaseProperties(_serialization.Model): """The properties related to the auto-storage account. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar storage_account_id: The resource ID of the storage account to be used for auto-storage account. Required. @@ -500,7 +632,7 @@ def __init__( class AutoStorageProperties(AutoStorageBaseProperties): """Contains information about the auto-storage account associated with a Batch account. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar storage_account_id: The resource ID of the storage account to be used for auto-storage account. Required. @@ -605,7 +737,7 @@ def __init__( class AzureBlobFileSystemConfiguration(_serialization.Model): """Information used to connect to an Azure Storage Container using Blobfuse. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar account_name: The Azure Storage Account name. Required. :vartype account_name: str @@ -688,7 +820,7 @@ def __init__( class AzureFileShareConfiguration(_serialization.Model): """Information used to connect to an Azure Fileshare. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar account_name: The Azure Storage account name. Required. :vartype account_name: str @@ -750,7 +882,7 @@ def __init__( self.mount_options = mount_options -class Resource(_serialization.Model): +class AzureResource(_serialization.Model): """A definition of an Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -793,7 +925,7 @@ def __init__(self, **kwargs: Any) -> None: self.tags = None -class BatchAccount(Resource): # pylint: disable=too-many-instance-attributes +class BatchAccount(AzureResource): # pylint: disable=too-many-instance-attributes """Contains information about an Azure Batch account. Variables are only populated by the server, and will be ignored when sending a request. @@ -824,7 +956,7 @@ class BatchAccount(Resource): # pylint: disable=too-many-instance-attributes :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'. Known values - are: "Enabled" and "Disabled". + are: "Enabled", "Disabled", and "SecuredByPerimeter". :vartype public_network_access: str or ~azure.mgmt.batch.models.PublicNetworkAccessType :ivar network_profile: The network profile only takes effect when publicNetworkAccess is enabled. @@ -936,7 +1068,7 @@ def __init__( :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'. Known values - are: "Enabled" and "Disabled". + are: "Enabled", "Disabled", and "SecuredByPerimeter". :paramtype public_network_access: str or ~azure.mgmt.batch.models.PublicNetworkAccessType :keyword network_profile: The network profile only takes effect when publicNetworkAccess is enabled. @@ -966,7 +1098,7 @@ def __init__( class BatchAccountCreateParameters(_serialization.Model): """Parameters supplied to the Create operation. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar location: The region in which to create the account. Required. :vartype location: str @@ -985,7 +1117,7 @@ class BatchAccountCreateParameters(_serialization.Model): account. :vartype key_vault_reference: ~azure.mgmt.batch.models.KeyVaultReference :ivar public_network_access: If not specified, the default value is 'enabled'. Known values - are: "Enabled" and "Disabled". + are: "Enabled", "Disabled", and "SecuredByPerimeter". :vartype public_network_access: str or ~azure.mgmt.batch.models.PublicNetworkAccessType :ivar network_profile: The network profile only takes effect when publicNetworkAccess is enabled. @@ -1051,7 +1183,7 @@ def __init__( account. :paramtype key_vault_reference: ~azure.mgmt.batch.models.KeyVaultReference :keyword public_network_access: If not specified, the default value is 'enabled'. Known values - are: "Enabled" and "Disabled". + are: "Enabled", "Disabled", and "SecuredByPerimeter". :paramtype public_network_access: str or ~azure.mgmt.batch.models.PublicNetworkAccessType :keyword network_profile: The network profile only takes effect when publicNetworkAccess is enabled. @@ -1086,7 +1218,7 @@ class BatchAccountIdentity(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar principal_id: The principal id of the Batch account. This property will only be provided for a system assigned identity. @@ -1200,7 +1332,7 @@ def __init__( class BatchAccountRegenerateKeyParameters(_serialization.Model): """Parameters supplied to the RegenerateKey operation. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar key_name: The type of account key to regenerate. Required. Known values are: "Primary" and "Secondary". @@ -1243,7 +1375,7 @@ class BatchAccountUpdateParameters(_serialization.Model): 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'. Known values - are: "Enabled" and "Disabled". + are: "Enabled", "Disabled", and "SecuredByPerimeter". :vartype public_network_access: str or ~azure.mgmt.batch.models.PublicNetworkAccessType :ivar network_profile: The network profile only takes effect when publicNetworkAccess is enabled. @@ -1289,7 +1421,7 @@ def __init__( :paramtype allowed_authentication_modes: list[str or ~azure.mgmt.batch.models.AuthenticationMode] :keyword public_network_access: If not specified, the default value is 'enabled'. Known values - are: "Enabled" and "Disabled". + are: "Enabled", "Disabled", and "SecuredByPerimeter". :paramtype public_network_access: str or ~azure.mgmt.batch.models.PublicNetworkAccessType :keyword network_profile: The network profile only takes effect when publicNetworkAccess is enabled. @@ -1334,7 +1466,7 @@ class BatchPoolIdentity(_serialization.Model): existing pool, only the new vms which are created after the pool shrinks to 0 will have the updated identities. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type: The type of identity used for the Batch Pool. Required. Known values are: "UserAssigned" and "None". @@ -1371,7 +1503,7 @@ def __init__( self.user_assigned_identities = user_assigned_identities -class Certificate(ProxyResource): # pylint: disable=too-many-instance-attributes +class Certificate(AzureProxyResource): # pylint: disable=too-many-instance-attributes """Contains information about a certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -1384,6 +1516,8 @@ class Certificate(ProxyResource): # pylint: disable=too-many-instance-attribute :vartype type: str :ivar etag: The ETag of the resource, used for concurrency statements. :vartype etag: str + :ivar tags: The tags of the resource. + :vartype tags: dict[str, str] :ivar thumbprint_algorithm: This must match the first portion of the certificate name. Currently required to be 'SHA1'. :vartype thumbprint_algorithm: str @@ -1429,6 +1563,7 @@ class Certificate(ProxyResource): # pylint: disable=too-many-instance-attribute "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "etag": {"key": "etag", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, "thumbprint_algorithm": {"key": "properties.thumbprintAlgorithm", "type": "str"}, "thumbprint": {"key": "properties.thumbprint", "type": "str"}, "format": {"key": "properties.format", "type": "str"}, @@ -1446,12 +1581,15 @@ class Certificate(ProxyResource): # pylint: disable=too-many-instance-attribute def __init__( self, *, + tags: Optional[Dict[str, str]] = None, thumbprint_algorithm: Optional[str] = None, thumbprint: Optional[str] = None, format: Optional[Union[str, "_models.CertificateFormat"]] = None, **kwargs: Any ) -> None: """ + :keyword tags: The tags of the resource. + :paramtype tags: dict[str, str] :keyword thumbprint_algorithm: This must match the first portion of the certificate name. Currently required to be 'SHA1'. :paramtype thumbprint_algorithm: str @@ -1461,7 +1599,7 @@ def __init__( Pfx. Known values are: "Pfx" and "Cer". :paramtype format: str or ~azure.mgmt.batch.models.CertificateFormat """ - super().__init__(**kwargs) + super().__init__(tags=tags, **kwargs) self.thumbprint_algorithm = thumbprint_algorithm self.thumbprint = thumbprint self.format = format @@ -1516,7 +1654,7 @@ def __init__( self.format = format -class CertificateCreateOrUpdateParameters(ProxyResource): +class CertificateCreateOrUpdateParameters(AzureProxyResource): """Contains information about a certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -1529,6 +1667,8 @@ class CertificateCreateOrUpdateParameters(ProxyResource): :vartype type: str :ivar etag: The ETag of the resource, used for concurrency statements. :vartype etag: str + :ivar tags: The tags of the resource. + :vartype tags: dict[str, str] :ivar thumbprint_algorithm: This must match the first portion of the certificate name. Currently required to be 'SHA1'. :vartype thumbprint_algorithm: str @@ -1555,6 +1695,7 @@ class CertificateCreateOrUpdateParameters(ProxyResource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "etag": {"key": "etag", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, "thumbprint_algorithm": {"key": "properties.thumbprintAlgorithm", "type": "str"}, "thumbprint": {"key": "properties.thumbprint", "type": "str"}, "format": {"key": "properties.format", "type": "str"}, @@ -1565,6 +1706,7 @@ class CertificateCreateOrUpdateParameters(ProxyResource): def __init__( self, *, + tags: Optional[Dict[str, str]] = None, thumbprint_algorithm: Optional[str] = None, thumbprint: Optional[str] = None, format: Optional[Union[str, "_models.CertificateFormat"]] = None, @@ -1573,6 +1715,8 @@ def __init__( **kwargs: Any ) -> None: """ + :keyword tags: The tags of the resource. + :paramtype tags: dict[str, str] :keyword thumbprint_algorithm: This must match the first portion of the certificate name. Currently required to be 'SHA1'. :paramtype thumbprint_algorithm: str @@ -1586,7 +1730,7 @@ def __init__( :keyword password: This must not be specified if the certificate format is Cer. :paramtype password: str """ - super().__init__(**kwargs) + super().__init__(tags=tags, **kwargs) self.thumbprint_algorithm = thumbprint_algorithm self.thumbprint = thumbprint self.format = format @@ -1597,7 +1741,7 @@ def __init__( class CertificateCreateOrUpdateProperties(CertificateBaseProperties): """Certificate properties for create operations. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar thumbprint_algorithm: This must match the first portion of the certificate name. Currently required to be 'SHA1'. @@ -1742,25 +1886,23 @@ class CertificateReference(_serialization.Model): `Azure KeyVault Extension `_ instead. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The fully qualified ID of the certificate to install on the pool. This must be inside the same batch account as the pool. Required. :vartype id: str :ivar store_location: 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 - 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. Known - values are: "CurrentUser" and "LocalMachine". + pools configured with Windows compute nodes. For Linux compute nodes, the 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. Known values + are: "CurrentUser" and "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 - Windows image reference). Common store names include: My, Root, CA, Trust, Disallowed, - TrustedPeople, TrustedPublisher, AuthRoot, AddressBook, but any custom store name can also be - used. The default value is My. + :ivar store_name: This property is applicable only for pools configured with Windows compute + nodes. Common store names include: My, Root, CA, Trust, Disallowed, TrustedPeople, + TrustedPublisher, AuthRoot, AddressBook, but any custom store name can also be used. The + default value is My. :vartype store_name: str :ivar visibility: Which user accounts on the compute node should have access to the private data of the certificate. @@ -1792,19 +1934,17 @@ def __init__( inside the same batch account as the pool. Required. :paramtype id: str :keyword store_location: 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 - 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. Known - values are: "CurrentUser" and "LocalMachine". + pools configured with Windows compute nodes. For Linux compute nodes, the 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. Known values + are: "CurrentUser" and "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 - Windows image reference). Common store names include: My, Root, CA, Trust, Disallowed, - TrustedPeople, TrustedPublisher, AuthRoot, AddressBook, but any custom store name can also be - used. The default value is My. + :keyword store_name: This property is applicable only for pools configured with Windows compute + nodes. Common store names include: My, Root, CA, Trust, Disallowed, TrustedPeople, + TrustedPublisher, AuthRoot, AddressBook, but any custom store name can also be used. The + default value is My. :paramtype store_name: str :keyword visibility: Which user accounts on the compute node should have access to the private data of the certificate. @@ -1822,7 +1962,7 @@ class CheckNameAvailabilityParameters(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name to check for availability. Required. :vartype name: str @@ -1890,7 +2030,7 @@ def __init__(self, **kwargs: Any) -> None: class CIFSMountConfiguration(_serialization.Model): """Information used to connect to a CIFS file system. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar user_name: The user to use for authentication against the CIFS file system. Required. :vartype user_name: str @@ -2004,50 +2144,6 @@ def __init__( self.details = details -class CloudServiceConfiguration(_serialization.Model): - """The configuration for nodes in a pool based on the Azure Cloud Services platform. - - All required parameters must be populated in order to send to Azure. - - :ivar os_family: Possible values are: 2 - OS Family 2, equivalent to Windows Server 2008 R2 - SP1. 3 - OS Family 3, equivalent to Windows Server 2012. 4 - OS Family 4, equivalent to Windows - Server 2012 R2. 5 - OS Family 5, equivalent to Windows Server 2016. 6 - OS Family 6, equivalent - to Windows Server 2019. For more information, see Azure Guest OS Releases - (https://azure.microsoft.com/documentation/articles/cloud-services-guestos-update-matrix/#releases). - Required. - :vartype os_family: str - :ivar os_version: The default value is * which specifies the latest operating system version - for the specified OS family. - :vartype os_version: str - """ - - _validation = { - "os_family": {"required": True}, - } - - _attribute_map = { - "os_family": {"key": "osFamily", "type": "str"}, - "os_version": {"key": "osVersion", "type": "str"}, - } - - def __init__(self, *, os_family: str, os_version: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword os_family: Possible values are: 2 - OS Family 2, equivalent to Windows Server 2008 R2 - SP1. 3 - OS Family 3, equivalent to Windows Server 2012. 4 - OS Family 4, equivalent to Windows - Server 2012 R2. 5 - OS Family 5, equivalent to Windows Server 2016. 6 - OS Family 6, equivalent - to Windows Server 2019. For more information, see Azure Guest OS Releases - (https://azure.microsoft.com/documentation/articles/cloud-services-guestos-update-matrix/#releases). - Required. - :paramtype os_family: str - :keyword os_version: The default value is * which specifies the latest operating system version - for the specified OS family. - :paramtype os_version: str - """ - super().__init__(**kwargs) - self.os_family = os_family - self.os_version = os_version - - class ComputeNodeIdentityReference(_serialization.Model): """The reference to a user assigned identity associated with the Batch pool which a compute node will use. @@ -2072,7 +2168,7 @@ def __init__(self, *, resource_id: Optional[str] = None, **kwargs: Any) -> None: class ContainerConfiguration(_serialization.Model): """The configuration for container-enabled pools. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type: The container technology to be used. Required. Known values are: "DockerCompatible" and "CriCompatible". @@ -2122,6 +2218,46 @@ def __init__( self.container_registries = container_registries +class ContainerHostBatchBindMountEntry(_serialization.Model): + """The entry of path and mount mode you want to mount into task container. + + :ivar source: The paths which will be mounted to container task's container. Known values are: + "Shared", "Startup", "VfsMounts", "Task", "JobPrep", and "Applications". + :vartype source: str or ~azure.mgmt.batch.models.ContainerHostDataPath + :ivar is_read_only: For Linux, if you mount this path as a read/write mode, this does not mean + that all users in container have the read/write access for the path, it depends on the access + in host VM. If this path is mounted read-only, all users within the container will not be able + to modify the path. + :vartype is_read_only: bool + """ + + _attribute_map = { + "source": {"key": "source", "type": "str"}, + "is_read_only": {"key": "isReadOnly", "type": "bool"}, + } + + def __init__( + self, + *, + source: Optional[Union[str, "_models.ContainerHostDataPath"]] = None, + is_read_only: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword source: The paths which will be mounted to container task's container. Known values + are: "Shared", "Startup", "VfsMounts", "Task", "JobPrep", and "Applications". + :paramtype source: str or ~azure.mgmt.batch.models.ContainerHostDataPath + :keyword is_read_only: For Linux, if you mount this path as a read/write mode, this does not + mean that all users in container have the read/write access for the path, it depends on the + access in host VM. If this path is mounted read-only, all users within the container will not + be able to modify the path. + :paramtype is_read_only: bool + """ + super().__init__(**kwargs) + self.source = source + self.is_read_only = is_read_only + + class ContainerRegistry(_serialization.Model): """A private container registry. @@ -2174,7 +2310,7 @@ class DataDisk(_serialization.Model): """Settings which will be used by the data disks associated to Compute Nodes in the Pool. When using attached data disks, you need to mount and format the disks from within a VM to use them. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar lun: The lun is used to uniquely identify each data disk. If attaching multiple disks, each should have a distinct lun. The value must be between 0 and 63, inclusive. Required. @@ -2231,7 +2367,7 @@ def __init__( readWrite - The caching mode for the disk is read and write. 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/. + https://blogs.msdn.microsoft.com/windowsazurestorage/2012/06/27/exploring-windows-azure-drives-disks-and-images/. # pylint: disable=line-too-long Known values are: "None", "ReadOnly", and "ReadWrite". :paramtype caching: str or ~azure.mgmt.batch.models.CachingType :keyword disk_size_gb: The initial disk size in GB when creating new data disk. Required. @@ -2253,7 +2389,7 @@ def __init__( class DeleteCertificateError(_serialization.Model): """An error response from the Batch service. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. Required. @@ -2312,39 +2448,24 @@ def __init__( class DeploymentConfiguration(_serialization.Model): """Deployment configuration properties. - :ivar cloud_service_configuration: This property and virtualMachineConfiguration are mutually - exclusive and one of the properties must be specified. This property cannot be specified if the - Batch account was created with its poolAllocationMode property set to 'UserSubscription'. - :vartype cloud_service_configuration: ~azure.mgmt.batch.models.CloudServiceConfiguration - :ivar virtual_machine_configuration: This property and cloudServiceConfiguration are mutually - exclusive and one of the properties must be specified. + :ivar virtual_machine_configuration: The configuration for compute nodes in a pool based on the + Azure Virtual Machines infrastructure. :vartype virtual_machine_configuration: ~azure.mgmt.batch.models.VirtualMachineConfiguration """ _attribute_map = { - "cloud_service_configuration": {"key": "cloudServiceConfiguration", "type": "CloudServiceConfiguration"}, "virtual_machine_configuration": {"key": "virtualMachineConfiguration", "type": "VirtualMachineConfiguration"}, } def __init__( - self, - *, - cloud_service_configuration: Optional["_models.CloudServiceConfiguration"] = None, - virtual_machine_configuration: Optional["_models.VirtualMachineConfiguration"] = None, - **kwargs: Any + self, *, virtual_machine_configuration: Optional["_models.VirtualMachineConfiguration"] = None, **kwargs: Any ) -> None: """ - :keyword cloud_service_configuration: This property and virtualMachineConfiguration are - mutually exclusive and one of the properties must be specified. This property cannot be - specified if the Batch account was created with its poolAllocationMode property set to - 'UserSubscription'. - :paramtype cloud_service_configuration: ~azure.mgmt.batch.models.CloudServiceConfiguration - :keyword virtual_machine_configuration: This property and cloudServiceConfiguration are - mutually exclusive and one of the properties must be specified. + :keyword virtual_machine_configuration: The configuration for compute nodes in a pool based on + the Azure Virtual Machines infrastructure. :paramtype virtual_machine_configuration: ~azure.mgmt.batch.models.VirtualMachineConfiguration """ super().__init__(**kwargs) - self.cloud_service_configuration = cloud_service_configuration self.virtual_machine_configuration = virtual_machine_configuration @@ -2380,7 +2501,7 @@ def __init__( self.next_link = next_link -class DetectorResponse(ProxyResource): +class DetectorResponse(AzureProxyResource): """Contains the information for a detector. Variables are only populated by the server, and will be ignored when sending a request. @@ -2393,6 +2514,8 @@ class DetectorResponse(ProxyResource): :vartype type: str :ivar etag: The ETag of the resource, used for concurrency statements. :vartype etag: str + :ivar tags: The tags of the resource. + :vartype tags: dict[str, str] :ivar value: A base64 encoded string that represents the content of a detector. :vartype value: str """ @@ -2409,15 +2532,18 @@ class DetectorResponse(ProxyResource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "etag": {"key": "etag", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, "value": {"key": "properties.value", "type": "str"}, } - def __init__(self, *, value: Optional[str] = None, **kwargs: Any) -> None: + def __init__(self, *, tags: Optional[Dict[str, str]] = None, value: Optional[str] = None, **kwargs: Any) -> None: """ + :keyword tags: The tags of the resource. + :paramtype tags: dict[str, str] :keyword value: A base64 encoded string that represents the content of a detector. :paramtype value: str """ - super().__init__(**kwargs) + super().__init__(tags=tags, **kwargs) self.value = value @@ -2521,7 +2647,7 @@ def __init__( class EndpointAccessProfile(_serialization.Model): """Network access profile for Batch endpoint. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar default_action: Default action for endpoint access. It is only applicable when publicNetworkAccess is enabled. Required. Known values are: "Allow" and "Deny". @@ -2619,7 +2745,7 @@ def __init__(self, **kwargs: Any) -> None: class EnvironmentSetting(_serialization.Model): """An environment variable to be set on a task process. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the environment variable. Required. :vartype name: str @@ -2648,6 +2774,98 @@ def __init__(self, *, name: str, value: Optional[str] = None, **kwargs: Any) -> self.value = value +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.batch.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.batch.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.batch.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.batch.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + class FixedScaleSettings(_serialization.Model): """Fixed scale settings for the pool. @@ -2727,6 +2945,12 @@ class ImageReference(_serialization.Model): the firewall settings for the Batch node agent to communicate with the Batch service see https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration. :vartype id: str + :ivar shared_gallery_image_id: This property is mutually exclusive with other properties and + can be fetched from shared gallery image GET call. + :vartype shared_gallery_image_id: str + :ivar community_gallery_image_id: This property is mutually exclusive with other properties and + can be fetched from community gallery image GET call. + :vartype community_gallery_image_id: str """ _attribute_map = { @@ -2735,6 +2959,8 @@ class ImageReference(_serialization.Model): "sku": {"key": "sku", "type": "str"}, "version": {"key": "version", "type": "str"}, "id": {"key": "id", "type": "str"}, + "shared_gallery_image_id": {"key": "sharedGalleryImageId", "type": "str"}, + "community_gallery_image_id": {"key": "communityGalleryImageId", "type": "str"}, } def __init__( @@ -2745,6 +2971,8 @@ def __init__( sku: Optional[str] = None, version: Optional[str] = None, id: Optional[str] = None, # pylint: disable=redefined-builtin + shared_gallery_image_id: Optional[str] = None, + community_gallery_image_id: Optional[str] = None, **kwargs: Any ) -> None: """ @@ -2762,6 +2990,12 @@ def __init__( about the firewall settings for the Batch node agent to communicate with the Batch service see https://docs.microsoft.com/en-us/azure/batch/batch-api-basics#virtual-network-vnet-and-firewall-configuration. :paramtype id: str + :keyword shared_gallery_image_id: This property is mutually exclusive with other properties and + can be fetched from shared gallery image GET call. + :paramtype shared_gallery_image_id: str + :keyword community_gallery_image_id: This property is mutually exclusive with other properties + and can be fetched from community gallery image GET call. + :paramtype community_gallery_image_id: str """ super().__init__(**kwargs) self.publisher = publisher @@ -2769,13 +3003,15 @@ def __init__( self.sku = sku self.version = version self.id = id + self.shared_gallery_image_id = shared_gallery_image_id + self.community_gallery_image_id = community_gallery_image_id class InboundNatPool(_serialization.Model): """A inbound NAT pool that can be used to address specific ports on compute nodes in a Batch pool externally. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name must be unique within a Batch pool, can contain letters, numbers, underscores, periods, and hyphens. Names must start with a letter or number, must end with a @@ -2878,7 +3114,7 @@ class IPRule(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar action: Action when client IP address is matched. Required. Default value is "Allow". :vartype action: str @@ -2944,7 +3180,7 @@ def __init__(self, *, key_identifier: Optional[str] = None, **kwargs: Any) -> No class KeyVaultReference(_serialization.Model): """Identifies the Azure key vault associated with a Batch account. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The resource ID of the Azure key vault associated with the Batch account. Required. :vartype id: str @@ -3214,29 +3450,43 @@ class ManagedDisk(_serialization.Model): :ivar storage_account_type: The storage account type for use in creating data disks or OS disk. Known values are: "Standard_LRS", "Premium_LRS", and "StandardSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.batch.models.StorageAccountType + :ivar security_profile: Specifies the security profile settings for the managed disk. + **Note**\\ : It can only be set for Confidential VMs and is required when using Confidential + VMs. + :vartype security_profile: ~azure.mgmt.batch.models.VMDiskSecurityProfile """ _attribute_map = { "storage_account_type": {"key": "storageAccountType", "type": "str"}, + "security_profile": {"key": "securityProfile", "type": "VMDiskSecurityProfile"}, } def __init__( - self, *, storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, **kwargs: Any + self, + *, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + security_profile: Optional["_models.VMDiskSecurityProfile"] = None, + **kwargs: Any ) -> None: """ :keyword storage_account_type: The storage account type for use in creating data disks or OS disk. Known values are: "Standard_LRS", "Premium_LRS", and "StandardSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.batch.models.StorageAccountType + :keyword security_profile: Specifies the security profile settings for the managed disk. + **Note**\\ : It can only be set for Confidential VMs and is required when using Confidential + VMs. + :paramtype security_profile: ~azure.mgmt.batch.models.VMDiskSecurityProfile """ super().__init__(**kwargs) self.storage_account_type = storage_account_type + self.security_profile = security_profile class MetadataItem(_serialization.Model): """The Batch service does not assign any meaning to this metadata; it is solely for the use of user code. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the metadata item. Required. :vartype name: str @@ -3337,22 +3587,19 @@ class NetworkConfiguration(_serialization.Model): communication to the compute nodes in the specified subnet is denied by an NSG, then the Batch service will set the state of the compute nodes to unusable. If the specified VNet has any associated Network Security Groups (NSG), then a few reserved system ports must be enabled for - inbound communication. For pools created with a virtual machine configuration, enable ports - 29876 and 29877, as well as port 22 for Linux and port 3389 for Windows. For pools created with - a cloud service configuration, enable ports 10100, 20100, and 30100. Also enable outbound - connections to Azure Storage on port 443. For cloudServiceConfiguration pools, only 'classic' - VNETs are supported. For more details see: + inbound communication. Enable ports 29876 and 29877, as well as port 22 for Linux and port 3389 + for Windows. Also enable outbound connections to Azure Storage on port 443. 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_vnet_assignment_scope: The scope of dynamic vnet assignment. Known values are: "none" and "job". :vartype dynamic_vnet_assignment_scope: str or ~azure.mgmt.batch.models.DynamicVNetAssignmentScope - :ivar endpoint_configuration: Pool endpoint configuration is only supported on pools with the - virtualMachineConfiguration property. + :ivar endpoint_configuration: The endpoint configuration for a pool. :vartype endpoint_configuration: ~azure.mgmt.batch.models.PoolEndpointConfiguration - :ivar public_ip_address_configuration: This property is only supported on Pools with the - virtualMachineConfiguration property. + :ivar public_ip_address_configuration: The public IP Address configuration of the networking + configuration of a Pool. :vartype public_ip_address_configuration: ~azure.mgmt.batch.models.PublicIPAddressConfiguration :ivar enable_accelerated_networking: Accelerated networking enables single root I/O virtualization (SR-IOV) to a VM, which may lead to improved networking performance. For more @@ -3394,22 +3641,19 @@ def __init__( communication to the compute nodes in the specified subnet is denied by an NSG, then the Batch service will set the state of the compute nodes to unusable. If the specified VNet has any associated Network Security Groups (NSG), then a few reserved system ports must be enabled for - inbound communication. For pools created with a virtual machine configuration, enable ports - 29876 and 29877, as well as port 22 for Linux and port 3389 for Windows. For pools created with - a cloud service configuration, enable ports 10100, 20100, and 30100. Also enable outbound - connections to Azure Storage on port 443. For cloudServiceConfiguration pools, only 'classic' - VNETs are supported. For more details see: + inbound communication. Enable ports 29876 and 29877, as well as port 22 for Linux and port 3389 + for Windows. Also enable outbound connections to Azure Storage on port 443. 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_vnet_assignment_scope: The scope of dynamic vnet assignment. Known values are: "none" and "job". :paramtype dynamic_vnet_assignment_scope: str or ~azure.mgmt.batch.models.DynamicVNetAssignmentScope - :keyword endpoint_configuration: Pool endpoint configuration is only supported on pools with - the virtualMachineConfiguration property. + :keyword endpoint_configuration: The endpoint configuration for a pool. :paramtype endpoint_configuration: ~azure.mgmt.batch.models.PoolEndpointConfiguration - :keyword public_ip_address_configuration: This property is only supported on Pools with the - virtualMachineConfiguration property. + :keyword public_ip_address_configuration: The public IP Address configuration of the networking + configuration of a Pool. :paramtype public_ip_address_configuration: ~azure.mgmt.batch.models.PublicIPAddressConfiguration :keyword enable_accelerated_networking: Accelerated networking enables single root I/O @@ -3465,7 +3709,7 @@ def __init__( class NetworkSecurityGroupRule(_serialization.Model): """A network security group rule to apply to an inbound endpoint. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar priority: Priorities within a pool must be unique and are evaluated in order of priority. The lower the number the higher the priority. For example, rules could be specified with order @@ -3480,7 +3724,7 @@ class NetworkSecurityGroupRule(_serialization.Model): (i.e. 192.168.1.0/24), default tag, or * (for all addresses). If any other values are provided the request fails with HTTP status code 400. Required. :vartype source_address_prefix: str - :ivar source_port_ranges: Valid values are '\ *' (for all ports 0 - 65535) or arrays of ports + :ivar source_port_ranges: Valid values are '\\ *' (for all ports 0 - 65535) or arrays of ports or port ranges (i.e. 100-200). The ports should in the range of 0 to 65535 and the port ranges or ports can't overlap. If any other values are provided the request fails with HTTP status code 400. Default value will be *. @@ -3523,7 +3767,7 @@ def __init__( subnet (i.e. 192.168.1.0/24), default tag, or * (for all addresses). If any other values are provided the request fails with HTTP status code 400. Required. :paramtype source_address_prefix: str - :keyword source_port_ranges: Valid values are '\ *' (for all ports 0 - 65535) or arrays of + :keyword source_port_ranges: Valid values are '\\ *' (for all ports 0 - 65535) or arrays of ports or port ranges (i.e. 100-200). The ports should in the range of 0 to 65535 and the port ranges or ports can't overlap. If any other values are provided the request fails with HTTP status code 400. Default value will be *. @@ -3536,10 +3780,298 @@ def __init__( self.source_port_ranges = source_port_ranges +class NetworkSecurityPerimeter(_serialization.Model): + """Information about a network security perimeter (NSP). + + :ivar id: Fully qualified Azure resource ID of the NSP resource. + :vartype id: str + :ivar perimeter_guid: Universal unique ID (UUID) of the network security perimeter. + :vartype perimeter_guid: str + :ivar location: Location of the network security perimeter. + :vartype location: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "perimeter_guid": {"key": "perimeterGuid", "type": "str"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + perimeter_guid: Optional[str] = None, + location: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Fully qualified Azure resource ID of the NSP resource. + :paramtype id: str + :keyword perimeter_guid: Universal unique ID (UUID) of the network security perimeter. + :paramtype perimeter_guid: str + :keyword location: Location of the network security perimeter. + :paramtype location: str + """ + super().__init__(**kwargs) + self.id = id + self.perimeter_guid = perimeter_guid + self.location = location + + +class Resource(_serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.batch.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.batch.models.SystemData + """ + + +class NetworkSecurityPerimeterConfiguration(ProxyResource): + """Network security perimeter (NSP) configuration resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.batch.models.SystemData + :ivar properties: Network security configuration properties. + :vartype properties: ~azure.mgmt.batch.models.NetworkSecurityPerimeterConfigurationProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "NetworkSecurityPerimeterConfigurationProperties"}, + } + + def __init__( + self, *, properties: Optional["_models.NetworkSecurityPerimeterConfigurationProperties"] = None, **kwargs: Any + ) -> None: + """ + :keyword properties: Network security configuration properties. + :paramtype properties: ~azure.mgmt.batch.models.NetworkSecurityPerimeterConfigurationProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class NetworkSecurityPerimeterConfigurationListResult(_serialization.Model): # pylint: disable=name-too-long + """Result of a list NSP (network security perimeter) configurations request. + + :ivar value: Array of network security perimeter results. + :vartype value: list[~azure.mgmt.batch.models.NetworkSecurityPerimeterConfiguration] + :ivar next_link: The link used to get the next page of results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[NetworkSecurityPerimeterConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.NetworkSecurityPerimeterConfiguration"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Array of network security perimeter results. + :paramtype value: list[~azure.mgmt.batch.models.NetworkSecurityPerimeterConfiguration] + :keyword next_link: The link used to get the next page of results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class NetworkSecurityPerimeterConfigurationProperties(_serialization.Model): # pylint: disable=name-too-long + """Network security configuration properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Provisioning state of a network security perimeter configuration that + is being created or updated. Known values are: "Succeeded", "Creating", "Updating", "Deleting", + "Accepted", "Failed", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.batch.models.NetworkSecurityPerimeterConfigurationProvisioningState + :ivar provisioning_issues: List of provisioning issues, if any. + :vartype provisioning_issues: list[~azure.mgmt.batch.models.ProvisioningIssue] + :ivar network_security_perimeter: Information about a network security perimeter (NSP). + :vartype network_security_perimeter: ~azure.mgmt.batch.models.NetworkSecurityPerimeter + :ivar resource_association: Information about resource association. + :vartype resource_association: ~azure.mgmt.batch.models.ResourceAssociation + :ivar profile: Network security perimeter configuration profile. + :vartype profile: ~azure.mgmt.batch.models.NetworkSecurityProfile + """ + + _validation = { + "provisioning_state": {"readonly": True}, + "provisioning_issues": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "provisioning_issues": {"key": "provisioningIssues", "type": "[ProvisioningIssue]"}, + "network_security_perimeter": {"key": "networkSecurityPerimeter", "type": "NetworkSecurityPerimeter"}, + "resource_association": {"key": "resourceAssociation", "type": "ResourceAssociation"}, + "profile": {"key": "profile", "type": "NetworkSecurityProfile"}, + } + + def __init__( + self, + *, + network_security_perimeter: Optional["_models.NetworkSecurityPerimeter"] = None, + resource_association: Optional["_models.ResourceAssociation"] = None, + profile: Optional["_models.NetworkSecurityProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword network_security_perimeter: Information about a network security perimeter (NSP). + :paramtype network_security_perimeter: ~azure.mgmt.batch.models.NetworkSecurityPerimeter + :keyword resource_association: Information about resource association. + :paramtype resource_association: ~azure.mgmt.batch.models.ResourceAssociation + :keyword profile: Network security perimeter configuration profile. + :paramtype profile: ~azure.mgmt.batch.models.NetworkSecurityProfile + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.provisioning_issues = None + self.network_security_perimeter = network_security_perimeter + self.resource_association = resource_association + self.profile = profile + + +class NetworkSecurityProfile(_serialization.Model): + """Network security perimeter configuration profile. + + :ivar name: Name of the profile. + :vartype name: str + :ivar access_rules_version: Current access rules version. + :vartype access_rules_version: int + :ivar access_rules: List of Access Rules. + :vartype access_rules: list[~azure.mgmt.batch.models.AccessRule] + :ivar diagnostic_settings_version: Current diagnostic settings version. + :vartype diagnostic_settings_version: int + :ivar enabled_log_categories: List of log categories that are enabled. + :vartype enabled_log_categories: list[str] + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "access_rules_version": {"key": "accessRulesVersion", "type": "int"}, + "access_rules": {"key": "accessRules", "type": "[AccessRule]"}, + "diagnostic_settings_version": {"key": "diagnosticSettingsVersion", "type": "int"}, + "enabled_log_categories": {"key": "enabledLogCategories", "type": "[str]"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + access_rules_version: Optional[int] = None, + access_rules: Optional[List["_models.AccessRule"]] = None, + diagnostic_settings_version: Optional[int] = None, + enabled_log_categories: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the profile. + :paramtype name: str + :keyword access_rules_version: Current access rules version. + :paramtype access_rules_version: int + :keyword access_rules: List of Access Rules. + :paramtype access_rules: list[~azure.mgmt.batch.models.AccessRule] + :keyword diagnostic_settings_version: Current diagnostic settings version. + :paramtype diagnostic_settings_version: int + :keyword enabled_log_categories: List of log categories that are enabled. + :paramtype enabled_log_categories: list[str] + """ + super().__init__(**kwargs) + self.name = name + self.access_rules_version = access_rules_version + self.access_rules = access_rules + self.diagnostic_settings_version = diagnostic_settings_version + self.enabled_log_categories = enabled_log_categories + + class NFSMountConfiguration(_serialization.Model): """Information used to connect to an NFS file system. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar source: The URI of the file system to mount. Required. :vartype source: str @@ -3851,7 +4383,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: self.next_link = next_link -class Pool(ProxyResource): # pylint: disable=too-many-instance-attributes +class Pool(AzureProxyResource): # pylint: disable=too-many-instance-attributes """Contains information about a pool. Variables are only populated by the server, and will be ignored when sending a request. @@ -3864,6 +4396,8 @@ class Pool(ProxyResource): # pylint: disable=too-many-instance-attributes :vartype type: str :ivar etag: The ETag of the resource, used for concurrency statements. :vartype etag: str + :ivar tags: The tags of the resource. + :vartype tags: dict[str, str] :ivar identity: The type of identity used for the Batch Pool. :vartype identity: ~azure.mgmt.batch.models.BatchPoolIdentity :ivar display_name: The display name need not be unique and can contain any Unicode characters @@ -3886,21 +4420,14 @@ class Pool(ProxyResource): # pylint: disable=too-many-instance-attributes :ivar allocation_state_transition_time: The time at which the pool entered its current allocation state. :vartype allocation_state_transition_time: ~datetime.datetime - :ivar vm_size: For information about available sizes of virtual machines for Cloud Services - pools (pools created with cloudServiceConfiguration), see Sizes for Cloud Services - (https://azure.microsoft.com/documentation/articles/cloud-services-sizes-specs/). Batch - supports all Cloud Services VM sizes except ExtraSmall. For information about available VM - sizes for pools using images from the Virtual Machines Marketplace (pools created with - virtualMachineConfiguration) see Sizes for Virtual Machines (Linux) + :ivar vm_size: For information about available VM sizes, see Sizes for Virtual Machines (Linux) (https://azure.microsoft.com/documentation/articles/virtual-machines-linux-sizes/) or Sizes for Virtual Machines (Windows) (https://azure.microsoft.com/documentation/articles/virtual-machines-windows-sizes/). Batch supports all Azure VM sizes except STANDARD_A0 and those with premium storage (STANDARD_GS, STANDARD_DS, and STANDARD_DSV2 series). :vartype vm_size: str - :ivar deployment_configuration: Using CloudServiceConfiguration specifies that the nodes should - be creating using Azure Cloud Services (PaaS), while VirtualMachineConfiguration uses Azure - Virtual Machines (IaaS). + :ivar deployment_configuration: Deployment configuration properties. :vartype deployment_configuration: ~azure.mgmt.batch.models.DeploymentConfiguration :ivar current_dedicated_nodes: The number of dedicated compute nodes currently in the pool. :vartype current_dedicated_nodes: int @@ -3999,6 +4526,7 @@ class Pool(ProxyResource): # pylint: disable=too-many-instance-attributes "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "etag": {"key": "etag", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, "identity": {"key": "identity", "type": "BatchPoolIdentity"}, "display_name": {"key": "properties.displayName", "type": "str"}, "last_modified": {"key": "properties.lastModified", "type": "iso-8601"}, @@ -4034,6 +4562,7 @@ class Pool(ProxyResource): # pylint: disable=too-many-instance-attributes def __init__( # pylint: disable=too-many-locals self, *, + tags: Optional[Dict[str, str]] = None, identity: Optional["_models.BatchPoolIdentity"] = None, display_name: Optional[str] = None, vm_size: Optional[str] = None, @@ -4056,26 +4585,21 @@ def __init__( # pylint: disable=too-many-locals **kwargs: Any ) -> None: """ + :keyword tags: The tags of the resource. + :paramtype tags: dict[str, str] :keyword identity: The type of identity used for the Batch Pool. :paramtype identity: ~azure.mgmt.batch.models.BatchPoolIdentity :keyword display_name: The display name need not be unique and can contain any Unicode characters up to a maximum length of 1024. :paramtype display_name: str - :keyword vm_size: For information about available sizes of virtual machines for Cloud Services - pools (pools created with cloudServiceConfiguration), see Sizes for Cloud Services - (https://azure.microsoft.com/documentation/articles/cloud-services-sizes-specs/). Batch - supports all Cloud Services VM sizes except ExtraSmall. For information about available VM - sizes for pools using images from the Virtual Machines Marketplace (pools created with - virtualMachineConfiguration) see Sizes for Virtual Machines (Linux) - (https://azure.microsoft.com/documentation/articles/virtual-machines-linux-sizes/) or Sizes for - Virtual Machines (Windows) + :keyword vm_size: For information about available VM sizes, see Sizes for Virtual Machines + (Linux) (https://azure.microsoft.com/documentation/articles/virtual-machines-linux-sizes/) or + Sizes for Virtual Machines (Windows) (https://azure.microsoft.com/documentation/articles/virtual-machines-windows-sizes/). Batch supports all Azure VM sizes except STANDARD_A0 and those with premium storage (STANDARD_GS, STANDARD_DS, and STANDARD_DSV2 series). :paramtype vm_size: str - :keyword deployment_configuration: Using CloudServiceConfiguration specifies that the nodes - should be creating using Azure Cloud Services (PaaS), while VirtualMachineConfiguration uses - Azure Virtual Machines (IaaS). + :keyword deployment_configuration: Deployment configuration properties. :paramtype deployment_configuration: ~azure.mgmt.batch.models.DeploymentConfiguration :keyword 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 @@ -4137,7 +4661,7 @@ def __init__( # pylint: disable=too-many-locals poolAllocationMode property set to 'UserSubscription'. :paramtype resource_tags: dict[str, str] """ - super().__init__(**kwargs) + super().__init__(tags=tags, **kwargs) self.identity = identity self.display_name = display_name self.last_modified = None @@ -4173,7 +4697,7 @@ def __init__( # pylint: disable=too-many-locals class PoolEndpointConfiguration(_serialization.Model): """The endpoint configuration for a pool. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar inbound_nat_pools: The maximum number of inbound NAT pools per Batch pool is 5. If the maximum number of inbound NAT pools is exceeded the request fails with HTTP status code 400. @@ -4206,7 +4730,7 @@ class PrivateEndpoint(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: The ARM resource identifier of the private endpoint. This is of the form - /subscriptions/{subscription}/resourceGroups/{group}/providers/Microsoft.Network/privateEndpoints/{privateEndpoint}. + /subscriptions/{subscription}/resourceGroups/{group}/providers/Microsoft.Network/privateEndpoints/{privateEndpoint}. # pylint: disable=line-too-long :vartype id: str """ @@ -4224,7 +4748,7 @@ def __init__(self, **kwargs: Any) -> None: self.id = None -class PrivateEndpointConnection(ProxyResource): +class PrivateEndpointConnection(AzureProxyResource): """Contains information about a private link resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -4237,6 +4761,8 @@ class PrivateEndpointConnection(ProxyResource): :vartype type: str :ivar etag: The ETag of the resource, used for concurrency statements. :vartype etag: str + :ivar tags: The tags of the resource. + :vartype tags: dict[str, str] :ivar provisioning_state: The provisioning state of the private endpoint connection. Known values are: "Creating", "Updating", "Deleting", "Succeeded", "Failed", and "Cancelled". :vartype provisioning_state: str or @@ -4266,6 +4792,7 @@ class PrivateEndpointConnection(ProxyResource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "etag": {"key": "etag", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, "group_ids": {"key": "properties.groupIds", "type": "[str]"}, @@ -4278,23 +4805,26 @@ class PrivateEndpointConnection(ProxyResource): def __init__( self, *, + tags: Optional[Dict[str, str]] = None, private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs: Any ) -> None: """ + :keyword tags: The tags of the resource. + :paramtype tags: dict[str, str] :keyword private_link_service_connection_state: The private link service connection state of the private endpoint connection. :paramtype private_link_service_connection_state: ~azure.mgmt.batch.models.PrivateLinkServiceConnectionState """ - super().__init__(**kwargs) + super().__init__(tags=tags, **kwargs) self.provisioning_state = None self.private_endpoint = None self.group_ids = None self.private_link_service_connection_state = private_link_service_connection_state -class PrivateLinkResource(ProxyResource): +class PrivateLinkResource(AzureProxyResource): """Contains information about a private link resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -4307,6 +4837,8 @@ class PrivateLinkResource(ProxyResource): :vartype type: str :ivar etag: The ETag of the resource, used for concurrency statements. :vartype etag: str + :ivar tags: The tags of the resource. + :vartype tags: dict[str, str] :ivar group_id: The group id is used to establish the private link connection. :vartype group_id: str :ivar required_members: The list of required members that are used to establish the private @@ -4331,14 +4863,18 @@ class PrivateLinkResource(ProxyResource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "etag": {"key": "etag", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, "group_id": {"key": "properties.groupId", "type": "str"}, "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: The tags of the resource. + :paramtype tags: dict[str, str] + """ + super().__init__(tags=tags, **kwargs) self.group_id = None self.required_members = None self.required_zone_names = None @@ -4349,7 +4885,7 @@ class PrivateLinkServiceConnectionState(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar status: The status of the Batch private endpoint connection. Required. Known values are: "Approved", "Pending", "Rejected", and "Disconnected". @@ -4391,6 +4927,87 @@ def __init__( self.actions_required = None +class ProvisioningIssue(_serialization.Model): + """Describes a provisioning issue for a network security perimeter configuration. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the issue. + :vartype name: str + :ivar properties: Details of a provisioning issue for a network security perimeter (NSP) + configuration. Resource providers should generate separate provisioning issue elements for each + separate issue detected, and include a meaningful and distinctive description, as well as any + appropriate suggestedResourceIds and suggestedAccessRules. + :vartype properties: ~azure.mgmt.batch.models.ProvisioningIssueProperties + """ + + _validation = { + "name": {"readonly": True}, + "properties": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "ProvisioningIssueProperties"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name = None + self.properties = None + + +class ProvisioningIssueProperties(_serialization.Model): + """Details of a provisioning issue for a network security perimeter (NSP) configuration. Resource + providers should generate separate provisioning issue elements for each separate issue + detected, and include a meaningful and distinctive description, as well as any appropriate + suggestedResourceIds and suggestedAccessRules. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar issue_type: Type of issue. Known values are: "Unknown", + "ConfigurationPropagationFailure", "MissingPerimeterConfiguration", and + "MissingIdentityConfiguration". + :vartype issue_type: str or ~azure.mgmt.batch.models.IssueType + :ivar severity: Severity of the issue. Known values are: "Warning" and "Error". + :vartype severity: str or ~azure.mgmt.batch.models.Severity + :ivar description: Description of the issue. + :vartype description: str + :ivar suggested_resource_ids: Fully qualified resource IDs of suggested resources that can be + associated to the network security perimeter (NSP) to remediate the issue. + :vartype suggested_resource_ids: list[str] + :ivar suggested_access_rules: Access rules that can be added to the network security profile + (NSP) to remediate the issue. + :vartype suggested_access_rules: list[~azure.mgmt.batch.models.AccessRule] + """ + + _validation = { + "issue_type": {"readonly": True}, + "severity": {"readonly": True}, + "description": {"readonly": True}, + "suggested_resource_ids": {"readonly": True}, + "suggested_access_rules": {"readonly": True}, + } + + _attribute_map = { + "issue_type": {"key": "issueType", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "suggested_resource_ids": {"key": "suggestedResourceIds", "type": "[str]"}, + "suggested_access_rules": {"key": "suggestedAccessRules", "type": "[AccessRule]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.issue_type = None + self.severity = None + self.description = None + self.suggested_resource_ids = None + self.suggested_access_rules = None + + class PublicIPAddressConfiguration(_serialization.Model): """The public IP Address configuration of the networking configuration of a Pool. @@ -4436,7 +5053,7 @@ def __init__( class ResizeError(_serialization.Model): """An error that occurred when resizing a pool. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. Required. @@ -4551,6 +5168,40 @@ def __init__( self.errors = errors +class ResourceAssociation(_serialization.Model): + """Information about resource association. + + :ivar name: Name of the resource association. + :vartype name: str + :ivar access_mode: Access mode of the resource association. Known values are: "Enforced", + "Learning", and "Audit". + :vartype access_mode: str or ~azure.mgmt.batch.models.ResourceAssociationAccessMode + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "access_mode": {"key": "accessMode", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + access_mode: Optional[Union[str, "_models.ResourceAssociationAccessMode"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the resource association. + :paramtype name: str + :keyword access_mode: Access mode of the resource association. Known values are: "Enforced", + "Learning", and "Audit". + :paramtype access_mode: str or ~azure.mgmt.batch.models.ResourceAssociationAccessMode + """ + super().__init__(**kwargs) + self.name = name + self.access_mode = access_mode + + class ResourceFile(_serialization.Model): """A single file or multiple files to be downloaded to a compute node. @@ -4828,8 +5479,8 @@ class SecurityProfile(_serialization.Model): """Specifies the security profile settings for the virtual machine or virtual machine scale set. :ivar security_type: Specifies the SecurityType of the virtual machine. It has to be set to any - specified value to enable UefiSettings. Default value is "trustedLaunch". - :vartype security_type: str + specified value to enable UefiSettings. Known values are: "trustedLaunch" and "confidentialVM". + :vartype security_type: str or ~azure.mgmt.batch.models.SecurityTypes :ivar encryption_at_host: This property can be used by user in the request to enable or disable the Host Encryption for the virtual machine or virtual machine scale set. This will enable the encryption for all the disks including Resource/Temp disk at host itself. @@ -4848,15 +5499,16 @@ class SecurityProfile(_serialization.Model): def __init__( self, *, - security_type: Optional[Literal["trustedLaunch"]] = None, + security_type: Optional[Union[str, "_models.SecurityTypes"]] = None, encryption_at_host: Optional[bool] = None, uefi_settings: Optional["_models.UefiSettings"] = None, **kwargs: Any ) -> None: """ :keyword security_type: Specifies the SecurityType of the virtual machine. It has to be set to - any specified value to enable UefiSettings. Default value is "trustedLaunch". - :paramtype security_type: str + any specified value to enable UefiSettings. Known values are: "trustedLaunch" and + "confidentialVM". + :paramtype security_type: str or ~azure.mgmt.batch.models.SecurityTypes :keyword encryption_at_host: This property can be used by user in the request to enable or disable the Host Encryption for the virtual machine or virtual machine scale set. This will enable the encryption for all the disks including Resource/Temp disk at host itself. @@ -4875,10 +5527,10 @@ class ServiceArtifactReference(_serialization.Model): """Specifies the service artifact reference id used to set same image version for all virtual machines in the scale set when using 'latest' image version. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: The service artifact reference id in the form of - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/serviceArtifacts/{serviceArtifactName}/vmArtifactsProfiles/{vmArtifactsProfilesName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/serviceArtifacts/{serviceArtifactName}/vmArtifactsProfiles/{vmArtifactsProfilesName}. # pylint: disable=line-too-long Required. :vartype id: str """ @@ -4894,7 +5546,7 @@ class ServiceArtifactReference(_serialization.Model): def __init__(self, *, id: str, **kwargs: Any) -> None: # pylint: disable=redefined-builtin """ :keyword id: The service artifact reference id in the form of - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/serviceArtifacts/{serviceArtifactName}/vmArtifactsProfiles/{vmArtifactsProfilesName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/serviceArtifacts/{serviceArtifactName}/vmArtifactsProfiles/{vmArtifactsProfilesName}. # pylint: disable=line-too-long Required. :paramtype id: str """ @@ -5085,7 +5737,7 @@ class SupportedSkusResult(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar value: The list of SKUs available for the Batch service in the location. Required. :vartype value: list[~azure.mgmt.batch.models.SupportedSku] @@ -5113,10 +5765,74 @@ def __init__(self, *, value: List["_models.SupportedSku"], **kwargs: Any) -> Non self.next_link = None +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.batch.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.batch.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.batch.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.batch.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + class TaskContainerSettings(_serialization.Model): """The container settings for a task. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar container_run_options: These additional options are supplied as arguments to the "docker create" command, in addition to those controlled by the Batch Service. @@ -5130,6 +5846,11 @@ class TaskContainerSettings(_serialization.Model): default is 'taskWorkingDirectory'. Known values are: "TaskWorkingDirectory" and "ContainerImageDefault". :vartype working_directory: str or ~azure.mgmt.batch.models.ContainerWorkingDirectory + :ivar container_host_batch_bind_mounts: If this array is null or be not present, container task + will mount entire temporary disk drive in windows (or AZ_BATCH_NODE_ROOT_DIR in Linux). It + won't' mount any data paths into container if this array is set as empty. + :vartype container_host_batch_bind_mounts: + list[~azure.mgmt.batch.models.ContainerHostBatchBindMountEntry] """ _validation = { @@ -5141,6 +5862,10 @@ class TaskContainerSettings(_serialization.Model): "image_name": {"key": "imageName", "type": "str"}, "registry": {"key": "registry", "type": "ContainerRegistry"}, "working_directory": {"key": "workingDirectory", "type": "str"}, + "container_host_batch_bind_mounts": { + "key": "containerHostBatchBindMounts", + "type": "[ContainerHostBatchBindMountEntry]", + }, } def __init__( @@ -5150,6 +5875,7 @@ def __init__( container_run_options: Optional[str] = None, registry: Optional["_models.ContainerRegistry"] = None, working_directory: Optional[Union[str, "_models.ContainerWorkingDirectory"]] = None, + container_host_batch_bind_mounts: Optional[List["_models.ContainerHostBatchBindMountEntry"]] = None, **kwargs: Any ) -> None: """ @@ -5166,18 +5892,24 @@ def __init__( The default is 'taskWorkingDirectory'. Known values are: "TaskWorkingDirectory" and "ContainerImageDefault". :paramtype working_directory: str or ~azure.mgmt.batch.models.ContainerWorkingDirectory + :keyword container_host_batch_bind_mounts: If this array is null or be not present, container + task will mount entire temporary disk drive in windows (or AZ_BATCH_NODE_ROOT_DIR in Linux). It + won't' mount any data paths into container if this array is set as empty. + :paramtype container_host_batch_bind_mounts: + list[~azure.mgmt.batch.models.ContainerHostBatchBindMountEntry] """ super().__init__(**kwargs) self.container_run_options = container_run_options self.image_name = image_name self.registry = registry self.working_directory = working_directory + self.container_host_batch_bind_mounts = container_host_batch_bind_mounts class TaskSchedulingPolicy(_serialization.Model): """Specifies how tasks should be distributed across compute nodes. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar node_fill_type: How tasks should be distributed across compute nodes. Known values are: "Spread" and "Pack". @@ -5236,7 +5968,7 @@ def __init__( class UpgradePolicy(_serialization.Model): """Describes an upgrade policy - automatic, manual, or rolling. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar mode: Specifies the mode of an upgrade to virtual machines in the scale set.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control @@ -5249,8 +5981,8 @@ class UpgradePolicy(_serialization.Model): :ivar automatic_os_upgrade_policy: The configuration parameters used for performing automatic OS upgrade. :vartype automatic_os_upgrade_policy: ~azure.mgmt.batch.models.AutomaticOSUpgradePolicy - :ivar rolling_upgrade_policy: This property is only supported on Pools with the - virtualMachineConfiguration property. + :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling + upgrade. :vartype rolling_upgrade_policy: ~azure.mgmt.batch.models.RollingUpgradePolicy """ @@ -5284,8 +6016,8 @@ def __init__( :keyword automatic_os_upgrade_policy: The configuration parameters used for performing automatic OS upgrade. :paramtype automatic_os_upgrade_policy: ~azure.mgmt.batch.models.AutomaticOSUpgradePolicy - :keyword rolling_upgrade_policy: This property is only supported on Pools with the - virtualMachineConfiguration property. + :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling + upgrade. :paramtype rolling_upgrade_policy: ~azure.mgmt.batch.models.RollingUpgradePolicy """ super().__init__(**kwargs) @@ -5297,7 +6029,7 @@ def __init__( class UserAccount(_serialization.Model): """Properties used to create a user on an Azure Batch node. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the user account. Names can contain any Unicode characters up to a maximum length of 20. Required. @@ -5434,7 +6166,7 @@ class VirtualMachineConfiguration(_serialization.Model): # pylint: disable=too- """The configuration for compute nodes in a pool based on the Azure Virtual Machines infrastructure. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar image_reference: A reference to an Azure Virtual Machines Marketplace image or the Azure Image resource of a custom Virtual Machine. To get the list of all imageReferences verified by @@ -5479,7 +6211,7 @@ class VirtualMachineConfiguration(_serialization.Model): # pylint: disable=too- virtual machine scale set. :vartype security_profile: ~azure.mgmt.batch.models.SecurityProfile :ivar service_artifact_reference: The service artifact reference id in the form of - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/serviceArtifacts/{serviceArtifactName}/vmArtifactsProfiles/{vmArtifactsProfilesName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/serviceArtifacts/{serviceArtifactName}/vmArtifactsProfiles/{vmArtifactsProfilesName}. # pylint: disable=line-too-long :vartype service_artifact_reference: ~azure.mgmt.batch.models.ServiceArtifactReference """ @@ -5564,7 +6296,7 @@ def __init__( virtual machine scale set. :paramtype security_profile: ~azure.mgmt.batch.models.SecurityProfile :keyword service_artifact_reference: The service artifact reference id in the form of - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/serviceArtifacts/{serviceArtifactName}/vmArtifactsProfiles/{vmArtifactsProfilesName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/serviceArtifacts/{serviceArtifactName}/vmArtifactsProfiles/{vmArtifactsProfilesName}. # pylint: disable=line-too-long :paramtype service_artifact_reference: ~azure.mgmt.batch.models.ServiceArtifactReference """ super().__init__(**kwargs) @@ -5610,10 +6342,41 @@ def __init__(self, **kwargs: Any) -> None: self.core_quota = None +class VMDiskSecurityProfile(_serialization.Model): + """Specifies the security profile settings for the managed disk. **Note**\\ : It can only be set + for Confidential VMs and is required when using Confidential VMs. + + :ivar security_encryption_type: Specifies the EncryptionType of the managed disk. It is set to + VMGuestStateOnly for encryption of just the VMGuestState blob, and NonPersistedTPM for not + persisting firmware state in the VMGuestState blob. **Note**\\ : It can be set for only + Confidential VMs and required when using Confidential VMs. Known values are: "NonPersistedTPM" + and "VMGuestStateOnly". + :vartype security_encryption_type: str or ~azure.mgmt.batch.models.SecurityEncryptionTypes + """ + + _attribute_map = { + "security_encryption_type": {"key": "securityEncryptionType", "type": "str"}, + } + + def __init__( + self, *, security_encryption_type: Optional[Union[str, "_models.SecurityEncryptionTypes"]] = None, **kwargs: Any + ) -> None: + """ + :keyword security_encryption_type: Specifies the EncryptionType of the managed disk. It is set + to VMGuestStateOnly for encryption of just the VMGuestState blob, and NonPersistedTPM for not + persisting firmware state in the VMGuestState blob. **Note**\\ : It can be set for only + Confidential VMs and required when using Confidential VMs. Known values are: "NonPersistedTPM" + and "VMGuestStateOnly". + :paramtype security_encryption_type: str or ~azure.mgmt.batch.models.SecurityEncryptionTypes + """ + super().__init__(**kwargs) + self.security_encryption_type = security_encryption_type + + class VMExtension(_serialization.Model): """The configuration for virtual machine extensions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the virtual machine extension. Required. :vartype name: str @@ -5732,9 +6495,8 @@ def __init__(self, *, enable_automatic_updates: Optional[bool] = None, **kwargs: class WindowsUserConfiguration(_serialization.Model): """Properties used to create a user account on a Windows node. - :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. Known values are: "Batch" and "Interactive". + :ivar login_mode: Specifies login mode for the user. The default value is Interactive. Known + values are: "Batch" and "Interactive". :vartype login_mode: str or ~azure.mgmt.batch.models.LoginMode """ @@ -5744,9 +6506,8 @@ class WindowsUserConfiguration(_serialization.Model): def __init__(self, *, login_mode: Optional[Union[str, "_models.LoginMode"]] = None, **kwargs: Any) -> None: """ - :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. Known values are: "Batch" and "Interactive". + :keyword login_mode: Specifies login mode for the user. The default value is Interactive. Known + values are: "Batch" and "Interactive". :paramtype login_mode: str or ~azure.mgmt.batch.models.LoginMode """ super().__init__(**kwargs) 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 ec302145381b..5ef1210d26db 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 @@ -15,6 +15,7 @@ from ._private_link_resource_operations import PrivateLinkResourceOperations from ._private_endpoint_connection_operations import PrivateEndpointConnectionOperations from ._pool_operations import PoolOperations +from ._network_security_perimeter_operations import NetworkSecurityPerimeterOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -30,6 +31,7 @@ "PrivateLinkResourceOperations", "PrivateEndpointConnectionOperations", "PoolOperations", + "NetworkSecurityPerimeterOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() 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 46d90747a2c9..7c5e920613f2 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +46,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -82,7 +85,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -118,7 +121,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -154,7 +157,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -198,7 +201,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -272,7 +275,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Application or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Application :raises ~azure.core.exceptions.HttpResponseError: @@ -284,7 +286,7 @@ def create( resource_group_name: str, account_name: str, application_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -300,11 +302,10 @@ def create( Required. :type application_name: str :param parameters: The parameters for the request. Default value is None. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Application or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Application :raises ~azure.core.exceptions.HttpResponseError: @@ -316,7 +317,7 @@ def create( resource_group_name: str, account_name: str, application_name: str, - parameters: Optional[Union[_models.Application, IO]] = None, + parameters: Optional[Union[_models.Application, IO[bytes]]] = None, **kwargs: Any ) -> _models.Application: """Adds an application to the specified Batch account. @@ -329,18 +330,14 @@ def create( :param application_name: The name of the application. This must be unique within the account. Required. :type application_name: str - :param parameters: The parameters for the request. Is either a Application type or a IO type. - Default value is None. - :type parameters: ~azure.mgmt.batch.models.Application or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: The parameters for the request. Is either a Application type or a IO[bytes] + type. Default value is None. + :type parameters: ~azure.mgmt.batch.models.Application or IO[bytes] :return: Application or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Application :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -366,7 +363,7 @@ def create( else: _json = None - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, application_name=application_name, @@ -375,16 +372,14 @@ def create( content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -393,16 +388,12 @@ def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Application", pipeline_response) + deserialized = self._deserialize("Application", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -418,12 +409,11 @@ def delete( # pylint: disable=inconsistent-return-statements :param application_name: The name of the application. This must be unique within the account. Required. :type application_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -437,22 +427,20 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, application_name=application_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -462,11 +450,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -482,12 +466,11 @@ def get( :param application_name: The name of the application. This must be unique within the account. Required. :type application_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Application or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Application :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -501,22 +484,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Application] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, application_name=application_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -525,16 +506,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Application", pipeline_response) + deserialized = self._deserialize("Application", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationName}" - } + return deserialized # type: ignore @overload def update( @@ -562,7 +539,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Application or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Application :raises ~azure.core.exceptions.HttpResponseError: @@ -574,7 +550,7 @@ def update( resource_group_name: str, account_name: str, application_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -590,11 +566,10 @@ def update( Required. :type application_name: str :param parameters: The parameters for the request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Application or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Application :raises ~azure.core.exceptions.HttpResponseError: @@ -606,7 +581,7 @@ def update( resource_group_name: str, account_name: str, application_name: str, - parameters: Union[_models.Application, IO], + parameters: Union[_models.Application, IO[bytes]], **kwargs: Any ) -> _models.Application: """Updates settings for the specified application. @@ -619,18 +594,14 @@ def update( :param application_name: The name of the application. This must be unique within the account. Required. :type application_name: str - :param parameters: The parameters for the request. Is either a Application type or a IO type. - Required. - :type parameters: ~azure.mgmt.batch.models.Application or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: The parameters for the request. Is either a Application type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.batch.models.Application or IO[bytes] :return: Application or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Application :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -653,7 +624,7 @@ def update( else: _json = self._serialize.body(parameters, "Application") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, application_name=application_name, @@ -662,16 +633,14 @@ def update( content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -680,16 +649,12 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("Application", pipeline_response) + deserialized = self._deserialize("Application", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -705,7 +670,6 @@ def list( :param maxresults: The maximum number of items to return in the response. Default value is None. :type maxresults: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Application or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.Application] :raises ~azure.core.exceptions.HttpResponseError: @@ -716,7 +680,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ListApplicationsResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -727,18 +691,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxresults=maxresults, 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) else: # make call to next link with the client's api-version @@ -750,13 +712,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListApplicationsResult", pipeline_response) @@ -766,11 +727,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -781,7 +742,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications" - } 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 0b9b9a22d6c3..6ed170ffd5a0 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -48,7 +51,7 @@ def build_activate_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -95,7 +98,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -142,7 +145,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +189,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -231,7 +234,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -313,7 +316,6 @@ def activate( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationPackage or the result of cls(response) :rtype: ~azure.mgmt.batch.models.ApplicationPackage :raises ~azure.core.exceptions.HttpResponseError: @@ -326,7 +328,7 @@ def activate( account_name: str, application_name: str, version_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -346,11 +348,10 @@ def activate( :param version_name: The version of the application. Required. :type version_name: str :param parameters: The parameters for the request. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationPackage or the result of cls(response) :rtype: ~azure.mgmt.batch.models.ApplicationPackage :raises ~azure.core.exceptions.HttpResponseError: @@ -363,7 +364,7 @@ def activate( account_name: str, application_name: str, version_name: str, - parameters: Union[_models.ActivateApplicationPackageParameters, IO], + parameters: Union[_models.ActivateApplicationPackageParameters, IO[bytes]], **kwargs: Any ) -> _models.ApplicationPackage: """Activates the specified application package. This should be done after the @@ -381,17 +382,13 @@ def activate( :param version_name: The version of the application. Required. :type version_name: str :param parameters: The parameters for the request. Is either a - ActivateApplicationPackageParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.batch.models.ActivateApplicationPackageParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + ActivateApplicationPackageParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.batch.models.ActivateApplicationPackageParameters or IO[bytes] :return: ApplicationPackage or the result of cls(response) :rtype: ~azure.mgmt.batch.models.ApplicationPackage :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -414,7 +411,7 @@ def activate( else: _json = self._serialize.body(parameters, "ActivateApplicationPackageParameters") - request = build_activate_request( + _request = build_activate_request( resource_group_name=resource_group_name, account_name=account_name, application_name=application_name, @@ -424,16 +421,14 @@ def activate( content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -442,16 +437,12 @@ def activate( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationPackage", pipeline_response) + deserialized = self._deserialize("ApplicationPackage", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - activate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationName}/versions/{versionName}/activate" - } + return deserialized # type: ignore @overload def create( @@ -485,7 +476,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationPackage or the result of cls(response) :rtype: ~azure.mgmt.batch.models.ApplicationPackage :raises ~azure.core.exceptions.HttpResponseError: @@ -498,7 +488,7 @@ def create( account_name: str, application_name: str, version_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -519,11 +509,10 @@ def create( :param version_name: The version of the application. Required. :type version_name: str :param parameters: The parameters for the request. Default value is None. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationPackage or the result of cls(response) :rtype: ~azure.mgmt.batch.models.ApplicationPackage :raises ~azure.core.exceptions.HttpResponseError: @@ -536,7 +525,7 @@ def create( account_name: str, application_name: str, version_name: str, - parameters: Optional[Union[_models.ApplicationPackage, IO]] = None, + parameters: Optional[Union[_models.ApplicationPackage, IO[bytes]]] = None, **kwargs: Any ) -> _models.ApplicationPackage: """Creates an application package record. The record contains a storageUrl where the package @@ -554,18 +543,14 @@ def create( :type application_name: str :param version_name: The version of the application. Required. :type version_name: str - :param parameters: The parameters for the request. Is either a ApplicationPackage type or a IO - type. Default value is None. - :type parameters: ~azure.mgmt.batch.models.ApplicationPackage or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: The parameters for the request. Is either a ApplicationPackage type or a + IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.batch.models.ApplicationPackage or IO[bytes] :return: ApplicationPackage or the result of cls(response) :rtype: ~azure.mgmt.batch.models.ApplicationPackage :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -591,7 +576,7 @@ def create( else: _json = None - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, application_name=application_name, @@ -601,16 +586,14 @@ def create( content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -619,16 +602,12 @@ def create( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationPackage", pipeline_response) + deserialized = self._deserialize("ApplicationPackage", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationName}/versions/{versionName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -646,12 +625,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type application_name: str :param version_name: The version of the application. Required. :type version_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -665,23 +643,21 @@ def delete( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, application_name=application_name, version_name=version_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -691,11 +667,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationName}/versions/{versionName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -713,12 +685,11 @@ def get( :type application_name: str :param version_name: The version of the application. Required. :type version_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ApplicationPackage or the result of cls(response) :rtype: ~azure.mgmt.batch.models.ApplicationPackage :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -732,23 +703,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ApplicationPackage] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, application_name=application_name, version_name=version_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -757,16 +726,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ApplicationPackage", pipeline_response) + deserialized = self._deserialize("ApplicationPackage", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationName}/versions/{versionName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -790,7 +755,6 @@ def list( :param maxresults: The maximum number of items to return in the response. Default value is None. :type maxresults: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ApplicationPackage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.ApplicationPackage] :raises ~azure.core.exceptions.HttpResponseError: @@ -801,7 +765,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ListApplicationPackagesResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -812,19 +776,17 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, application_name=application_name, subscription_id=self._config.subscription_id, maxresults=maxresults, 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) else: # make call to next link with the client's api-version @@ -836,13 +798,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListApplicationPackagesResult", pipeline_response) @@ -852,11 +813,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -867,7 +828,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationName}/versions" - } 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 5a153240ee4c..e801056288a5 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -81,7 +86,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -117,7 +122,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -148,7 +153,7 @@ def build_get_request(resource_group_name: str, account_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -179,7 +184,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -203,7 +208,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -227,13 +232,13 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_synchronize_auto_storage_keys_request( +def build_synchronize_auto_storage_keys_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -266,7 +271,7 @@ def build_regenerate_key_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -302,7 +307,7 @@ def build_get_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -335,7 +340,7 @@ def build_list_detectors_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -368,7 +373,7 @@ def build_get_detector_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -396,13 +401,13 @@ def build_get_detector_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_outbound_network_dependencies_endpoints_request( +def build_list_outbound_network_dependencies_endpoints_request( # pylint: disable=name-too-long resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -452,10 +457,10 @@ def _create_initial( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BatchAccountCreateParameters, IO], + parameters: Union[_models.BatchAccountCreateParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.BatchAccount]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -468,7 +473,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.BatchAccount]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -478,7 +483,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "BatchAccountCreateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -486,41 +491,38 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("BatchAccount", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -549,14 +551,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either BatchAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.batch.models.BatchAccount] @@ -568,7 +562,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -586,18 +580,10 @@ def begin_create( http://accountname.region.batch.azure.com/. Required. :type account_name: str :param parameters: Additional parameters for account creation. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either BatchAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.batch.models.BatchAccount] @@ -609,7 +595,7 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BatchAccountCreateParameters, IO], + parameters: Union[_models.BatchAccountCreateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.BatchAccount]: """Creates a new Batch account with the specified parameters. Existing accounts cannot be updated @@ -625,19 +611,8 @@ def begin_create( http://accountname.region.batch.azure.com/. Required. :type account_name: str :param parameters: Additional parameters for account creation. Is either a - BatchAccountCreateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.batch.models.BatchAccountCreateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + BatchAccountCreateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.batch.models.BatchAccountCreateParameters or IO[bytes] :return: An instance of LROPoller that returns either BatchAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.batch.models.BatchAccount] @@ -664,12 +639,13 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("BatchAccount", pipeline_response) + deserialized = self._deserialize("BatchAccount", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -681,17 +657,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.BatchAccount].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}" - } + return LROPoller[_models.BatchAccount]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @overload def update( @@ -715,7 +689,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BatchAccount or the result of cls(response) :rtype: ~azure.mgmt.batch.models.BatchAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -726,7 +699,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -739,11 +712,10 @@ def update( :param account_name: The name of the Batch account. Required. :type account_name: str :param parameters: Additional parameters for account update. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BatchAccount or the result of cls(response) :rtype: ~azure.mgmt.batch.models.BatchAccount :raises ~azure.core.exceptions.HttpResponseError: @@ -754,7 +726,7 @@ def update( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BatchAccountUpdateParameters, IO], + parameters: Union[_models.BatchAccountUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.BatchAccount: """Updates the properties of an existing Batch account. @@ -765,17 +737,13 @@ def update( :param account_name: The name of the Batch account. Required. :type account_name: str :param parameters: Additional parameters for account update. Is either a - BatchAccountUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.batch.models.BatchAccountUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + BatchAccountUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.batch.models.BatchAccountUpdateParameters or IO[bytes] :return: BatchAccount or the result of cls(response) :rtype: ~azure.mgmt.batch.models.BatchAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -798,7 +766,7 @@ def update( else: _json = self._serialize.body(parameters, "BatchAccountUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -806,16 +774,14 @@ def update( content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -824,21 +790,15 @@ def update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("BatchAccount", pipeline_response) + deserialized = self._deserialize("BatchAccount", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, account_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -850,28 +810,31 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -880,12 +843,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: @@ -896,14 +859,6 @@ def begin_delete(self, resource_group_name: str, account_name: str, **kwargs: An :type resource_group_name: str :param account_name: The name of the Batch account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -917,7 +872,7 @@ def begin_delete(self, resource_group_name: str, account_name: str, **kwargs: An lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, @@ -926,11 +881,12 @@ def begin_delete(self, resource_group_name: str, account_name: str, **kwargs: An params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -941,17 +897,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.BatchAccount: @@ -962,12 +914,11 @@ def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _mo :type resource_group_name: str :param account_name: The name of the Batch account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BatchAccount or the result of cls(response) :rtype: ~azure.mgmt.batch.models.BatchAccount :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -981,21 +932,19 @@ def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _mo api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BatchAccount] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1004,22 +953,17 @@ def get(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _mo map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("BatchAccount", pipeline_response) + deserialized = self._deserialize("BatchAccount", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.BatchAccount"]: """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 :return: An iterator like instance of either BatchAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.BatchAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1030,7 +974,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.BatchAccount"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BatchAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1041,15 +985,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.BatchAccount"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) else: # make call to next link with the client's api-version @@ -1061,13 +1003,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("BatchAccountListResult", pipeline_response) @@ -1077,11 +1018,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1093,8 +1034,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Batch/batchAccounts"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.BatchAccount"]: """Gets information about the Batch accounts associated with the specified resource group. @@ -1102,7 +1041,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group that contains the Batch account. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BatchAccount or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.BatchAccount] :raises ~azure.core.exceptions.HttpResponseError: @@ -1113,7 +1051,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BatchAccountListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1124,16 +1062,14 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, 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) else: # make call to next link with the client's api-version @@ -1145,13 +1081,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("BatchAccountListResult", pipeline_response) @@ -1161,11 +1096,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1177,10 +1112,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts" - } - @distributed_trace def synchronize_auto_storage_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any @@ -1193,12 +1124,11 @@ def synchronize_auto_storage_keys( # pylint: disable=inconsistent-return-statem :type resource_group_name: str :param account_name: The name of the Batch account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1212,21 +1142,19 @@ def synchronize_auto_storage_keys( # pylint: disable=inconsistent-return-statem api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_synchronize_auto_storage_keys_request( + _request = build_synchronize_auto_storage_keys_request( resource_group_name=resource_group_name, account_name=account_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1236,11 +1164,7 @@ def synchronize_auto_storage_keys( # pylint: disable=inconsistent-return-statem raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - synchronize_auto_storage_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/syncAutoStorageKeys" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def regenerate_key( @@ -1269,7 +1193,6 @@ def regenerate_key( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BatchAccountKeys or the result of cls(response) :rtype: ~azure.mgmt.batch.models.BatchAccountKeys :raises ~azure.core.exceptions.HttpResponseError: @@ -1280,7 +1203,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1298,11 +1221,10 @@ def regenerate_key( :param account_name: The name of the Batch account. Required. :type account_name: str :param parameters: The type of key to regenerate. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BatchAccountKeys or the result of cls(response) :rtype: ~azure.mgmt.batch.models.BatchAccountKeys :raises ~azure.core.exceptions.HttpResponseError: @@ -1313,7 +1235,7 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - parameters: Union[_models.BatchAccountRegenerateKeyParameters, IO], + parameters: Union[_models.BatchAccountRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.BatchAccountKeys: """Regenerates the specified account key for the Batch account. @@ -1329,17 +1251,13 @@ def regenerate_key( :param account_name: The name of the Batch account. Required. :type account_name: str :param parameters: The type of key to regenerate. Is either a - BatchAccountRegenerateKeyParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.batch.models.BatchAccountRegenerateKeyParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + BatchAccountRegenerateKeyParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.batch.models.BatchAccountRegenerateKeyParameters or IO[bytes] :return: BatchAccountKeys or the result of cls(response) :rtype: ~azure.mgmt.batch.models.BatchAccountKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1362,7 +1280,7 @@ def regenerate_key( else: _json = self._serialize.body(parameters, "BatchAccountRegenerateKeyParameters") - request = build_regenerate_key_request( + _request = build_regenerate_key_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -1370,16 +1288,14 @@ def regenerate_key( content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1388,16 +1304,12 @@ def regenerate_key( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("BatchAccountKeys", pipeline_response) + deserialized = self._deserialize("BatchAccountKeys", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - regenerate_key.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/regenerateKeys" - } + return deserialized # type: ignore @distributed_trace def get_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.BatchAccountKeys: @@ -1413,12 +1325,11 @@ def get_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) - :type resource_group_name: str :param account_name: The name of the Batch account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BatchAccountKeys or the result of cls(response) :rtype: ~azure.mgmt.batch.models.BatchAccountKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1432,21 +1343,19 @@ def get_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BatchAccountKeys] = kwargs.pop("cls", None) - request = build_get_keys_request( + _request = build_get_keys_request( resource_group_name=resource_group_name, account_name=account_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1455,16 +1364,12 @@ def get_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) - map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("BatchAccountKeys", pipeline_response) + deserialized = self._deserialize("BatchAccountKeys", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_keys.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/listKeys" - } + return deserialized # type: ignore @distributed_trace def list_detectors( @@ -1477,7 +1382,6 @@ def list_detectors( :type resource_group_name: str :param account_name: The name of the Batch account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DetectorResponse or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.DetectorResponse] :raises ~azure.core.exceptions.HttpResponseError: @@ -1488,7 +1392,7 @@ def list_detectors( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DetectorListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1499,17 +1403,15 @@ def list_detectors( def prepare_request(next_link=None): if not next_link: - request = build_list_detectors_request( + _request = build_list_detectors_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, 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) else: # make call to next link with the client's api-version @@ -1521,13 +1423,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DetectorListResult", pipeline_response) @@ -1537,11 +1438,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1553,10 +1454,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_detectors.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/detectors" - } - @distributed_trace def get_detector( self, resource_group_name: str, account_name: str, detector_id: str, **kwargs: Any @@ -1570,12 +1467,11 @@ def get_detector( :type account_name: str :param detector_id: The name of the detector. Required. :type detector_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DetectorResponse or the result of cls(response) :rtype: ~azure.mgmt.batch.models.DetectorResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1589,22 +1485,20 @@ def get_detector( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DetectorResponse] = kwargs.pop("cls", None) - request = build_get_detector_request( + _request = build_get_detector_request( resource_group_name=resource_group_name, account_name=account_name, detector_id=detector_id, subscription_id=self._config.subscription_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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1613,19 +1507,15 @@ def get_detector( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DetectorResponse", pipeline_response) + deserialized = self._deserialize("DetectorResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_detector.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/detectors/{detectorId}" - } + return deserialized # type: ignore @distributed_trace - def list_outbound_network_dependencies_endpoints( + def list_outbound_network_dependencies_endpoints( # pylint: disable=name-too-long self, resource_group_name: str, account_name: str, **kwargs: Any ) -> Iterable["_models.OutboundEnvironmentEndpoint"]: """Lists the endpoints that a Batch Compute Node under this Batch Account may call as part of @@ -1640,7 +1530,6 @@ def list_outbound_network_dependencies_endpoints( :type resource_group_name: str :param account_name: The name of the Batch account. Required. :type account_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OutboundEnvironmentEndpoint or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.OutboundEnvironmentEndpoint] @@ -1652,7 +1541,7 @@ def list_outbound_network_dependencies_endpoints( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OutboundEnvironmentEndpointCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1663,17 +1552,15 @@ def list_outbound_network_dependencies_endpoints( def prepare_request(next_link=None): if not next_link: - request = build_list_outbound_network_dependencies_endpoints_request( + _request = build_list_outbound_network_dependencies_endpoints_request( resource_group_name=resource_group_name, account_name=account_name, 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) else: # make call to next link with the client's api-version @@ -1685,13 +1572,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OutboundEnvironmentEndpointCollection", pipeline_response) @@ -1701,11 +1587,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1716,7 +1602,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_outbound_network_dependencies_endpoints.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/outboundNetworkDependenciesEndpoints" - } 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 1fe0c5d35090..499accb1f93d 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +57,7 @@ def build_list_by_batch_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -98,7 +103,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -147,7 +152,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -188,7 +193,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -224,7 +229,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -260,7 +265,7 @@ def build_cancel_deletion_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -341,7 +346,6 @@ def list_by_batch_account( "properties/provisioningState", "properties/provisioningStateTransitionTime", "name". Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Certificate or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.Certificate] :raises ~azure.core.exceptions.HttpResponseError: @@ -352,7 +356,7 @@ def list_by_batch_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ListCertificatesResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -363,7 +367,7 @@ def list_by_batch_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_batch_account_request( + _request = build_list_by_batch_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -371,12 +375,10 @@ def prepare_request(next_link=None): select=select, filter=filter, api_version=api_version, - 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) else: # make call to next link with the client's api-version @@ -388,13 +390,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListCertificatesResult", pipeline_response) @@ -404,11 +405,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -420,10 +421,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_batch_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/certificates" - } - @overload def create( self, @@ -464,7 +461,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: @@ -476,7 +472,7 @@ def create( resource_group_name: str, account_name: str, certificate_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -499,7 +495,7 @@ def create( example SHA1-a3d1c5. Required. :type certificate_name: str :param parameters: Additional parameters for certificate creation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The entity state (ETag) version of the certificate to update. A value of "*" can be used to apply the operation only if the certificate already exists. If omitted, this operation will always be applied. Default value is None. @@ -510,7 +506,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: @@ -522,7 +517,7 @@ def create( resource_group_name: str, account_name: str, certificate_name: str, - parameters: Union[_models.CertificateCreateOrUpdateParameters, IO], + parameters: Union[_models.CertificateCreateOrUpdateParameters, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -543,8 +538,8 @@ def create( example SHA1-a3d1c5. Required. :type certificate_name: str :param parameters: Additional parameters for certificate creation. Is either a - CertificateCreateOrUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.batch.models.CertificateCreateOrUpdateParameters or IO + CertificateCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.batch.models.CertificateCreateOrUpdateParameters or IO[bytes] :param if_match: The entity state (ETag) version of the certificate to update. A value of "*" can be used to apply the operation only if the certificate already exists. If omitted, this operation will always be applied. Default value is None. @@ -552,15 +547,11 @@ def create( :param if_none_match: Set to '*' to allow a new certificate to be created, but to prevent updating an existing certificate. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -583,7 +574,7 @@ def create( else: _json = self._serialize.body(parameters, "CertificateCreateOrUpdateParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, certificate_name=certificate_name, @@ -594,16 +585,14 @@ def create( content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -615,16 +604,12 @@ def create( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Certificate", pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/certificates/{certificateName}" - } + return deserialized # type: ignore @overload def update( @@ -661,7 +646,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: @@ -673,7 +657,7 @@ def update( resource_group_name: str, account_name: str, certificate_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -695,14 +679,13 @@ def update( example SHA1-a3d1c5. Required. :type certificate_name: str :param parameters: Certificate entity to update. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The entity state (ETag) version of the certificate to update. This value can be omitted or set to "*" to apply the operation unconditionally. Default value is None. :type if_match: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: @@ -714,7 +697,7 @@ def update( resource_group_name: str, account_name: str, certificate_name: str, - parameters: Union[_models.CertificateCreateOrUpdateParameters, IO], + parameters: Union[_models.CertificateCreateOrUpdateParameters, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> _models.Certificate: @@ -734,20 +717,16 @@ def update( example SHA1-a3d1c5. Required. :type certificate_name: str :param parameters: Certificate entity to update. Is either a - CertificateCreateOrUpdateParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.batch.models.CertificateCreateOrUpdateParameters or IO + CertificateCreateOrUpdateParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.batch.models.CertificateCreateOrUpdateParameters or IO[bytes] :param if_match: The entity state (ETag) version of the certificate to update. This value can be omitted or set to "*" to apply the operation unconditionally. Default value is None. :type if_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -770,7 +749,7 @@ def update( else: _json = self._serialize.body(parameters, "CertificateCreateOrUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, certificate_name=certificate_name, @@ -780,16 +759,14 @@ def update( content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -801,21 +778,17 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Certificate", pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/certificates/{certificateName}" - } + return deserialized # type: ignore - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, account_name: str, certificate_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -827,29 +800,32 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, certificate_name=certificate_name, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -858,12 +834,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/certificates/{certificateName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -884,14 +860,6 @@ def begin_delete( and thumbprint separated by a dash, and must match the certificate data in the request. For example SHA1-a3d1c5. Required. :type certificate_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -905,7 +873,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, account_name=account_name, certificate_name=certificate_name, @@ -915,11 +883,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -930,17 +899,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/certificates/{certificateName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get( @@ -961,12 +926,11 @@ def get( and thumbprint separated by a dash, and must match the certificate data in the request. For example SHA1-a3d1c5. Required. :type certificate_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -980,22 +944,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Certificate] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, certificate_name=certificate_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1007,16 +969,12 @@ def get( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Certificate", pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/certificates/{certificateName}" - } + return deserialized # type: ignore @distributed_trace def cancel_deletion( @@ -1044,12 +1002,11 @@ def cancel_deletion( and thumbprint separated by a dash, and must match the certificate data in the request. For example SHA1-a3d1c5. Required. :type certificate_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Certificate :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1063,22 +1020,20 @@ def cancel_deletion( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Certificate] = kwargs.pop("cls", None) - request = build_cancel_deletion_request( + _request = build_cancel_deletion_request( resource_group_name=resource_group_name, account_name=account_name, certificate_name=certificate_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1090,13 +1045,9 @@ def cancel_deletion( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Certificate", pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - cancel_deletion.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/certificates/{certificateName}/cancelDelete" - } + return deserialized # type: ignore 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 b1e025f03209..4736e41195d1 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, overload import urllib.parse from azure.core.exceptions import ( @@ -20,16 +21,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +44,7 @@ def build_get_quotas_request(location_name: str, subscription_id: str, **kwargs: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +67,7 @@ def build_get_quotas_request(location_name: str, subscription_id: str, **kwargs: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_supported_virtual_machine_skus_request( +def build_list_supported_virtual_machine_skus_request( # pylint: disable=name-too-long location_name: str, subscription_id: str, *, @@ -75,7 +78,7 @@ def build_list_supported_virtual_machine_skus_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -103,50 +106,11 @@ def build_list_supported_virtual_machine_skus_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_supported_cloud_service_skus_request( - location_name: str, - subscription_id: str, - *, - maxresults: Optional[int] = None, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - accept = _headers.pop("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 = { - "locationName": _SERIALIZER.url("location_name", location_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if maxresults is not None: - _params["maxresults"] = _SERIALIZER.query("maxresults", maxresults, "int") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - def build_check_name_availability_request(location_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -198,12 +162,11 @@ def get_quotas(self, location_name: str, **kwargs: Any) -> _models.BatchLocation :param location_name: The region for which to retrieve Batch service quotas. Required. :type location_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BatchLocationQuota or the result of cls(response) :rtype: ~azure.mgmt.batch.models.BatchLocationQuota :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -217,20 +180,18 @@ def get_quotas(self, location_name: str, **kwargs: Any) -> _models.BatchLocation api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.BatchLocationQuota] = kwargs.pop("cls", None) - request = build_get_quotas_request( + _request = build_get_quotas_request( location_name=location_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -239,16 +200,12 @@ def get_quotas(self, location_name: str, **kwargs: Any) -> _models.BatchLocation map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("BatchLocationQuota", pipeline_response) + deserialized = self._deserialize("BatchLocationQuota", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_quotas.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Batch/locations/{locationName}/quotas" - } + return deserialized # type: ignore @distributed_trace def list_supported_virtual_machine_skus( @@ -264,102 +221,6 @@ def list_supported_virtual_machine_skus( :param filter: OData filter expression. Valid properties for filtering are "familyName". Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SupportedSku or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.SupportedSku] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SupportedSkusResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_supported_virtual_machine_skus_request( - location_name=location_name, - subscription_id=self._config.subscription_id, - maxresults=maxresults, - filter=filter, - api_version=api_version, - 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) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SupportedSkusResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_supported_virtual_machine_skus.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Batch/locations/{locationName}/virtualMachineSkus" - } - - @distributed_trace - def list_supported_cloud_service_skus( - self, location_name: str, maxresults: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.SupportedSku"]: - """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. Required. - :type location_name: str - :param maxresults: The maximum number of items to return in the response. Default value is - None. - :type maxresults: int - :param filter: OData filter expression. Valid properties for filtering are "familyName". - Default value is None. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SupportedSku or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.SupportedSku] :raises ~azure.core.exceptions.HttpResponseError: @@ -370,7 +231,7 @@ def list_supported_cloud_service_skus( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SupportedSkusResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -381,18 +242,16 @@ def list_supported_cloud_service_skus( def prepare_request(next_link=None): if not next_link: - request = build_list_supported_cloud_service_skus_request( + _request = build_list_supported_virtual_machine_skus_request( location_name=location_name, subscription_id=self._config.subscription_id, maxresults=maxresults, filter=filter, api_version=api_version, - 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) else: # make call to next link with the client's api-version @@ -404,13 +263,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SupportedSkusResult", pipeline_response) @@ -420,11 +278,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -436,10 +294,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_supported_cloud_service_skus.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Batch/locations/{locationName}/cloudServiceSkus" - } - @overload def check_name_availability( self, @@ -458,7 +312,6 @@ def check_name_availability( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.batch.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -466,18 +319,17 @@ def check_name_availability( @overload def check_name_availability( - self, location_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, location_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks whether the Batch account name is available in the specified region. :param location_name: The desired region for the name check. Required. :type location_name: str :param parameters: Properties needed to check the availability of a name. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.batch.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: @@ -485,24 +337,20 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, location_name: str, parameters: Union[_models.CheckNameAvailabilityParameters, IO], **kwargs: Any + self, location_name: str, parameters: Union[_models.CheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks whether the Batch account name is available in the specified region. :param location_name: The desired region for the name check. Required. :type location_name: str :param parameters: Properties needed to check the availability of a name. Is either a - CheckNameAvailabilityParameters type or a IO type. Required. - :type parameters: ~azure.mgmt.batch.models.CheckNameAvailabilityParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + CheckNameAvailabilityParameters type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.batch.models.CheckNameAvailabilityParameters or IO[bytes] :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.batch.models.CheckNameAvailabilityResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -525,23 +373,21 @@ def check_name_availability( else: _json = self._serialize.body(parameters, "CheckNameAvailabilityParameters") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( location_name=location_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -550,13 +396,9 @@ def check_name_availability( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Batch/locations/{locationName}/checkNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_network_security_perimeter_operations.py b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_network_security_perimeter_operations.py new file mode 100644 index 000000000000..20614db6b24a --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/azure/mgmt/batch/operations/_network_security_perimeter_operations.py @@ -0,0 +1,457 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Iterator, Optional, Type, TypeVar, Union, cast +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +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 .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_configurations_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/networkSecurityPerimeterConfigurations", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-zA-Z0-9]+$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_configuration_request( + resource_group_name: str, + account_name: str, + network_security_perimeter_configuration_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/networkSecurityPerimeterConfigurations/{networkSecurityPerimeterConfigurationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-zA-Z0-9]+$" + ), + "networkSecurityPerimeterConfigurationName": _SERIALIZER.url( + "network_security_perimeter_configuration_name", + network_security_perimeter_configuration_name, + "str", + pattern=r"^.*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_reconcile_configuration_request( + resource_group_name: str, + account_name: str, + network_security_perimeter_configuration_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/networkSecurityPerimeterConfigurations/{networkSecurityPerimeterConfigurationName}/reconcile", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "accountName": _SERIALIZER.url( + "account_name", account_name, "str", max_length=24, min_length=3, pattern=r"^[a-zA-Z0-9]+$" + ), + "networkSecurityPerimeterConfigurationName": _SERIALIZER.url( + "network_security_perimeter_configuration_name", + network_security_perimeter_configuration_name, + "str", + pattern=r"^.*$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class NetworkSecurityPerimeterOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.batch.BatchManagementClient`'s + :attr:`network_security_perimeter` attribute. + """ + + models = _models + + 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_configurations( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.NetworkSecurityPerimeterConfiguration"]: + """Lists all of the NSP configurations in the specified account. + + :param resource_group_name: The name of the resource group that contains the Batch account. + Required. + :type resource_group_name: str + :param account_name: The name of the Batch account. Required. + :type account_name: str + :return: An iterator like instance of either NetworkSecurityPerimeterConfiguration or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.NetworkSecurityPerimeterConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NetworkSecurityPerimeterConfigurationListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_configurations_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("NetworkSecurityPerimeterConfigurationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_configuration( + self, + resource_group_name: str, + account_name: str, + network_security_perimeter_configuration_name: str, + **kwargs: Any + ) -> _models.NetworkSecurityPerimeterConfiguration: + """Gets information about the specified NSP configuration. + + :param resource_group_name: The name of the resource group that contains the Batch account. + Required. + :type resource_group_name: str + :param account_name: The name of the Batch account. Required. + :type account_name: str + :param network_security_perimeter_configuration_name: The name for Network Security Perimeter + configuration. Required. + :type network_security_perimeter_configuration_name: str + :return: NetworkSecurityPerimeterConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.batch.models.NetworkSecurityPerimeterConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NetworkSecurityPerimeterConfiguration] = kwargs.pop("cls", None) + + _request = build_get_configuration_request( + resource_group_name=resource_group_name, + account_name=account_name, + network_security_perimeter_configuration_name=network_security_perimeter_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NetworkSecurityPerimeterConfiguration", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _reconcile_configuration_initial( + self, + resource_group_name: str, + account_name: str, + network_security_perimeter_configuration_name: str, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_reconcile_configuration_request( + resource_group_name=resource_group_name, + account_name=account_name, + network_security_perimeter_configuration_name=network_security_perimeter_configuration_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_reconcile_configuration( + self, + resource_group_name: str, + account_name: str, + network_security_perimeter_configuration_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Reconciles the specified NSP configuration. + + :param resource_group_name: The name of the resource group that contains the Batch account. + Required. + :type resource_group_name: str + :param account_name: The name of the Batch account. Required. + :type account_name: str + :param network_security_perimeter_configuration_name: The name for Network Security Perimeter + configuration. Required. + :type network_security_perimeter_configuration_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._reconcile_configuration_initial( + resource_group_name=resource_group_name, + account_name=account_name, + network_security_perimeter_configuration_name=network_security_perimeter_configuration_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 1ee446d2329b..b9e0a50dd2b7 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +81,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists available operations for the Microsoft.Batch provider. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -89,7 +91,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,14 +102,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) else: # make call to next link with the client's api-version @@ -119,13 +119,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -135,11 +134,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -150,5 +149,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Batch/operations"} 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 367ed9be029a..0e732612b695 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +57,7 @@ def build_list_by_batch_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -98,7 +103,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -147,7 +152,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -188,7 +193,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -224,7 +229,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -260,7 +265,7 @@ def build_disable_auto_scale_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -296,7 +301,7 @@ def build_stop_resize_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -383,7 +388,6 @@ def list_by_batch_account( properties/scaleSettings/autoScale properties/scaleSettings/fixedScale. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Pool or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.Pool] :raises ~azure.core.exceptions.HttpResponseError: @@ -394,7 +398,7 @@ def list_by_batch_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ListPoolsResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -405,7 +409,7 @@ def list_by_batch_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_batch_account_request( + _request = build_list_by_batch_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, @@ -413,12 +417,10 @@ def prepare_request(next_link=None): select=select, filter=filter, api_version=api_version, - 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) else: # make call to next link with the client's api-version @@ -430,13 +432,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListPoolsResult", pipeline_response) @@ -446,11 +447,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -462,10 +463,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_batch_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/pools" - } - @overload def create( self, @@ -500,7 +497,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Pool or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Pool :raises ~azure.core.exceptions.HttpResponseError: @@ -512,7 +508,7 @@ def create( resource_group_name: str, account_name: str, pool_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -529,7 +525,7 @@ def create( :param pool_name: The pool name. This must be unique within the account. Required. :type pool_name: str :param parameters: Additional parameters for pool creation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The entity state (ETag) version of the pool to update. A value of "*" can be used to apply the operation only if the pool already exists. If omitted, this operation will always be applied. Default value is None. @@ -540,7 +536,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Pool or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Pool :raises ~azure.core.exceptions.HttpResponseError: @@ -552,7 +547,7 @@ def create( resource_group_name: str, account_name: str, pool_name: str, - parameters: Union[_models.Pool, IO], + parameters: Union[_models.Pool, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -566,9 +561,9 @@ def create( :type account_name: str :param pool_name: The pool name. This must be unique within the account. Required. :type pool_name: str - :param parameters: Additional parameters for pool creation. Is either a Pool type or a IO type. - Required. - :type parameters: ~azure.mgmt.batch.models.Pool or IO + :param parameters: Additional parameters for pool creation. Is either a Pool type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.batch.models.Pool or IO[bytes] :param if_match: The entity state (ETag) version of the pool to update. A value of "*" can be used to apply the operation only if the pool already exists. If omitted, this operation will always be applied. Default value is None. @@ -576,15 +571,11 @@ def create( :param if_none_match: Set to '*' to allow a new pool to be created, but to prevent updating an existing pool. Other values will be ignored. Default value is None. :type if_none_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Pool or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Pool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -607,7 +598,7 @@ def create( else: _json = self._serialize.body(parameters, "Pool") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -618,16 +609,14 @@ def create( content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -639,16 +628,12 @@ def create( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Pool", pipeline_response) + deserialized = self._deserialize("Pool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/pools/{poolName}" - } + return deserialized # type: ignore @overload def update( @@ -680,7 +665,6 @@ def update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Pool or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Pool :raises ~azure.core.exceptions.HttpResponseError: @@ -692,7 +676,7 @@ def update( resource_group_name: str, account_name: str, pool_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -709,14 +693,13 @@ def update( :type pool_name: str :param parameters: Pool properties that should be updated. Properties that are supplied will be updated, any property not supplied will be unchanged. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The entity state (ETag) version of the pool to update. This value can be omitted or set to "*" to apply the operation unconditionally. Default value is None. :type if_match: str :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Pool or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Pool :raises ~azure.core.exceptions.HttpResponseError: @@ -728,7 +711,7 @@ def update( resource_group_name: str, account_name: str, pool_name: str, - parameters: Union[_models.Pool, IO], + parameters: Union[_models.Pool, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> _models.Pool: @@ -742,21 +725,17 @@ def update( :param pool_name: The pool name. This must be unique within the account. Required. :type pool_name: str :param parameters: Pool properties that should be updated. Properties that are supplied will be - updated, any property not supplied will be unchanged. Is either a Pool type or a IO type. - Required. - :type parameters: ~azure.mgmt.batch.models.Pool or IO + updated, any property not supplied will be unchanged. Is either a Pool type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.batch.models.Pool or IO[bytes] :param if_match: The entity state (ETag) version of the pool to update. This value can be omitted or set to "*" to apply the operation unconditionally. Default value is None. :type if_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Pool or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Pool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -779,7 +758,7 @@ def update( else: _json = self._serialize.body(parameters, "Pool") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -789,16 +768,14 @@ def update( content_type=content_type, json=_json, content=_content, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -810,21 +787,17 @@ def update( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Pool", pipeline_response) + deserialized = self._deserialize("Pool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized + return deserialized # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/pools/{poolName}" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, account_name: str, pool_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -836,29 +809,32 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -867,12 +843,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/pools/{poolName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -887,14 +863,6 @@ def begin_delete( :type account_name: str :param pool_name: The pool name. This must be unique within the account. Required. :type pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -908,7 +876,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, @@ -918,11 +886,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -933,17 +902,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/pools/{poolName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get(self, resource_group_name: str, account_name: str, pool_name: str, **kwargs: Any) -> _models.Pool: @@ -956,12 +921,11 @@ def get(self, resource_group_name: str, account_name: str, pool_name: str, **kwa :type account_name: str :param pool_name: The pool name. This must be unique within the account. Required. :type pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Pool or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Pool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -975,22 +939,20 @@ def get(self, resource_group_name: str, account_name: str, pool_name: str, **kwa api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Pool] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1002,16 +964,12 @@ def get(self, resource_group_name: str, account_name: str, pool_name: str, **kwa response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Pool", pipeline_response) + deserialized = self._deserialize("Pool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/pools/{poolName}" - } + return deserialized # type: ignore @distributed_trace def disable_auto_scale( @@ -1026,12 +984,11 @@ def disable_auto_scale( :type account_name: str :param pool_name: The pool name. This must be unique within the account. Required. :type pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Pool or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Pool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1045,22 +1002,20 @@ def disable_auto_scale( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Pool] = kwargs.pop("cls", None) - request = build_disable_auto_scale_request( + _request = build_disable_auto_scale_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1072,16 +1027,12 @@ def disable_auto_scale( response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Pool", pipeline_response) + deserialized = self._deserialize("Pool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - disable_auto_scale.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/pools/{poolName}/disableAutoScale" - } + return deserialized # type: ignore @distributed_trace def stop_resize(self, resource_group_name: str, account_name: str, pool_name: str, **kwargs: Any) -> _models.Pool: @@ -1101,12 +1052,11 @@ def stop_resize(self, resource_group_name: str, account_name: str, pool_name: st :type account_name: str :param pool_name: The pool name. This must be unique within the account. Required. :type pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Pool or the result of cls(response) :rtype: ~azure.mgmt.batch.models.Pool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1120,22 +1070,20 @@ def stop_resize(self, resource_group_name: str, account_name: str, pool_name: st api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Pool] = kwargs.pop("cls", None) - request = build_stop_resize_request( + _request = build_stop_resize_request( resource_group_name=resource_group_name, account_name=account_name, pool_name=pool_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1147,13 +1095,9 @@ def stop_resize(self, resource_group_name: str, account_name: str, pool_name: st response_headers = {} response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize("Pool", pipeline_response) + deserialized = self._deserialize("Pool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - stop_resize.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/pools/{poolName}/stopResize" - } + return deserialized # type: ignore 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 a7ba1f57fbbb..1b2b8ee591cd 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +55,7 @@ def build_list_by_batch_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,7 +94,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -136,7 +141,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -186,7 +191,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -254,7 +259,6 @@ def list_by_batch_account( :param maxresults: The maximum number of items to return in the response. Default value is None. :type maxresults: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.PrivateEndpointConnection] @@ -266,7 +270,7 @@ def list_by_batch_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ListPrivateEndpointConnectionsResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -277,18 +281,16 @@ def list_by_batch_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_batch_account_request( + _request = build_list_by_batch_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxresults=maxresults, api_version=api_version, - 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) else: # make call to next link with the client's api-version @@ -300,13 +302,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListPrivateEndpointConnectionsResult", pipeline_response) @@ -316,11 +317,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -332,10 +333,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_batch_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/privateEndpointConnections" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -350,12 +347,11 @@ def get( :param private_endpoint_connection_name: The private endpoint connection name. This must be unique within the account. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.batch.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -369,22 +365,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -393,27 +387,23 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore def _update_initial( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.PrivateEndpointConnection]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -426,7 +416,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -436,7 +426,7 @@ def _update_initial( else: _json = self._serialize.body(parameters, "PrivateEndpointConnection") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -446,41 +436,38 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -514,14 +501,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.batch.models.PrivateEndpointConnection] @@ -534,7 +513,7 @@ def begin_update( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -552,7 +531,7 @@ def begin_update( :type private_endpoint_connection_name: str :param parameters: PrivateEndpointConnection properties that should be updated. Properties that are supplied will be updated, any property not supplied will be unchanged. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The state (ETag) version of the private endpoint connection to update. This value can be omitted or set to "*" to apply the operation unconditionally. Default value is None. @@ -560,14 +539,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.batch.models.PrivateEndpointConnection] @@ -580,7 +551,7 @@ def begin_update( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> LROPoller[_models.PrivateEndpointConnection]: @@ -596,23 +567,12 @@ def begin_update( :type private_endpoint_connection_name: str :param parameters: PrivateEndpointConnection properties that should be updated. Properties that are supplied will be updated, any property not supplied will be unchanged. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type parameters: ~azure.mgmt.batch.models.PrivateEndpointConnection or IO + PrivateEndpointConnection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.batch.models.PrivateEndpointConnection or IO[bytes] :param if_match: The state (ETag) version of the private endpoint connection to update. This value can be omitted or set to "*" to apply the operation unconditionally. Default value is None. :type if_match: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.batch.models.PrivateEndpointConnection] @@ -641,12 +601,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -658,22 +619,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.PrivateEndpointConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return LROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -685,29 +644,32 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) @@ -716,12 +678,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -737,14 +699,6 @@ def begin_delete( :param private_endpoint_connection_name: The private endpoint connection name. This must be unique within the account. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -758,7 +712,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, account_name=account_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -768,11 +722,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -783,14 +738,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 fb3531096de6..ba62577ca744 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # 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 +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +50,7 @@ def build_list_by_batch_account_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -82,7 +85,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -150,7 +153,6 @@ def list_by_batch_account( :param maxresults: The maximum number of items to return in the response. Default value is None. :type maxresults: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.batch.models.PrivateLinkResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -161,7 +163,7 @@ def list_by_batch_account( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ListPrivateLinkResourcesResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -172,18 +174,16 @@ def list_by_batch_account( def prepare_request(next_link=None): if not next_link: - request = build_list_by_batch_account_request( + _request = build_list_by_batch_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, maxresults=maxresults, api_version=api_version, - 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) else: # make call to next link with the client's api-version @@ -195,13 +195,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListPrivateLinkResourcesResult", pipeline_response) @@ -211,11 +210,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -227,10 +226,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_batch_account.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/privateLinkResources" - } - @distributed_trace def get( self, resource_group_name: str, account_name: str, private_link_resource_name: str, **kwargs: Any @@ -245,12 +240,11 @@ def get( :param private_link_resource_name: The private link resource name. This must be unique within the account. Required. :type private_link_resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.batch.models.PrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -264,22 +258,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, private_link_resource_name=private_link_resource_name, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -288,13 +280,9 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateLinkResource", pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/privateLinkResources/{privateLinkResourceName}" - } + return deserialized # type: ignore diff --git a/sdk/batch/azure-mgmt-batch/dev_requirements.txt b/sdk/batch/azure-mgmt-batch/dev_requirements.txt index 6fd0a84811c1..ccaf6eec98ab 100644 --- a/sdk/batch/azure-mgmt-batch/dev_requirements.txt +++ b/sdk/batch/azure-mgmt-batch/dev_requirements.txt @@ -3,4 +3,5 @@ azure-mgmt-keyvault<9.0.0 azure-mgmt-network<19.0.0 -e ../../resources/azure-mgmt-resource -e ../../storage/azure-mgmt-storage -../../identity/azure-identity \ No newline at end of file +../../identity/azure-identity +aiohttp \ No newline at end of file diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/application_create.py b/sdk/batch/azure-mgmt-batch/generated_samples/application_create.py index 665b0d1fce99..34f50204d9b0 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/application_create.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/application_create.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/ApplicationCreate.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationCreate.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/application_delete.py b/sdk/batch/azure-mgmt-batch/generated_samples/application_delete.py index 5439cb19777d..a6512f1a05e3 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/application_delete.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/application_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -36,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/ApplicationDelete.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationDelete.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/application_get.py b/sdk/batch/azure-mgmt-batch/generated_samples/application_get.py index 3ac290349d86..5a75bbcc6106 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/application_get.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/application_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/ApplicationGet.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationGet.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/application_list.py b/sdk/batch/azure-mgmt-batch/generated_samples/application_list.py index 224c4b36ae05..f0cd27842e14 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/application_list.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/application_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/ApplicationList.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationList.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/application_package_activate.py b/sdk/batch/azure-mgmt-batch/generated_samples/application_package_activate.py index 5e5a7fbab8fa..b27b0a8b0919 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/application_package_activate.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/application_package_activate.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -39,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/ApplicationPackageActivate.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationPackageActivate.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/application_package_create.py b/sdk/batch/azure-mgmt-batch/generated_samples/application_package_create.py index f4f335d12895..e248723330f5 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/application_package_create.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/application_package_create.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/ApplicationPackageCreate.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationPackageCreate.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/application_package_delete.py b/sdk/batch/azure-mgmt-batch/generated_samples/application_package_delete.py index 1af5d5210a35..a94b5a1eca26 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/application_package_delete.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/application_package_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/ApplicationPackageDelete.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationPackageDelete.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/application_package_get.py b/sdk/batch/azure-mgmt-batch/generated_samples/application_package_get.py index 69edf7dc8eb3..d2bc057a5abf 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/application_package_get.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/application_package_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/ApplicationPackageGet.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationPackageGet.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/application_package_list.py b/sdk/batch/azure-mgmt-batch/generated_samples/application_package_list.py index 24d07c502faa..67043d2ba0ca 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/application_package_list.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/application_package_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/ApplicationPackageList.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationPackageList.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/application_update.py b/sdk/batch/azure-mgmt-batch/generated_samples/application_update.py index fd5b2a6f08a6..a0172a60f638 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/application_update.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/application_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/ApplicationUpdate.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationUpdate.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_create_byos.py b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_create_byos.py index 4dd016bd3a4d..5cd3815907b4 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_create_byos.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_create_byos.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -49,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/BatchAccountCreate_BYOS.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountCreate_BYOS.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_create_default.py b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_create_default.py index cf091e901d36..c3064b90c897 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_create_default.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_create_default.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -44,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/BatchAccountCreate_Default.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountCreate_Default.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_create_system_assigned_identity.py b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_create_system_assigned_identity.py index 9ac89ff05686..fd9f89729767 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_create_system_assigned_identity.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_create_system_assigned_identity.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/BatchAccountCreate_SystemAssignedIdentity.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountCreate_SystemAssignedIdentity.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_create_user_assigned_identity.py b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_create_user_assigned_identity.py index 5a1c5b366a7f..7be4a8fd84ab 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_create_user_assigned_identity.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_create_user_assigned_identity.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -50,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/BatchAccountCreate_UserAssignedIdentity.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountCreate_UserAssignedIdentity.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_delete.py b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_delete.py index e8f4c0185650..5a196dc7c3b0 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_delete.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/BatchAccountDelete.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountDelete.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_get.py b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_get.py index 60ba05ebbc0a..44e3146e0a14 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_get.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/BatchAccountGet.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountGet.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_get_keys.py b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_get_keys.py index e05addae2840..6175279ae1cc 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_get_keys.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_get_keys.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/BatchAccountGetKeys.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountGetKeys.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_list.py b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_list.py index 2756f73441b6..85328ef76678 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_list.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/BatchAccountList.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountList.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_list_by_resource_group.py b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_list_by_resource_group.py index 7a77ae639e8d..0f65e3eb1dbc 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_list_by_resource_group.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_list_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/BatchAccountListByResourceGroup.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_list_outbound_network_dependencies_endpoints.py b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_list_outbound_network_dependencies_endpoints.py index d4d98d0de887..be4d250ec533 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_list_outbound_network_dependencies_endpoints.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_list_outbound_network_dependencies_endpoints.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/BatchAccountListOutboundNetworkDependenciesEndpoints.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountListOutboundNetworkDependenciesEndpoints.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_regenerate_key.py b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_regenerate_key.py index 692b58bba6e5..cdd3bd61cc9d 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_regenerate_key.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_regenerate_key.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/BatchAccountRegenerateKey.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountRegenerateKey.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_synchronize_auto_storage_keys.py b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_synchronize_auto_storage_keys.py index 843fa2dc651b..92dac77ca475 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_synchronize_auto_storage_keys.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_synchronize_auto_storage_keys.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -35,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/BatchAccountSynchronizeAutoStorageKeys.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountSynchronizeAutoStorageKeys.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_update.py b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_update.py index 8c131a724592..4839ece6557b 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_update.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/batch_account_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -43,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/BatchAccountUpdate.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountUpdate.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/certificate_cancel_deletion.py b/sdk/batch/azure-mgmt-batch/generated_samples/certificate_cancel_deletion.py index 242f0ab57a58..68de8cce5ea7 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/certificate_cancel_deletion.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/certificate_cancel_deletion.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateCancelDeletion.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateCancelDeletion.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/certificate_create_full.py b/sdk/batch/azure-mgmt-batch/generated_samples/certificate_create_full.py index ff3e26a6bab5..1dd002f3dcf0 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/certificate_create_full.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/certificate_create_full.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateCreate_Full.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateCreate_Full.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/certificate_create_minimal.py b/sdk/batch/azure-mgmt-batch/generated_samples/certificate_create_minimal.py index 09e22392f50d..8b355229de18 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/certificate_create_minimal.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/certificate_create_minimal.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateCreate_Minimal.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateCreate_Minimal.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/certificate_create_minimal_cer.py b/sdk/batch/azure-mgmt-batch/generated_samples/certificate_create_minimal_cer.py index 8d748613d985..ea196367a908 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/certificate_create_minimal_cer.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/certificate_create_minimal_cer.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateCreate_MinimalCer.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateCreate_MinimalCer.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/certificate_delete.py b/sdk/batch/azure-mgmt-batch/generated_samples/certificate_delete.py index 92d0c2d8a62f..2fc0c7772202 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/certificate_delete.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/certificate_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateDelete.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateDelete.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/certificate_get.py b/sdk/batch/azure-mgmt-batch/generated_samples/certificate_get.py index f51586e006b3..c77e177cf139 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/certificate_get.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/certificate_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateGet.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateGet.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/certificate_get_with_deletion_error.py b/sdk/batch/azure-mgmt-batch/generated_samples/certificate_get_with_deletion_error.py index 9748611630e0..d7c54aa0b525 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/certificate_get_with_deletion_error.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/certificate_get_with_deletion_error.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateGetWithDeletionError.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateGetWithDeletionError.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/certificate_list.py b/sdk/batch/azure-mgmt-batch/generated_samples/certificate_list.py index 3f7eab54d6ea..595cb2bc613e 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/certificate_list.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/certificate_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateList.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateList.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/certificate_list_with_filter.py b/sdk/batch/azure-mgmt-batch/generated_samples/certificate_list_with_filter.py index 6e49caf9325b..012e30783098 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/certificate_list_with_filter.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/certificate_list_with_filter.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateListWithFilter.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateListWithFilter.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/certificate_update.py b/sdk/batch/azure-mgmt-batch/generated_samples/certificate_update.py index a60e52f84130..90b11e02bf26 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/certificate_update.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/certificate_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/CertificateUpdate.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateUpdate.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/detector_get.py b/sdk/batch/azure-mgmt-batch/generated_samples/detector_get.py index ac0288bc9761..0bf611ce05ab 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/detector_get.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/detector_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/DetectorGet.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/DetectorGet.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/detector_list.py b/sdk/batch/azure-mgmt-batch/generated_samples/detector_list.py index 36723999e116..ac416a93c722 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/detector_list.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/detector_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/DetectorList.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/DetectorList.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/location_check_name_availability_already_exists.py b/sdk/batch/azure-mgmt-batch/generated_samples/location_check_name_availability_already_exists.py index 418e81bff689..96ba16751480 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/location_check_name_availability_already_exists.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/location_check_name_availability_already_exists.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/LocationCheckNameAvailability_AlreadyExists.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/LocationCheckNameAvailability_AlreadyExists.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/location_check_name_availability_available.py b/sdk/batch/azure-mgmt-batch/generated_samples/location_check_name_availability_available.py index 917ad6bc303c..824bbf5ba9e8 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/location_check_name_availability_available.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/location_check_name_availability_available.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/LocationCheckNameAvailability_Available.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/LocationCheckNameAvailability_Available.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/location_get_quotas.py b/sdk/batch/azure-mgmt-batch/generated_samples/location_get_quotas.py index 8d705ae0a12b..78c3fa7bd595 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/location_get_quotas.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/location_get_quotas.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/LocationGetQuotas.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/LocationGetQuotas.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/location_list_virtual_machine_skus.py b/sdk/batch/azure-mgmt-batch/generated_samples/location_list_virtual_machine_skus.py index 6f0f68b01ec6..9f514668c064 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/location_list_virtual_machine_skus.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/location_list_virtual_machine_skus.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/LocationListVirtualMachineSkus.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/LocationListVirtualMachineSkus.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_minimal_cloud_service_configuration.py b/sdk/batch/azure-mgmt-batch/generated_samples/nsp_configuration_get.py similarity index 73% rename from sdk/batch/azure-mgmt-batch/generated_samples/pool_create_minimal_cloud_service_configuration.py rename to sdk/batch/azure-mgmt-batch/generated_samples/nsp_configuration_get.py index 1c54bd4a0dc7..882bc275fd70 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_minimal_cloud_service_configuration.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/nsp_configuration_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -14,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-batch # USAGE - python pool_create_minimal_cloud_service_configuration.py + python nsp_configuration_get.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,21 +30,14 @@ def main(): subscription_id="subid", ) - response = client.pool.create( + response = client.network_security_perimeter.get_configuration( resource_group_name="default-azurebatch-japaneast", account_name="sampleacct", - pool_name="testpool", - parameters={ - "properties": { - "deploymentConfiguration": {"cloudServiceConfiguration": {"osFamily": "5"}}, - "scaleSettings": {"fixedScale": {"targetDedicatedNodes": 3}}, - "vmSize": "STANDARD_D4", - } - }, + network_security_perimeter_configuration_name="00000000-0000-0000-0000-000000000000.sampleassociation", ) print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolCreate_MinimalCloudServiceConfiguration.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/NspConfigurationGet.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/nsp_configuration_reconcile.py b/sdk/batch/azure-mgmt-batch/generated_samples/nsp_configuration_reconcile.py new file mode 100644 index 000000000000..53dfe287f42a --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_samples/nsp_configuration_reconcile.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.batch import BatchManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-batch +# USAGE + python nsp_configuration_reconcile.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = BatchManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + client.network_security_perimeter.begin_reconcile_configuration( + resource_group_name="default-azurebatch-japaneast", + account_name="sampleacct", + network_security_perimeter_configuration_name="00000000-0000-0000-0000-000000000000.sampleassociation", + ).result() + + +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/NspConfigurationReconcile.json +if __name__ == "__main__": + main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/location_list_cloud_service_skus.py b/sdk/batch/azure-mgmt-batch/generated_samples/nsp_configurations_list.py similarity index 83% rename from sdk/batch/azure-mgmt-batch/generated_samples/location_list_cloud_service_skus.py rename to sdk/batch/azure-mgmt-batch/generated_samples/nsp_configurations_list.py index e581435cb918..f682b15d4fa3 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/location_list_cloud_service_skus.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/nsp_configurations_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -14,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-batch # USAGE - python location_list_cloud_service_skus.py + python nsp_configurations_list.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,13 +30,14 @@ def main(): subscription_id="subid", ) - response = client.location.list_supported_cloud_service_skus( - location_name="japaneast", + response = client.network_security_perimeter.list_configurations( + resource_group_name="default-azurebatch-japaneast", + account_name="sampleacct", ) for item in response: print(item) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/LocationListCloudServiceSkus.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/NspConfigurationsList.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/operations_list.py b/sdk/batch/azure-mgmt-batch/generated_samples/operations_list.py index e4a1112ea21b..544ce5b4e76d 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/operations_list.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/operations_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/OperationsList.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/OperationsList.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_accelerated_networking.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_accelerated_networking.py index 4b899c8244a2..224286ca8fec 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_accelerated_networking.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_accelerated_networking.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -58,6 +59,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolCreate_AcceleratedNetworking.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_AcceleratedNetworking.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_cloud_service_configuration.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_cloud_service_configuration.py deleted file mode 100644 index 8e2c4e9d8720..000000000000 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_cloud_service_configuration.py +++ /dev/null @@ -1,110 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential -from azure.mgmt.batch import BatchManagementClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-batch -# USAGE - python pool_create_cloud_service_configuration.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = BatchManagementClient( - credential=DefaultAzureCredential(), - subscription_id="subid", - ) - - response = client.pool.create( - resource_group_name="default-azurebatch-japaneast", - account_name="sampleacct", - pool_name="testpool", - parameters={ - "properties": { - "applicationLicenses": ["app-license0", "app-license1"], - "applicationPackages": [ - { - "id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool/applications/app_1234", - "version": "asdf", - } - ], - "certificates": [ - { - "id": "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool/certificates/sha1-1234567", - "storeLocation": "LocalMachine", - "storeName": "MY", - "visibility": ["RemoteUser"], - } - ], - "deploymentConfiguration": { - "cloudServiceConfiguration": {"osFamily": "4", "osVersion": "WA-GUEST-OS-4.45_201708-01"} - }, - "displayName": "my-pool-name", - "interNodeCommunication": "Enabled", - "metadata": [{"name": "metadata-1", "value": "value-1"}, {"name": "metadata-2", "value": "value-2"}], - "networkConfiguration": { - "publicIPAddressConfiguration": { - "ipAddressIds": [ - "/subscriptions/subid1/resourceGroups/rg13/providers/Microsoft.Network/publicIPAddresses/ip135", - "/subscriptions/subid2/resourceGroups/rg24/providers/Microsoft.Network/publicIPAddresses/ip268", - ], - "provision": "UserManaged", - }, - "subnetId": "/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123", - }, - "scaleSettings": { - "fixedScale": { - "nodeDeallocationOption": "TaskCompletion", - "resizeTimeout": "PT8M", - "targetDedicatedNodes": 6, - "targetLowPriorityNodes": 28, - } - }, - "startTask": { - "commandLine": "cmd /c SET", - "environmentSettings": [{"name": "MYSET", "value": "1234"}], - "maxTaskRetryCount": 6, - "resourceFiles": [ - { - "fileMode": "777", - "filePath": "c:\\temp\\gohere", - "httpUrl": "https://testaccount.blob.core.windows.net/example-blob-file", - } - ], - "userIdentity": {"autoUser": {"elevationLevel": "Admin", "scope": "Pool"}}, - "waitForSuccess": True, - }, - "taskSchedulingPolicy": {"nodeFillType": "Pack"}, - "taskSlotsPerNode": 13, - "userAccounts": [ - { - "elevationLevel": "Admin", - "linuxUserConfiguration": {"gid": 4567, "sshPrivateKey": "sshprivatekeyvalue", "uid": 1234}, - "name": "username1", - "password": "", - } - ], - "vmSize": "STANDARD_D4", - } - }, - ) - print(response) - - -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolCreate_CloudServiceConfiguration.json -if __name__ == "__main__": - main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_minimal_virtual_machine_configuration.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_minimal_virtual_machine_configuration.py index dcbffc3bf0b7..ed14afe8cd97 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_minimal_virtual_machine_configuration.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_minimal_virtual_machine_configuration.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -54,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolCreate_MinimalVirtualMachineConfiguration.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_MinimalVirtualMachineConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_no_public_ip_addresses.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_no_public_ip_addresses.py index 706c3e68e239..96c397837369 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_no_public_ip_addresses.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_no_public_ip_addresses.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -54,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolCreate_NoPublicIPAddresses.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_NoPublicIPAddresses.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_public_ips.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_public_ips.py index 38f1f654be12..7207473706f8 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_public_ips.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_public_ips.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -59,6 +60,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolCreate_PublicIPs.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_PublicIPs.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_resource_tags.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_resource_tags.py index e226d8e2c21e..66e118f95f2b 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_resource_tags.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_resource_tags.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -55,6 +56,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolCreate_ResourceTags.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_ResourceTags.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_security_profile.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_security_profile.py index cd10fe3bcfc3..22ef3583c92b 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_security_profile.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_security_profile.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -59,6 +60,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolCreate_SecurityProfile.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_SecurityProfile.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_shared_image_gallery.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_shared_image_gallery.py index 4db8bb43b292..77977c73de89 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_shared_image_gallery.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_shared_image_gallery.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -50,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolCreate_SharedImageGallery.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_SharedImageGallery.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_tags.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_tags.py new file mode 100644 index 000000000000..3fd4937a9be4 --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_tags.py @@ -0,0 +1,61 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.batch import BatchManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-batch +# USAGE + python pool_create_tags.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = BatchManagementClient( + credential=DefaultAzureCredential(), + subscription_id="subid", + ) + + response = client.pool.create( + resource_group_name="default-azurebatch-japaneast", + account_name="sampleacct", + pool_name="testpool", + parameters={ + "properties": { + "deploymentConfiguration": { + "virtualMachineConfiguration": { + "imageReference": { + "offer": "0001-com-ubuntu-server-jammy", + "publisher": "Canonical", + "sku": "22_04-lts", + "version": "latest", + }, + "nodeAgentSkuId": "batch.node.ubuntu 22.04", + } + }, + "scaleSettings": {"fixedScale": {"targetDedicatedNodes": 1, "targetLowPriorityNodes": 0}}, + "vmSize": "Standard_d4s_v3", + }, + "tags": {"TagName1": "TagValue1", "TagName2": "TagValue2"}, + }, + ) + print(response) + + +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_Tags.json +if __name__ == "__main__": + main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_upgrade_policy.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_upgrade_policy.py index 6150704fcd56..2932c39e9e50 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_upgrade_policy.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_upgrade_policy.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -74,6 +75,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolCreate_UpgradePolicy.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_UpgradePolicy.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_user_assigned_identities.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_user_assigned_identities.py index 9cf6d0ed7743..23f343e9b2e0 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_user_assigned_identities.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_user_assigned_identities.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -61,6 +62,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolCreate_UserAssignedIdentities.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_UserAssignedIdentities.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_virtual_machine_configuration.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_virtual_machine_configuration.py index 04ae86f7153d..2fb5b0a9142a 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_virtual_machine_configuration.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_virtual_machine_configuration.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -90,6 +91,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolCreate_VirtualMachineConfiguration.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_VirtualMachineConfiguration.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_virtual_machine_configuration_extensions.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_virtual_machine_configuration_extensions.py index 68e732abe6ab..a110d9754dbf 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_virtual_machine_configuration_extensions.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_virtual_machine_configuration_extensions.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -68,6 +69,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolCreate_VirtualMachineConfiguration_Extensions.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_VirtualMachineConfiguration_Extensions.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_virtual_machine_configuration_managed_os_disk.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_virtual_machine_configuration_managed_os_disk.py index 644c4968d467..3e3d48a94488 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_virtual_machine_configuration_managed_os_disk.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_virtual_machine_configuration_managed_os_disk.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -59,6 +60,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolCreate_VirtualMachineConfiguration_ManagedOSDisk.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_VirtualMachineConfiguration_ManagedOSDisk.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_virtual_machine_configuration_service_artifact_reference.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_virtual_machine_configuration_service_artifact_reference.py index 6d94cf6ee8d9..261e91e04192 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_virtual_machine_configuration_service_artifact_reference.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_create_virtual_machine_configuration_service_artifact_reference.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -59,6 +60,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolCreate_VirtualMachineConfiguration_ServiceArtifactReference.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolCreate_VirtualMachineConfiguration_ServiceArtifactReference.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_delete.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_delete.py index fc9c474e5b0f..6671789eef46 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_delete.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolDelete.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolDelete.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_disable_auto_scale.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_disable_auto_scale.py index 889ec9a343f6..532bf8e07f1f 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_disable_auto_scale.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_disable_auto_scale.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolDisableAutoScale.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolDisableAutoScale.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_get.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_get.py index 169799fd829e..1901d4d7057e 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_get.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolGet.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_accelerated_networking.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_accelerated_networking.py index c1d8e591ef14..832bd6dc9626 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_accelerated_networking.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_accelerated_networking.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolGet_AcceleratedNetworking.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_AcceleratedNetworking.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_security_profile.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_security_profile.py index 68d28d7dbf08..ea3c79ddb7ec 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_security_profile.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_security_profile.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolGet_SecurityProfile.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_SecurityProfile.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_upgrade_policy.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_upgrade_policy.py index 6b6bc2470f68..cedd49b97fea 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_upgrade_policy.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_upgrade_policy.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolGet_UpgradePolicy.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_UpgradePolicy.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_virtual_machine_configuration_extensions.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_virtual_machine_configuration_extensions.py index 98b19ba32fe2..8e213fee3238 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_virtual_machine_configuration_extensions.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_virtual_machine_configuration_extensions.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolGet_VirtualMachineConfiguration_Extensions.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_Extensions.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_virtual_machine_configuration_manged_os_disk.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_virtual_machine_configuration_manged_os_disk.py index 74d7659f8c64..7569b6287415 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_virtual_machine_configuration_manged_os_disk.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_virtual_machine_configuration_manged_os_disk.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolGet_VirtualMachineConfiguration_MangedOSDisk.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_MangedOSDisk.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_virtual_machine_configuration_service_artifact_reference.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_virtual_machine_configuration_service_artifact_reference.py index e756a594298b..ded9316e7170 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_virtual_machine_configuration_service_artifact_reference.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_get_virtual_machine_configuration_service_artifact_reference.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolGet_VirtualMachineConfiguration_ServiceArtifactReference.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_ServiceArtifactReference.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_list.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_list.py index e755acb83af4..45e59bf1ad32 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_list.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolList.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolList.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_list_with_filter.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_list_with_filter.py index 18faafab5d5a..44e91ad8a4ad 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_list_with_filter.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_list_with_filter.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolListWithFilter.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolListWithFilter.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_stop_resize.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_stop_resize.py index 6a626f7334cc..0f518cb765b1 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_stop_resize.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_stop_resize.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolStopResize.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolStopResize.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_update_enable_auto_scale.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_update_enable_auto_scale.py index 4122d3389936..def14873939f 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_update_enable_auto_scale.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_update_enable_auto_scale.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolUpdate_EnableAutoScale.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolUpdate_EnableAutoScale.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_update_other_properties.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_update_other_properties.py index e7d4260dce52..d38df9a059ed 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_update_other_properties.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_update_other_properties.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -59,6 +60,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolUpdate_OtherProperties.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolUpdate_OtherProperties.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_update_remove_start_task.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_update_remove_start_task.py index f7377c967cb7..adb88642c2ac 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_update_remove_start_task.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_update_remove_start_task.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolUpdate_RemoveStartTask.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolUpdate_RemoveStartTask.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/pool_update_resize_pool.py b/sdk/batch/azure-mgmt-batch/generated_samples/pool_update_resize_pool.py index 5bfa7d94db16..2d120085b64d 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/pool_update_resize_pool.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/pool_update_resize_pool.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -49,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PoolUpdate_ResizePool.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolUpdate_ResizePool.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/private_batch_account_create.py b/sdk/batch/azure-mgmt-batch/generated_samples/private_batch_account_create.py index ba904f442a24..65fe113d9ead 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/private_batch_account_create.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/private_batch_account_create.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -49,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PrivateBatchAccountCreate.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateBatchAccountCreate.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/private_batch_account_get.py b/sdk/batch/azure-mgmt-batch/generated_samples/private_batch_account_get.py index 1fcce4a38c7c..70d7935ccd43 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/private_batch_account_get.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/private_batch_account_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PrivateBatchAccountGet.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateBatchAccountGet.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/private_endpoint_connection_delete.py b/sdk/batch/azure-mgmt-batch/generated_samples/private_endpoint_connection_delete.py index f6507b31639c..56205beb4c3d 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/private_endpoint_connection_delete.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/private_endpoint_connection_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PrivateEndpointConnectionDelete.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateEndpointConnectionDelete.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/private_endpoint_connection_get.py b/sdk/batch/azure-mgmt-batch/generated_samples/private_endpoint_connection_get.py index 56d92ffae8a7..57e33d90534a 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/private_endpoint_connection_get.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/private_endpoint_connection_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PrivateEndpointConnectionGet.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateEndpointConnectionGet.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/private_endpoint_connection_update.py b/sdk/batch/azure-mgmt-batch/generated_samples/private_endpoint_connection_update.py index 7614a5f7cd53..ae3760cc981b 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/private_endpoint_connection_update.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/private_endpoint_connection_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PrivateEndpointConnectionUpdate.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateEndpointConnectionUpdate.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/private_endpoint_connections_list.py b/sdk/batch/azure-mgmt-batch/generated_samples/private_endpoint_connections_list.py index efb8dca0bdf0..406abec363c4 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/private_endpoint_connections_list.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/private_endpoint_connections_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PrivateEndpointConnectionsList.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateEndpointConnectionsList.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/private_link_resource_get.py b/sdk/batch/azure-mgmt-batch/generated_samples/private_link_resource_get.py index bc2f64c1afa8..e8a93013c416 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/private_link_resource_get.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/private_link_resource_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PrivateLinkResourceGet.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateLinkResourceGet.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_samples/private_link_resources_list.py b/sdk/batch/azure-mgmt-batch/generated_samples/private_link_resources_list.py index 6b492f7eef92..99bb74e7869f 100644 --- a/sdk/batch/azure-mgmt-batch/generated_samples/private_link_resources_list.py +++ b/sdk/batch/azure-mgmt-batch/generated_samples/private_link_resources_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.batch import BatchManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-02-01/examples/PrivateLinkResourcesList.json +# x-ms-original-file: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateLinkResourcesList.json if __name__ == "__main__": main() diff --git a/sdk/batch/azure-mgmt-batch/generated_tests/conftest.py b/sdk/batch/azure-mgmt-batch/generated_tests/conftest.py new file mode 100644 index 000000000000..d2197a0b732b --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + batchmanagement_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + batchmanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + batchmanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + batchmanagement_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=batchmanagement_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=batchmanagement_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=batchmanagement_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=batchmanagement_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_application_operations.py b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_application_operations.py new file mode 100644 index 000000000000..793bb3b6cecc --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_application_operations.py @@ -0,0 +1,93 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestBatchManagementApplicationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create(self, resource_group): + response = self.client.application.create( + resource_group_name=resource_group.name, + account_name="str", + application_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.application.delete( + resource_group_name=resource_group.name, + account_name="str", + application_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.application.get( + resource_group_name=resource_group.name, + account_name="str", + application_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.application.update( + resource_group_name=resource_group.name, + account_name="str", + application_name="str", + parameters={ + "allowUpdates": bool, + "defaultVersion": "str", + "displayName": "str", + "etag": "str", + "id": "str", + "name": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.application.list( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_application_operations_async.py b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_application_operations_async.py new file mode 100644 index 000000000000..840697e41cb7 --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_application_operations_async.py @@ -0,0 +1,94 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch.aio import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestBatchManagementApplicationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create(self, resource_group): + response = await self.client.application.create( + resource_group_name=resource_group.name, + account_name="str", + application_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.application.delete( + resource_group_name=resource_group.name, + account_name="str", + application_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.application.get( + resource_group_name=resource_group.name, + account_name="str", + application_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.application.update( + resource_group_name=resource_group.name, + account_name="str", + application_name="str", + parameters={ + "allowUpdates": bool, + "defaultVersion": "str", + "displayName": "str", + "etag": "str", + "id": "str", + "name": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.application.list( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_application_package_operations.py b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_application_package_operations.py new file mode 100644 index 000000000000..959684b482f4 --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_application_package_operations.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestBatchManagementApplicationPackageOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_activate(self, resource_group): + response = self.client.application_package.activate( + resource_group_name=resource_group.name, + account_name="str", + application_name="str", + version_name="str", + parameters={"format": "str"}, + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create(self, resource_group): + response = self.client.application_package.create( + resource_group_name=resource_group.name, + account_name="str", + application_name="str", + version_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.application_package.delete( + resource_group_name=resource_group.name, + account_name="str", + application_name="str", + version_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.application_package.get( + resource_group_name=resource_group.name, + account_name="str", + application_name="str", + version_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.application_package.list( + resource_group_name=resource_group.name, + account_name="str", + application_name="str", + api_version="2024-07-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_application_package_operations_async.py b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_application_package_operations_async.py new file mode 100644 index 000000000000..493a81ace540 --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_application_package_operations_async.py @@ -0,0 +1,90 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch.aio import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestBatchManagementApplicationPackageOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_activate(self, resource_group): + response = await self.client.application_package.activate( + resource_group_name=resource_group.name, + account_name="str", + application_name="str", + version_name="str", + parameters={"format": "str"}, + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create(self, resource_group): + response = await self.client.application_package.create( + resource_group_name=resource_group.name, + account_name="str", + application_name="str", + version_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.application_package.delete( + resource_group_name=resource_group.name, + account_name="str", + application_name="str", + version_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.application_package.get( + resource_group_name=resource_group.name, + account_name="str", + application_name="str", + version_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.application_package.list( + resource_group_name=resource_group.name, + account_name="str", + application_name="str", + api_version="2024-07-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_batch_account_operations.py b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_batch_account_operations.py new file mode 100644 index 000000000000..7dde00ce609b --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_batch_account_operations.py @@ -0,0 +1,207 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestBatchManagementBatchAccountOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.batch_account.begin_create( + resource_group_name=resource_group.name, + account_name="str", + parameters={ + "location": "str", + "allowedAuthenticationModes": ["str"], + "autoStorage": { + "storageAccountId": "str", + "authenticationMode": "StorageKeys", + "nodeIdentityReference": {"resourceId": "str"}, + }, + "encryption": {"keySource": "str", "keyVaultProperties": {"keyIdentifier": "str"}}, + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "keyVaultReference": {"id": "str", "url": "str"}, + "networkProfile": { + "accountAccess": {"defaultAction": "str", "ipRules": [{"action": "Allow", "value": "str"}]}, + "nodeManagementAccess": {"defaultAction": "str", "ipRules": [{"action": "Allow", "value": "str"}]}, + }, + "poolAllocationMode": "str", + "publicNetworkAccess": "Enabled", + "tags": {"str": "str"}, + }, + api_version="2024-07-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.batch_account.update( + resource_group_name=resource_group.name, + account_name="str", + parameters={ + "allowedAuthenticationModes": ["str"], + "autoStorage": { + "storageAccountId": "str", + "authenticationMode": "StorageKeys", + "nodeIdentityReference": {"resourceId": "str"}, + }, + "encryption": {"keySource": "str", "keyVaultProperties": {"keyIdentifier": "str"}}, + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "networkProfile": { + "accountAccess": {"defaultAction": "str", "ipRules": [{"action": "Allow", "value": "str"}]}, + "nodeManagementAccess": {"defaultAction": "str", "ipRules": [{"action": "Allow", "value": "str"}]}, + }, + "publicNetworkAccess": "Enabled", + "tags": {"str": "str"}, + }, + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.batch_account.begin_delete( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.batch_account.get( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.batch_account.list( + api_version="2024-07-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.batch_account.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-07-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_synchronize_auto_storage_keys(self, resource_group): + response = self.client.batch_account.synchronize_auto_storage_keys( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_regenerate_key(self, resource_group): + response = self.client.batch_account.regenerate_key( + resource_group_name=resource_group.name, + account_name="str", + parameters={"keyName": "str"}, + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_keys(self, resource_group): + response = self.client.batch_account.get_keys( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_detectors(self, resource_group): + response = self.client.batch_account.list_detectors( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_detector(self, resource_group): + response = self.client.batch_account.get_detector( + resource_group_name=resource_group.name, + account_name="str", + detector_id="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_outbound_network_dependencies_endpoints(self, resource_group): + response = self.client.batch_account.list_outbound_network_dependencies_endpoints( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_batch_account_operations_async.py b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_batch_account_operations_async.py new file mode 100644 index 000000000000..c76442104ec8 --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_batch_account_operations_async.py @@ -0,0 +1,215 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch.aio import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestBatchManagementBatchAccountOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.batch_account.begin_create( + resource_group_name=resource_group.name, + account_name="str", + parameters={ + "location": "str", + "allowedAuthenticationModes": ["str"], + "autoStorage": { + "storageAccountId": "str", + "authenticationMode": "StorageKeys", + "nodeIdentityReference": {"resourceId": "str"}, + }, + "encryption": {"keySource": "str", "keyVaultProperties": {"keyIdentifier": "str"}}, + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "keyVaultReference": {"id": "str", "url": "str"}, + "networkProfile": { + "accountAccess": {"defaultAction": "str", "ipRules": [{"action": "Allow", "value": "str"}]}, + "nodeManagementAccess": { + "defaultAction": "str", + "ipRules": [{"action": "Allow", "value": "str"}], + }, + }, + "poolAllocationMode": "str", + "publicNetworkAccess": "Enabled", + "tags": {"str": "str"}, + }, + api_version="2024-07-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.batch_account.update( + resource_group_name=resource_group.name, + account_name="str", + parameters={ + "allowedAuthenticationModes": ["str"], + "autoStorage": { + "storageAccountId": "str", + "authenticationMode": "StorageKeys", + "nodeIdentityReference": {"resourceId": "str"}, + }, + "encryption": {"keySource": "str", "keyVaultProperties": {"keyIdentifier": "str"}}, + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "networkProfile": { + "accountAccess": {"defaultAction": "str", "ipRules": [{"action": "Allow", "value": "str"}]}, + "nodeManagementAccess": {"defaultAction": "str", "ipRules": [{"action": "Allow", "value": "str"}]}, + }, + "publicNetworkAccess": "Enabled", + "tags": {"str": "str"}, + }, + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.batch_account.begin_delete( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.batch_account.get( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.batch_account.list( + api_version="2024-07-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.batch_account.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-07-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_synchronize_auto_storage_keys(self, resource_group): + response = await self.client.batch_account.synchronize_auto_storage_keys( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_regenerate_key(self, resource_group): + response = await self.client.batch_account.regenerate_key( + resource_group_name=resource_group.name, + account_name="str", + parameters={"keyName": "str"}, + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_keys(self, resource_group): + response = await self.client.batch_account.get_keys( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_detectors(self, resource_group): + response = self.client.batch_account.list_detectors( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_detector(self, resource_group): + response = await self.client.batch_account.get_detector( + resource_group_name=resource_group.name, + account_name="str", + detector_id="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_outbound_network_dependencies_endpoints(self, resource_group): + response = self.client.batch_account.list_outbound_network_dependencies_endpoints( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_certificate_operations.py b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_certificate_operations.py new file mode 100644 index 000000000000..1bdcc87462e2 --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_certificate_operations.py @@ -0,0 +1,120 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestBatchManagementCertificateOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_batch_account(self, resource_group): + response = self.client.certificate.list_by_batch_account( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create(self, resource_group): + response = self.client.certificate.create( + resource_group_name=resource_group.name, + account_name="str", + certificate_name="str", + parameters={ + "data": "str", + "etag": "str", + "format": "str", + "id": "str", + "name": "str", + "password": "str", + "tags": {"str": "str"}, + "thumbprint": "str", + "thumbprintAlgorithm": "str", + "type": "str", + }, + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.certificate.update( + resource_group_name=resource_group.name, + account_name="str", + certificate_name="str", + parameters={ + "data": "str", + "etag": "str", + "format": "str", + "id": "str", + "name": "str", + "password": "str", + "tags": {"str": "str"}, + "thumbprint": "str", + "thumbprintAlgorithm": "str", + "type": "str", + }, + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.certificate.begin_delete( + resource_group_name=resource_group.name, + account_name="str", + certificate_name="str", + api_version="2024-07-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.certificate.get( + resource_group_name=resource_group.name, + account_name="str", + certificate_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_cancel_deletion(self, resource_group): + response = self.client.certificate.cancel_deletion( + resource_group_name=resource_group.name, + account_name="str", + certificate_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_certificate_operations_async.py b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_certificate_operations_async.py new file mode 100644 index 000000000000..d0f27b7bf5df --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_certificate_operations_async.py @@ -0,0 +1,123 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch.aio import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestBatchManagementCertificateOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_batch_account(self, resource_group): + response = self.client.certificate.list_by_batch_account( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create(self, resource_group): + response = await self.client.certificate.create( + resource_group_name=resource_group.name, + account_name="str", + certificate_name="str", + parameters={ + "data": "str", + "etag": "str", + "format": "str", + "id": "str", + "name": "str", + "password": "str", + "tags": {"str": "str"}, + "thumbprint": "str", + "thumbprintAlgorithm": "str", + "type": "str", + }, + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.certificate.update( + resource_group_name=resource_group.name, + account_name="str", + certificate_name="str", + parameters={ + "data": "str", + "etag": "str", + "format": "str", + "id": "str", + "name": "str", + "password": "str", + "tags": {"str": "str"}, + "thumbprint": "str", + "thumbprintAlgorithm": "str", + "type": "str", + }, + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.certificate.begin_delete( + resource_group_name=resource_group.name, + account_name="str", + certificate_name="str", + api_version="2024-07-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.certificate.get( + resource_group_name=resource_group.name, + account_name="str", + certificate_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_cancel_deletion(self, resource_group): + response = await self.client.certificate.cancel_deletion( + resource_group_name=resource_group.name, + account_name="str", + certificate_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_location_operations.py b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_location_operations.py new file mode 100644 index 000000000000..bea348d83ff2 --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_location_operations.py @@ -0,0 +1,53 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestBatchManagementLocationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_quotas(self, resource_group): + response = self.client.location.get_quotas( + location_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_supported_virtual_machine_skus(self, resource_group): + response = self.client.location.list_supported_virtual_machine_skus( + location_name="str", + api_version="2024-07-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_name_availability(self, resource_group): + response = self.client.location.check_name_availability( + location_name="str", + parameters={"name": "str", "type": "Microsoft.Batch/batchAccounts"}, + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_location_operations_async.py b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_location_operations_async.py new file mode 100644 index 000000000000..83b96efa5fd3 --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_location_operations_async.py @@ -0,0 +1,54 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch.aio import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestBatchManagementLocationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_quotas(self, resource_group): + response = await self.client.location.get_quotas( + location_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_supported_virtual_machine_skus(self, resource_group): + response = self.client.location.list_supported_virtual_machine_skus( + location_name="str", + api_version="2024-07-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_name_availability(self, resource_group): + response = await self.client.location.check_name_availability( + location_name="str", + parameters={"name": "str", "type": "Microsoft.Batch/batchAccounts"}, + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_network_security_perimeter_operations.py b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_network_security_perimeter_operations.py new file mode 100644 index 000000000000..189306c465bf --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_network_security_perimeter_operations.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestBatchManagementNetworkSecurityPerimeterOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_configurations(self, resource_group): + response = self.client.network_security_perimeter.list_configurations( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_configuration(self, resource_group): + response = self.client.network_security_perimeter.get_configuration( + resource_group_name=resource_group.name, + account_name="str", + network_security_perimeter_configuration_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_reconcile_configuration(self, resource_group): + response = self.client.network_security_perimeter.begin_reconcile_configuration( + resource_group_name=resource_group.name, + account_name="str", + network_security_perimeter_configuration_name="str", + api_version="2024-07-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_network_security_perimeter_operations_async.py b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_network_security_perimeter_operations_async.py new file mode 100644 index 000000000000..576c9c2eb4db --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_network_security_perimeter_operations_async.py @@ -0,0 +1,60 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch.aio import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestBatchManagementNetworkSecurityPerimeterOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_configurations(self, resource_group): + response = self.client.network_security_perimeter.list_configurations( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_configuration(self, resource_group): + response = await self.client.network_security_perimeter.get_configuration( + resource_group_name=resource_group.name, + account_name="str", + network_security_perimeter_configuration_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_reconcile_configuration(self, resource_group): + response = await ( + await self.client.network_security_perimeter.begin_reconcile_configuration( + resource_group_name=resource_group.name, + account_name="str", + network_security_perimeter_configuration_name="str", + api_version="2024-07-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_operations.py b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_operations.py new file mode 100644 index 000000000000..5539e12e4fcb --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestBatchManagementOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-07-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_operations_async.py b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_operations_async.py new file mode 100644 index 000000000000..00a4787eb3a0 --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch.aio import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestBatchManagementOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-07-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_pool_operations.py b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_pool_operations.py new file mode 100644 index 000000000000..9a7c4d0c743f --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_pool_operations.py @@ -0,0 +1,555 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestBatchManagementPoolOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_batch_account(self, resource_group): + response = self.client.pool.list_by_batch_account( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create(self, resource_group): + response = self.client.pool.create( + resource_group_name=resource_group.name, + account_name="str", + pool_name="str", + parameters={ + "allocationState": "str", + "allocationStateTransitionTime": "2020-02-20 00:00:00", + "applicationLicenses": ["str"], + "applicationPackages": [{"id": "str", "version": "str"}], + "autoScaleRun": { + "evaluationTime": "2020-02-20 00:00:00", + "error": {"code": "str", "message": "str", "details": [...]}, + "results": "str", + }, + "certificates": [{"id": "str", "storeLocation": "str", "storeName": "str", "visibility": ["str"]}], + "creationTime": "2020-02-20 00:00:00", + "currentDedicatedNodes": 0, + "currentLowPriorityNodes": 0, + "currentNodeCommunicationMode": "str", + "deploymentConfiguration": { + "virtualMachineConfiguration": { + "imageReference": { + "communityGalleryImageId": "str", + "id": "str", + "offer": "str", + "publisher": "str", + "sharedGalleryImageId": "str", + "sku": "str", + "version": "str", + }, + "nodeAgentSkuId": "str", + "containerConfiguration": { + "type": "str", + "containerImageNames": ["str"], + "containerRegistries": [ + { + "identityReference": {"resourceId": "str"}, + "password": "str", + "registryServer": "str", + "username": "str", + } + ], + }, + "dataDisks": [{"diskSizeGB": 0, "lun": 0, "caching": "str", "storageAccountType": "str"}], + "diskEncryptionConfiguration": {"targets": ["str"]}, + "extensions": [ + { + "name": "str", + "publisher": "str", + "type": "str", + "autoUpgradeMinorVersion": bool, + "enableAutomaticUpgrade": bool, + "protectedSettings": {}, + "provisionAfterExtensions": ["str"], + "settings": {}, + "typeHandlerVersion": "str", + } + ], + "licenseType": "str", + "nodePlacementConfiguration": {"policy": "str"}, + "osDisk": { + "caching": "str", + "diskSizeGB": 0, + "ephemeralOSDiskSettings": {"placement": "CacheDisk"}, + "managedDisk": { + "securityProfile": {"securityEncryptionType": "str"}, + "storageAccountType": "str", + }, + "writeAcceleratorEnabled": bool, + }, + "securityProfile": { + "encryptionAtHost": bool, + "securityType": "str", + "uefiSettings": {"secureBootEnabled": bool, "vTpmEnabled": bool}, + }, + "serviceArtifactReference": {"id": "str"}, + "windowsConfiguration": {"enableAutomaticUpdates": bool}, + } + }, + "displayName": "str", + "etag": "str", + "id": "str", + "identity": { + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "interNodeCommunication": "str", + "lastModified": "2020-02-20 00:00:00", + "metadata": [{"name": "str", "value": "str"}], + "mountConfiguration": [ + { + "azureBlobFileSystemConfiguration": { + "accountName": "str", + "containerName": "str", + "relativeMountPath": "str", + "accountKey": "str", + "blobfuseOptions": "str", + "identityReference": {"resourceId": "str"}, + "sasKey": "str", + }, + "azureFileShareConfiguration": { + "accountKey": "str", + "accountName": "str", + "azureFileUrl": "str", + "relativeMountPath": "str", + "mountOptions": "str", + }, + "cifsMountConfiguration": { + "password": "str", + "relativeMountPath": "str", + "source": "str", + "userName": "str", + "mountOptions": "str", + }, + "nfsMountConfiguration": {"relativeMountPath": "str", "source": "str", "mountOptions": "str"}, + } + ], + "name": "str", + "networkConfiguration": { + "dynamicVnetAssignmentScope": "none", + "enableAcceleratedNetworking": bool, + "endpointConfiguration": { + "inboundNatPools": [ + { + "backendPort": 0, + "frontendPortRangeEnd": 0, + "frontendPortRangeStart": 0, + "name": "str", + "protocol": "str", + "networkSecurityGroupRules": [ + { + "access": "str", + "priority": 0, + "sourceAddressPrefix": "str", + "sourcePortRanges": ["str"], + } + ], + } + ] + }, + "publicIPAddressConfiguration": {"ipAddressIds": ["str"], "provision": "str"}, + "subnetId": "str", + }, + "provisioningState": "str", + "provisioningStateTransitionTime": "2020-02-20 00:00:00", + "resizeOperationStatus": { + "errors": [{"code": "str", "message": "str", "details": [...]}], + "nodeDeallocationOption": "str", + "resizeTimeout": "1 day, 0:00:00", + "startTime": "2020-02-20 00:00:00", + "targetDedicatedNodes": 0, + "targetLowPriorityNodes": 0, + }, + "resourceTags": {"str": "str"}, + "scaleSettings": { + "autoScale": {"formula": "str", "evaluationInterval": "1 day, 0:00:00"}, + "fixedScale": { + "nodeDeallocationOption": "str", + "resizeTimeout": "PT15M", + "targetDedicatedNodes": 0, + "targetLowPriorityNodes": 0, + }, + }, + "startTask": { + "commandLine": "str", + "containerSettings": { + "imageName": "str", + "containerHostBatchBindMounts": [{"isReadOnly": bool, "source": "str"}], + "containerRunOptions": "str", + "registry": { + "identityReference": {"resourceId": "str"}, + "password": "str", + "registryServer": "str", + "username": "str", + }, + "workingDirectory": "str", + }, + "environmentSettings": [{"name": "str", "value": "str"}], + "maxTaskRetryCount": 0, + "resourceFiles": [ + { + "autoStorageContainerName": "str", + "blobPrefix": "str", + "fileMode": "str", + "filePath": "str", + "httpUrl": "str", + "identityReference": {"resourceId": "str"}, + "storageContainerUrl": "str", + } + ], + "userIdentity": {"autoUser": {"elevationLevel": "str", "scope": "str"}, "userName": "str"}, + "waitForSuccess": bool, + }, + "tags": {"str": "str"}, + "targetNodeCommunicationMode": "str", + "taskSchedulingPolicy": {"nodeFillType": "Spread"}, + "taskSlotsPerNode": 1, + "type": "str", + "upgradePolicy": { + "mode": "str", + "automaticOSUpgradePolicy": { + "disableAutomaticRollback": bool, + "enableAutomaticOSUpgrade": bool, + "osRollingUpgradeDeferral": bool, + "useRollingUpgradePolicy": bool, + }, + "rollingUpgradePolicy": { + "enableCrossZoneUpgrade": bool, + "maxBatchInstancePercent": 0, + "maxUnhealthyInstancePercent": 0, + "maxUnhealthyUpgradedInstancePercent": 0, + "pauseTimeBetweenBatches": "str", + "prioritizeUnhealthyInstances": bool, + "rollbackFailedInstancesOnPolicyBreach": bool, + }, + }, + "userAccounts": [ + { + "name": "str", + "password": "str", + "elevationLevel": "str", + "linuxUserConfiguration": {"gid": 0, "sshPrivateKey": "str", "uid": 0}, + "windowsUserConfiguration": {"loginMode": "str"}, + } + ], + "vmSize": "str", + }, + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.pool.update( + resource_group_name=resource_group.name, + account_name="str", + pool_name="str", + parameters={ + "allocationState": "str", + "allocationStateTransitionTime": "2020-02-20 00:00:00", + "applicationLicenses": ["str"], + "applicationPackages": [{"id": "str", "version": "str"}], + "autoScaleRun": { + "evaluationTime": "2020-02-20 00:00:00", + "error": {"code": "str", "message": "str", "details": [...]}, + "results": "str", + }, + "certificates": [{"id": "str", "storeLocation": "str", "storeName": "str", "visibility": ["str"]}], + "creationTime": "2020-02-20 00:00:00", + "currentDedicatedNodes": 0, + "currentLowPriorityNodes": 0, + "currentNodeCommunicationMode": "str", + "deploymentConfiguration": { + "virtualMachineConfiguration": { + "imageReference": { + "communityGalleryImageId": "str", + "id": "str", + "offer": "str", + "publisher": "str", + "sharedGalleryImageId": "str", + "sku": "str", + "version": "str", + }, + "nodeAgentSkuId": "str", + "containerConfiguration": { + "type": "str", + "containerImageNames": ["str"], + "containerRegistries": [ + { + "identityReference": {"resourceId": "str"}, + "password": "str", + "registryServer": "str", + "username": "str", + } + ], + }, + "dataDisks": [{"diskSizeGB": 0, "lun": 0, "caching": "str", "storageAccountType": "str"}], + "diskEncryptionConfiguration": {"targets": ["str"]}, + "extensions": [ + { + "name": "str", + "publisher": "str", + "type": "str", + "autoUpgradeMinorVersion": bool, + "enableAutomaticUpgrade": bool, + "protectedSettings": {}, + "provisionAfterExtensions": ["str"], + "settings": {}, + "typeHandlerVersion": "str", + } + ], + "licenseType": "str", + "nodePlacementConfiguration": {"policy": "str"}, + "osDisk": { + "caching": "str", + "diskSizeGB": 0, + "ephemeralOSDiskSettings": {"placement": "CacheDisk"}, + "managedDisk": { + "securityProfile": {"securityEncryptionType": "str"}, + "storageAccountType": "str", + }, + "writeAcceleratorEnabled": bool, + }, + "securityProfile": { + "encryptionAtHost": bool, + "securityType": "str", + "uefiSettings": {"secureBootEnabled": bool, "vTpmEnabled": bool}, + }, + "serviceArtifactReference": {"id": "str"}, + "windowsConfiguration": {"enableAutomaticUpdates": bool}, + } + }, + "displayName": "str", + "etag": "str", + "id": "str", + "identity": { + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "interNodeCommunication": "str", + "lastModified": "2020-02-20 00:00:00", + "metadata": [{"name": "str", "value": "str"}], + "mountConfiguration": [ + { + "azureBlobFileSystemConfiguration": { + "accountName": "str", + "containerName": "str", + "relativeMountPath": "str", + "accountKey": "str", + "blobfuseOptions": "str", + "identityReference": {"resourceId": "str"}, + "sasKey": "str", + }, + "azureFileShareConfiguration": { + "accountKey": "str", + "accountName": "str", + "azureFileUrl": "str", + "relativeMountPath": "str", + "mountOptions": "str", + }, + "cifsMountConfiguration": { + "password": "str", + "relativeMountPath": "str", + "source": "str", + "userName": "str", + "mountOptions": "str", + }, + "nfsMountConfiguration": {"relativeMountPath": "str", "source": "str", "mountOptions": "str"}, + } + ], + "name": "str", + "networkConfiguration": { + "dynamicVnetAssignmentScope": "none", + "enableAcceleratedNetworking": bool, + "endpointConfiguration": { + "inboundNatPools": [ + { + "backendPort": 0, + "frontendPortRangeEnd": 0, + "frontendPortRangeStart": 0, + "name": "str", + "protocol": "str", + "networkSecurityGroupRules": [ + { + "access": "str", + "priority": 0, + "sourceAddressPrefix": "str", + "sourcePortRanges": ["str"], + } + ], + } + ] + }, + "publicIPAddressConfiguration": {"ipAddressIds": ["str"], "provision": "str"}, + "subnetId": "str", + }, + "provisioningState": "str", + "provisioningStateTransitionTime": "2020-02-20 00:00:00", + "resizeOperationStatus": { + "errors": [{"code": "str", "message": "str", "details": [...]}], + "nodeDeallocationOption": "str", + "resizeTimeout": "1 day, 0:00:00", + "startTime": "2020-02-20 00:00:00", + "targetDedicatedNodes": 0, + "targetLowPriorityNodes": 0, + }, + "resourceTags": {"str": "str"}, + "scaleSettings": { + "autoScale": {"formula": "str", "evaluationInterval": "1 day, 0:00:00"}, + "fixedScale": { + "nodeDeallocationOption": "str", + "resizeTimeout": "PT15M", + "targetDedicatedNodes": 0, + "targetLowPriorityNodes": 0, + }, + }, + "startTask": { + "commandLine": "str", + "containerSettings": { + "imageName": "str", + "containerHostBatchBindMounts": [{"isReadOnly": bool, "source": "str"}], + "containerRunOptions": "str", + "registry": { + "identityReference": {"resourceId": "str"}, + "password": "str", + "registryServer": "str", + "username": "str", + }, + "workingDirectory": "str", + }, + "environmentSettings": [{"name": "str", "value": "str"}], + "maxTaskRetryCount": 0, + "resourceFiles": [ + { + "autoStorageContainerName": "str", + "blobPrefix": "str", + "fileMode": "str", + "filePath": "str", + "httpUrl": "str", + "identityReference": {"resourceId": "str"}, + "storageContainerUrl": "str", + } + ], + "userIdentity": {"autoUser": {"elevationLevel": "str", "scope": "str"}, "userName": "str"}, + "waitForSuccess": bool, + }, + "tags": {"str": "str"}, + "targetNodeCommunicationMode": "str", + "taskSchedulingPolicy": {"nodeFillType": "Spread"}, + "taskSlotsPerNode": 1, + "type": "str", + "upgradePolicy": { + "mode": "str", + "automaticOSUpgradePolicy": { + "disableAutomaticRollback": bool, + "enableAutomaticOSUpgrade": bool, + "osRollingUpgradeDeferral": bool, + "useRollingUpgradePolicy": bool, + }, + "rollingUpgradePolicy": { + "enableCrossZoneUpgrade": bool, + "maxBatchInstancePercent": 0, + "maxUnhealthyInstancePercent": 0, + "maxUnhealthyUpgradedInstancePercent": 0, + "pauseTimeBetweenBatches": "str", + "prioritizeUnhealthyInstances": bool, + "rollbackFailedInstancesOnPolicyBreach": bool, + }, + }, + "userAccounts": [ + { + "name": "str", + "password": "str", + "elevationLevel": "str", + "linuxUserConfiguration": {"gid": 0, "sshPrivateKey": "str", "uid": 0}, + "windowsUserConfiguration": {"loginMode": "str"}, + } + ], + "vmSize": "str", + }, + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.pool.begin_delete( + resource_group_name=resource_group.name, + account_name="str", + pool_name="str", + api_version="2024-07-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.pool.get( + resource_group_name=resource_group.name, + account_name="str", + pool_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_disable_auto_scale(self, resource_group): + response = self.client.pool.disable_auto_scale( + resource_group_name=resource_group.name, + account_name="str", + pool_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_stop_resize(self, resource_group): + response = self.client.pool.stop_resize( + resource_group_name=resource_group.name, + account_name="str", + pool_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_pool_operations_async.py b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_pool_operations_async.py new file mode 100644 index 000000000000..95a7a2b1b936 --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_pool_operations_async.py @@ -0,0 +1,558 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch.aio import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestBatchManagementPoolOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_batch_account(self, resource_group): + response = self.client.pool.list_by_batch_account( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create(self, resource_group): + response = await self.client.pool.create( + resource_group_name=resource_group.name, + account_name="str", + pool_name="str", + parameters={ + "allocationState": "str", + "allocationStateTransitionTime": "2020-02-20 00:00:00", + "applicationLicenses": ["str"], + "applicationPackages": [{"id": "str", "version": "str"}], + "autoScaleRun": { + "evaluationTime": "2020-02-20 00:00:00", + "error": {"code": "str", "message": "str", "details": [...]}, + "results": "str", + }, + "certificates": [{"id": "str", "storeLocation": "str", "storeName": "str", "visibility": ["str"]}], + "creationTime": "2020-02-20 00:00:00", + "currentDedicatedNodes": 0, + "currentLowPriorityNodes": 0, + "currentNodeCommunicationMode": "str", + "deploymentConfiguration": { + "virtualMachineConfiguration": { + "imageReference": { + "communityGalleryImageId": "str", + "id": "str", + "offer": "str", + "publisher": "str", + "sharedGalleryImageId": "str", + "sku": "str", + "version": "str", + }, + "nodeAgentSkuId": "str", + "containerConfiguration": { + "type": "str", + "containerImageNames": ["str"], + "containerRegistries": [ + { + "identityReference": {"resourceId": "str"}, + "password": "str", + "registryServer": "str", + "username": "str", + } + ], + }, + "dataDisks": [{"diskSizeGB": 0, "lun": 0, "caching": "str", "storageAccountType": "str"}], + "diskEncryptionConfiguration": {"targets": ["str"]}, + "extensions": [ + { + "name": "str", + "publisher": "str", + "type": "str", + "autoUpgradeMinorVersion": bool, + "enableAutomaticUpgrade": bool, + "protectedSettings": {}, + "provisionAfterExtensions": ["str"], + "settings": {}, + "typeHandlerVersion": "str", + } + ], + "licenseType": "str", + "nodePlacementConfiguration": {"policy": "str"}, + "osDisk": { + "caching": "str", + "diskSizeGB": 0, + "ephemeralOSDiskSettings": {"placement": "CacheDisk"}, + "managedDisk": { + "securityProfile": {"securityEncryptionType": "str"}, + "storageAccountType": "str", + }, + "writeAcceleratorEnabled": bool, + }, + "securityProfile": { + "encryptionAtHost": bool, + "securityType": "str", + "uefiSettings": {"secureBootEnabled": bool, "vTpmEnabled": bool}, + }, + "serviceArtifactReference": {"id": "str"}, + "windowsConfiguration": {"enableAutomaticUpdates": bool}, + } + }, + "displayName": "str", + "etag": "str", + "id": "str", + "identity": { + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "interNodeCommunication": "str", + "lastModified": "2020-02-20 00:00:00", + "metadata": [{"name": "str", "value": "str"}], + "mountConfiguration": [ + { + "azureBlobFileSystemConfiguration": { + "accountName": "str", + "containerName": "str", + "relativeMountPath": "str", + "accountKey": "str", + "blobfuseOptions": "str", + "identityReference": {"resourceId": "str"}, + "sasKey": "str", + }, + "azureFileShareConfiguration": { + "accountKey": "str", + "accountName": "str", + "azureFileUrl": "str", + "relativeMountPath": "str", + "mountOptions": "str", + }, + "cifsMountConfiguration": { + "password": "str", + "relativeMountPath": "str", + "source": "str", + "userName": "str", + "mountOptions": "str", + }, + "nfsMountConfiguration": {"relativeMountPath": "str", "source": "str", "mountOptions": "str"}, + } + ], + "name": "str", + "networkConfiguration": { + "dynamicVnetAssignmentScope": "none", + "enableAcceleratedNetworking": bool, + "endpointConfiguration": { + "inboundNatPools": [ + { + "backendPort": 0, + "frontendPortRangeEnd": 0, + "frontendPortRangeStart": 0, + "name": "str", + "protocol": "str", + "networkSecurityGroupRules": [ + { + "access": "str", + "priority": 0, + "sourceAddressPrefix": "str", + "sourcePortRanges": ["str"], + } + ], + } + ] + }, + "publicIPAddressConfiguration": {"ipAddressIds": ["str"], "provision": "str"}, + "subnetId": "str", + }, + "provisioningState": "str", + "provisioningStateTransitionTime": "2020-02-20 00:00:00", + "resizeOperationStatus": { + "errors": [{"code": "str", "message": "str", "details": [...]}], + "nodeDeallocationOption": "str", + "resizeTimeout": "1 day, 0:00:00", + "startTime": "2020-02-20 00:00:00", + "targetDedicatedNodes": 0, + "targetLowPriorityNodes": 0, + }, + "resourceTags": {"str": "str"}, + "scaleSettings": { + "autoScale": {"formula": "str", "evaluationInterval": "1 day, 0:00:00"}, + "fixedScale": { + "nodeDeallocationOption": "str", + "resizeTimeout": "PT15M", + "targetDedicatedNodes": 0, + "targetLowPriorityNodes": 0, + }, + }, + "startTask": { + "commandLine": "str", + "containerSettings": { + "imageName": "str", + "containerHostBatchBindMounts": [{"isReadOnly": bool, "source": "str"}], + "containerRunOptions": "str", + "registry": { + "identityReference": {"resourceId": "str"}, + "password": "str", + "registryServer": "str", + "username": "str", + }, + "workingDirectory": "str", + }, + "environmentSettings": [{"name": "str", "value": "str"}], + "maxTaskRetryCount": 0, + "resourceFiles": [ + { + "autoStorageContainerName": "str", + "blobPrefix": "str", + "fileMode": "str", + "filePath": "str", + "httpUrl": "str", + "identityReference": {"resourceId": "str"}, + "storageContainerUrl": "str", + } + ], + "userIdentity": {"autoUser": {"elevationLevel": "str", "scope": "str"}, "userName": "str"}, + "waitForSuccess": bool, + }, + "tags": {"str": "str"}, + "targetNodeCommunicationMode": "str", + "taskSchedulingPolicy": {"nodeFillType": "Spread"}, + "taskSlotsPerNode": 1, + "type": "str", + "upgradePolicy": { + "mode": "str", + "automaticOSUpgradePolicy": { + "disableAutomaticRollback": bool, + "enableAutomaticOSUpgrade": bool, + "osRollingUpgradeDeferral": bool, + "useRollingUpgradePolicy": bool, + }, + "rollingUpgradePolicy": { + "enableCrossZoneUpgrade": bool, + "maxBatchInstancePercent": 0, + "maxUnhealthyInstancePercent": 0, + "maxUnhealthyUpgradedInstancePercent": 0, + "pauseTimeBetweenBatches": "str", + "prioritizeUnhealthyInstances": bool, + "rollbackFailedInstancesOnPolicyBreach": bool, + }, + }, + "userAccounts": [ + { + "name": "str", + "password": "str", + "elevationLevel": "str", + "linuxUserConfiguration": {"gid": 0, "sshPrivateKey": "str", "uid": 0}, + "windowsUserConfiguration": {"loginMode": "str"}, + } + ], + "vmSize": "str", + }, + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.pool.update( + resource_group_name=resource_group.name, + account_name="str", + pool_name="str", + parameters={ + "allocationState": "str", + "allocationStateTransitionTime": "2020-02-20 00:00:00", + "applicationLicenses": ["str"], + "applicationPackages": [{"id": "str", "version": "str"}], + "autoScaleRun": { + "evaluationTime": "2020-02-20 00:00:00", + "error": {"code": "str", "message": "str", "details": [...]}, + "results": "str", + }, + "certificates": [{"id": "str", "storeLocation": "str", "storeName": "str", "visibility": ["str"]}], + "creationTime": "2020-02-20 00:00:00", + "currentDedicatedNodes": 0, + "currentLowPriorityNodes": 0, + "currentNodeCommunicationMode": "str", + "deploymentConfiguration": { + "virtualMachineConfiguration": { + "imageReference": { + "communityGalleryImageId": "str", + "id": "str", + "offer": "str", + "publisher": "str", + "sharedGalleryImageId": "str", + "sku": "str", + "version": "str", + }, + "nodeAgentSkuId": "str", + "containerConfiguration": { + "type": "str", + "containerImageNames": ["str"], + "containerRegistries": [ + { + "identityReference": {"resourceId": "str"}, + "password": "str", + "registryServer": "str", + "username": "str", + } + ], + }, + "dataDisks": [{"diskSizeGB": 0, "lun": 0, "caching": "str", "storageAccountType": "str"}], + "diskEncryptionConfiguration": {"targets": ["str"]}, + "extensions": [ + { + "name": "str", + "publisher": "str", + "type": "str", + "autoUpgradeMinorVersion": bool, + "enableAutomaticUpgrade": bool, + "protectedSettings": {}, + "provisionAfterExtensions": ["str"], + "settings": {}, + "typeHandlerVersion": "str", + } + ], + "licenseType": "str", + "nodePlacementConfiguration": {"policy": "str"}, + "osDisk": { + "caching": "str", + "diskSizeGB": 0, + "ephemeralOSDiskSettings": {"placement": "CacheDisk"}, + "managedDisk": { + "securityProfile": {"securityEncryptionType": "str"}, + "storageAccountType": "str", + }, + "writeAcceleratorEnabled": bool, + }, + "securityProfile": { + "encryptionAtHost": bool, + "securityType": "str", + "uefiSettings": {"secureBootEnabled": bool, "vTpmEnabled": bool}, + }, + "serviceArtifactReference": {"id": "str"}, + "windowsConfiguration": {"enableAutomaticUpdates": bool}, + } + }, + "displayName": "str", + "etag": "str", + "id": "str", + "identity": { + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "interNodeCommunication": "str", + "lastModified": "2020-02-20 00:00:00", + "metadata": [{"name": "str", "value": "str"}], + "mountConfiguration": [ + { + "azureBlobFileSystemConfiguration": { + "accountName": "str", + "containerName": "str", + "relativeMountPath": "str", + "accountKey": "str", + "blobfuseOptions": "str", + "identityReference": {"resourceId": "str"}, + "sasKey": "str", + }, + "azureFileShareConfiguration": { + "accountKey": "str", + "accountName": "str", + "azureFileUrl": "str", + "relativeMountPath": "str", + "mountOptions": "str", + }, + "cifsMountConfiguration": { + "password": "str", + "relativeMountPath": "str", + "source": "str", + "userName": "str", + "mountOptions": "str", + }, + "nfsMountConfiguration": {"relativeMountPath": "str", "source": "str", "mountOptions": "str"}, + } + ], + "name": "str", + "networkConfiguration": { + "dynamicVnetAssignmentScope": "none", + "enableAcceleratedNetworking": bool, + "endpointConfiguration": { + "inboundNatPools": [ + { + "backendPort": 0, + "frontendPortRangeEnd": 0, + "frontendPortRangeStart": 0, + "name": "str", + "protocol": "str", + "networkSecurityGroupRules": [ + { + "access": "str", + "priority": 0, + "sourceAddressPrefix": "str", + "sourcePortRanges": ["str"], + } + ], + } + ] + }, + "publicIPAddressConfiguration": {"ipAddressIds": ["str"], "provision": "str"}, + "subnetId": "str", + }, + "provisioningState": "str", + "provisioningStateTransitionTime": "2020-02-20 00:00:00", + "resizeOperationStatus": { + "errors": [{"code": "str", "message": "str", "details": [...]}], + "nodeDeallocationOption": "str", + "resizeTimeout": "1 day, 0:00:00", + "startTime": "2020-02-20 00:00:00", + "targetDedicatedNodes": 0, + "targetLowPriorityNodes": 0, + }, + "resourceTags": {"str": "str"}, + "scaleSettings": { + "autoScale": {"formula": "str", "evaluationInterval": "1 day, 0:00:00"}, + "fixedScale": { + "nodeDeallocationOption": "str", + "resizeTimeout": "PT15M", + "targetDedicatedNodes": 0, + "targetLowPriorityNodes": 0, + }, + }, + "startTask": { + "commandLine": "str", + "containerSettings": { + "imageName": "str", + "containerHostBatchBindMounts": [{"isReadOnly": bool, "source": "str"}], + "containerRunOptions": "str", + "registry": { + "identityReference": {"resourceId": "str"}, + "password": "str", + "registryServer": "str", + "username": "str", + }, + "workingDirectory": "str", + }, + "environmentSettings": [{"name": "str", "value": "str"}], + "maxTaskRetryCount": 0, + "resourceFiles": [ + { + "autoStorageContainerName": "str", + "blobPrefix": "str", + "fileMode": "str", + "filePath": "str", + "httpUrl": "str", + "identityReference": {"resourceId": "str"}, + "storageContainerUrl": "str", + } + ], + "userIdentity": {"autoUser": {"elevationLevel": "str", "scope": "str"}, "userName": "str"}, + "waitForSuccess": bool, + }, + "tags": {"str": "str"}, + "targetNodeCommunicationMode": "str", + "taskSchedulingPolicy": {"nodeFillType": "Spread"}, + "taskSlotsPerNode": 1, + "type": "str", + "upgradePolicy": { + "mode": "str", + "automaticOSUpgradePolicy": { + "disableAutomaticRollback": bool, + "enableAutomaticOSUpgrade": bool, + "osRollingUpgradeDeferral": bool, + "useRollingUpgradePolicy": bool, + }, + "rollingUpgradePolicy": { + "enableCrossZoneUpgrade": bool, + "maxBatchInstancePercent": 0, + "maxUnhealthyInstancePercent": 0, + "maxUnhealthyUpgradedInstancePercent": 0, + "pauseTimeBetweenBatches": "str", + "prioritizeUnhealthyInstances": bool, + "rollbackFailedInstancesOnPolicyBreach": bool, + }, + }, + "userAccounts": [ + { + "name": "str", + "password": "str", + "elevationLevel": "str", + "linuxUserConfiguration": {"gid": 0, "sshPrivateKey": "str", "uid": 0}, + "windowsUserConfiguration": {"loginMode": "str"}, + } + ], + "vmSize": "str", + }, + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.pool.begin_delete( + resource_group_name=resource_group.name, + account_name="str", + pool_name="str", + api_version="2024-07-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.pool.get( + resource_group_name=resource_group.name, + account_name="str", + pool_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_disable_auto_scale(self, resource_group): + response = await self.client.pool.disable_auto_scale( + resource_group_name=resource_group.name, + account_name="str", + pool_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_stop_resize(self, resource_group): + response = await self.client.pool.stop_resize( + resource_group_name=resource_group.name, + account_name="str", + pool_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_private_endpoint_connection_operations.py b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_private_endpoint_connection_operations.py new file mode 100644 index 000000000000..577cdc32cbbd --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_private_endpoint_connection_operations.py @@ -0,0 +1,81 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestBatchManagementPrivateEndpointConnectionOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_batch_account(self, resource_group): + response = self.client.private_endpoint_connection.list_by_batch_account( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.private_endpoint_connection.get( + resource_group_name=resource_group.name, + account_name="str", + private_endpoint_connection_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.private_endpoint_connection.begin_update( + resource_group_name=resource_group.name, + account_name="str", + private_endpoint_connection_name="str", + parameters={ + "etag": "str", + "groupIds": ["str"], + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": {"status": "str", "actionsRequired": "str", "description": "str"}, + "provisioningState": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-07-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.private_endpoint_connection.begin_delete( + resource_group_name=resource_group.name, + account_name="str", + private_endpoint_connection_name="str", + api_version="2024-07-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_private_endpoint_connection_operations_async.py b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_private_endpoint_connection_operations_async.py new file mode 100644 index 000000000000..3688ff388dd2 --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_private_endpoint_connection_operations_async.py @@ -0,0 +1,90 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch.aio import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestBatchManagementPrivateEndpointConnectionOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_batch_account(self, resource_group): + response = self.client.private_endpoint_connection.list_by_batch_account( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.private_endpoint_connection.get( + resource_group_name=resource_group.name, + account_name="str", + private_endpoint_connection_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.private_endpoint_connection.begin_update( + resource_group_name=resource_group.name, + account_name="str", + private_endpoint_connection_name="str", + parameters={ + "etag": "str", + "groupIds": ["str"], + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "status": "str", + "actionsRequired": "str", + "description": "str", + }, + "provisioningState": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-07-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.private_endpoint_connection.begin_delete( + resource_group_name=resource_group.name, + account_name="str", + private_endpoint_connection_name="str", + api_version="2024-07-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_private_link_resource_operations.py b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_private_link_resource_operations.py new file mode 100644 index 000000000000..7477336bef11 --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_private_link_resource_operations.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestBatchManagementPrivateLinkResourceOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_batch_account(self, resource_group): + response = self.client.private_link_resource.list_by_batch_account( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.private_link_resource.get( + resource_group_name=resource_group.name, + account_name="str", + private_link_resource_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_private_link_resource_operations_async.py b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_private_link_resource_operations_async.py new file mode 100644 index 000000000000..5e37e447c29f --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/generated_tests/test_batch_management_private_link_resource_operations_async.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch.aio import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestBatchManagementPrivateLinkResourceOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_batch_account(self, resource_group): + response = self.client.private_link_resource.list_by_batch_account( + resource_group_name=resource_group.name, + account_name="str", + api_version="2024-07-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.private_link_resource.get( + resource_group_name=resource_group.name, + account_name="str", + private_link_resource_name="str", + api_version="2024-07-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/batch/azure-mgmt-batch/tests/test_batch_management_batch_account_operations_async_test.py b/sdk/batch/azure-mgmt-batch/tests/test_batch_management_batch_account_operations_async_test.py new file mode 100644 index 000000000000..f7e664542fd0 --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/tests/test_batch_management_batch_account_operations_async_test.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch.aio import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestBatchManagementBatchAccountOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.batch_account.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + assert result == [] diff --git a/sdk/batch/azure-mgmt-batch/tests/test_batch_management_batch_account_operations_test.py b/sdk/batch/azure-mgmt-batch/tests/test_batch_management_batch_account_operations_test.py new file mode 100644 index 000000000000..8e1b9e190ff1 --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/tests/test_batch_management_batch_account_operations_test.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestBatchManagementBatchAccountOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.batch_account.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + assert result == [] + diff --git a/sdk/batch/azure-mgmt-batch/tests/test_batch_management_operations_async_test.py b/sdk/batch/azure-mgmt-batch/tests/test_batch_management_operations_async_test.py new file mode 100644 index 000000000000..36b05f07db49 --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/tests/test_batch_management_operations_async_test.py @@ -0,0 +1,28 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch.aio import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestBatchManagementOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.operations.list() + result = [r async for r in response] + assert result + diff --git a/sdk/batch/azure-mgmt-batch/tests/test_batch_management_operations_test.py b/sdk/batch/azure-mgmt-batch/tests/test_batch_management_operations_test.py new file mode 100644 index 000000000000..d5499a56e915 --- /dev/null +++ b/sdk/batch/azure-mgmt-batch/tests/test_batch_management_operations_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.batch import BatchManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +class TestBatchManagementOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(BatchManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list() + result = [r for r in response] + assert result + diff --git a/sdk/batch/azure-mgmt-batch/tests/test_mgmt_batch.py b/sdk/batch/azure-mgmt-batch/tests/test_mgmt_batch_test.py similarity index 99% rename from sdk/batch/azure-mgmt-batch/tests/test_mgmt_batch.py rename to sdk/batch/azure-mgmt-batch/tests/test_mgmt_batch_test.py index b50f256dafb0..71c0ff896ffa 100644 --- a/sdk/batch/azure-mgmt-batch/tests/test_mgmt_batch.py +++ b/sdk/batch/azure-mgmt-batch/tests/test_mgmt_batch_test.py @@ -33,7 +33,7 @@ EXPECTED_POOL_QUOTA = 100 SECRET_FIELDS = ["primary", "secondary"] - +@pytest.mark.live_test_only class TestMgmtBatch(AzureMgmtRecordedTestCase): def setup_method(self, method): @@ -320,6 +320,7 @@ def test_mgmt_batch_certificates(self, resource_group, location, batch_account): response = self.mgmt_batch_client.certificate.begin_delete(resource_group.name, batch_account.name, certificate) assert response.result() is None + @pytest.mark.skip("model CloudServiceConfiguration deprecated") @pytest.mark.skipif(os.getenv('AZURE_TEST_RUN_LIVE') not in ('yes', 'true'), reason='only run live test') @ResourceGroupPreparer(location=AZURE_LOCATION) @SimpleBatchPreparer(location=AZURE_LOCATION)